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.Collections.Generic; | |
using System.IO; | |
using System.Linq; | |
namespace Commons { | |
public class UriTemplate1 { | |
public static void Expand(TextWriter writer, string template, IDictionary<string, object?> parameters) { |
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.Collections.Generic; | |
using System.ComponentModel; | |
using System.Globalization; | |
using System.Reflection; | |
namespace Inasync { | |
//[TypeDescriptionProvider(typeof(OptionalTypeDescriptionProvider))] | |
[TypeConverter(typeof(OptionalTypeConverter))] |
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
<Project Sdk="Microsoft.NET.Sdk"> | |
<PropertyGroup> | |
<TargetFramework>netstandard2.0</TargetFramework> | |
<LangVersion>9.0</LangVersion> | |
<Nullable>enable</Nullable> | |
<IsRoslynComponent>true</IsRoslynComponent> | |
</PropertyGroup> | |
<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
<Project Sdk="Microsoft.NET.Sdk"> | |
<PropertyGroup> | |
<TargetFramework>netstandard2.0</TargetFramework> | |
<LangVersion>9.0</LangVersion> | |
<Nullable>enable</Nullable> | |
<IsRoslynComponent>true</IsRoslynComponent> | |
</PropertyGroup> | |
<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
using System; | |
namespace Commons { | |
/// <remarks> | |
/// cf. Proposal: Expression blocks https://github.com/dotnet/csharplang/issues/3086 | |
/// cf. Proposal: Sequence Expressions https://github.com/dotnet/csharplang/issues/377 | |
/// </remarks> | |
public static class ExpressionFunc { |
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.Collections.Generic; | |
namespace Commons { | |
public static class EnumerableExtensions { | |
public static IEnumerable<T> WithDisposable<T>(this IEnumerable<T> source, IDisposable disposable) { | |
try { | |
foreach (T item in source) { |
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
/// Usage | |
void Main() { | |
var weights = new decimal[] { 4, 6, 7.3m }; | |
Prorate(total: 1014, weights: weights, ProrationRounding.SpecifiedOrder).Dump(nameof(ProrationRounding.SpecifiedOrder)); | |
Prorate(total: 1014, weights: weights, ProrationRounding.DecimalPartDescending).Dump(nameof(ProrationRounding.DecimalPartDescending)); | |
ProrateExact(total: 1014, weights: weights).Dump(nameof(ProrateExact)); | |
} | |
/// <summary> |
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
#nullable enable | |
using System; | |
using System.Collections.Generic; | |
namespace Commons { | |
public delegate bool StringSplitPredicate(ref int index); | |
public static class StringExtensions { |
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
#nullable enable | |
using System; | |
using System.Collections.Generic; | |
namespace Commons { | |
/// <summary> | |
/// 自然順ソート (Natural sort order) を行う <see cref="IComparer{T}"/> の実装。 | |
/// cf. https://ja.wikipedia.org/wiki/%E8%87%AA%E7%84%B6%E9%A0%86 |
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
#nullable enable | |
using System; | |
using System.Collections.Generic; | |
namespace Commons { | |
/// <summary> | |
/// シーケンスの比較を行う <see cref="IComparer{T}"/> 実装。 | |
/// </summary> |