$lineBreak="`r`n"$noticeTemplate="// Copyright (c) Microsoft. All rights reserved.$lineBreak// Licensed under the MIT license. See LICENSE file in the project root for full license information.$lineBreak$lineBreak"$tokenToReplace=[regex]::Escape("[FileName]")FunctionCreateFileSpecificNotice($sourcePath){$fileName=Split-Path$sourcePath-Leaf$fileSpecificNotice=$noticeTemplate-replace$tokenToReplace,$fileNamereturn$fileSpecificNotice}FunctionSourceFileContainsNotice($sourcePath){$copyrightSnippet=[regex]::Escape("// Copyright (c) Microsoft")$fileSpecificNotice=CreateFileSpecificNotice($sourcePath)$arrMatchResults=Get-Content$sourcePath|Select-String$copyrightSnippetif($arrMatchResults-ne$null-and$arrMatchResults.count-gt0){return$true}else{return$false}}FunctionAddHeaderToSourceFile($sourcePath){# "Source path is: $sourcePath"$containsNotice=SourceFileContainsNotice($sourcePath)# "Contains notice: $containsNotice"if($containsNotice){#"Source file already contains notice -- not adding"}else{#"Source file does not contain notice -- adding"$noticeToInsert=CreateFileSpecificNotice($sourcePath)$fileLines=(Get-Content$sourcePath)-join$lineBreak$content=$noticeToInsert+$fileLines+$lineBreak$content|Out-File$sourcePath-Encodingutf8}}$scriptPath=split-path-parent$MyInvocation.MyCommand.Definition$parent=(get-item$scriptPath).Parent.FullName$startingPath="$parent\src"Get-ChildItem$startingPath\*.cs-Recurse|SelectFullName|Foreach-Object{AddHeaderToSourceFile($_.FullName)}Get-ChildItem$startingPath\*.fs-Recurse|SelectFullName|Foreach-Object{AddHeaderToSourceFile($_.FullName)}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。