This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<ItemGroup> | |
<Compile Include="TSChineseDictionary.cs" /> | |
<Compile Include="Program.cs" /> | |
<Compile Include="Properties\AssemblyInfo.cs" /> | |
<Compile Include="TSChineseConverter.cs" /> | |
</ItemGroup> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.1.0-preview1-final" /> | |
<PackageReference Include="Serilog" Version="2.7.1-dev-00960" /> | |
<PackageReference Include="Serilog.Extensions.Logging" Version="2.0.2" /> | |
<PackageReference Include="Serilog.Sinks.File" Version="4.0.1-dev-00795" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 設定 DI | |
var serviceProvider = new ServiceCollection() | |
.AddLogging(loggingBuilder => loggingBuilder.AddSerilog(dispose: true)) | |
.BuildServiceProvider(); | |
// 建立 logger | |
Log.Logger = new LoggerConfiguration() | |
.Enrich.FromLogContext() | |
.WriteTo.File(opts.LogFileName, Serilog.Events.LogEventLevel.Information) | |
.CreateLogger(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class TSChineseDictionary | |
{ | |
private ILogger _logger; | |
public TSChineseDictionary(ILogger logger) | |
{ | |
_logger = logger; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Log.Information("應用程式開始執行。"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var dict = new TSChineseDictionary(Log.Logger); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Linq; | |
using Nuke.Common; | |
using Nuke.Common.Git; | |
using Nuke.Common.Tools.GitVersion; | |
using Nuke.Core; | |
using static Nuke.Common.Tools.DotNet.DotNetTasks; | |
using static Nuke.Core.IO.FileSystemTasks; | |
using static Nuke.Core.IO.PathConstruction; | |
using static Nuke.Core.EnvironmentInfo; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<ItemGroup> | |
<Compile Include="Form1.cs"> | |
<SubType>Form</SubType> | |
</Compile> | |
<Compile Include="Form1.Designer.cs"> | |
<DependentUpon>Form1.cs</DependentUpon> | |
</Compile> | |
<EmbeddedResource Include="Form1.resx"> | |
<DependentUpon>Form1.cs</DependentUpon> | |
<SubType>Designer</SubType> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
Utility functions for deleting old files. | |
Source: http://blog.danskingdom.com/powershell-functions-to-delete-old-files-and-empty-directories/ | |
#> | |
# Function to remove all empty directories under the given path. | |
# If -DeletePathIfEmpty is provided the given Path directory will also be deleted if it is empty. | |
# If -OnlyDeleteDirectoriesCreatedBeforeDate is provided, empty folders will only be deleted if they were created before the given date. | |
# If -OnlyDeleteDirectoriesNotModifiedAfterDate is provided, empty folders will only be deleted if they have not been written to after the given date. | |
function Remove-EmptyDirectories([parameter(Mandatory)][ValidateScript({Test-Path $_})][string] $Path, [switch] $DeletePathIfEmpty, [DateTime] $OnlyDeleteDirectoriesCreatedBeforeDate = [DateTime]::MaxValue, [DateTime] $OnlyDeleteDirectoriesNotModifiedAfterDate = [DateTime]::MaxValue, [switch] $OutputDeletedPaths, [switch] $WhatIf) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class DemoDeadlockController : ApiController | |
{ | |
[HttpGet] | |
public HttpResponseMessage DownloadPage() | |
{ | |
var task = MyDownloadPageAsync("https://www.huanlintalk.com"); | |
var content = task.Result; | |
return Request.CreateResponse($"網頁長度: {content.Length}"); | |
} |