This file contains hidden or 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 static class Extensions | |
{ | |
static readonly ConcurrentDictionary<string, object> TaskDictionary = new ConcurrentDictionary<string, object>(); | |
public static async Task<T> GetOrAdd<T>(this IMemoryCache cache, string key, Func<string, Task<T>> factoryMethod) | |
{ | |
object result; | |
if (!cache.TryGetValue(key, out result)) | |
{ | |
var asyncLazy = (AsyncLazy<T>)TaskDictionary.GetOrAdd(key, (k) => { |
This file contains hidden or 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.IO; | |
using System.Text; | |
using Newtonsoft.Json.Linq; | |
namespace ReadTorrentFile | |
{ | |
class Program | |
{ | |
static void Main(string[] args) |
This file contains hidden or 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.Data.SqlClient; | |
using System.Linq; | |
using System.Management.Automation; | |
using System.Threading.Tasks; | |
using JetBrains.Annotations; | |
using TTRider.PowerShellAsync; | |
namespace PowerShellAsyncExample | |
{ | |
[Cmdlet(VerbsLifecycle.Invoke, "MultiSql")] |
This file contains hidden or 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
protected async override Task BeginProcessingAsync() | |
{ | |
// before processing of the first item in a pipeline | |
} | |
protected async override Task ProcessRecordAsync() | |
{ | |
// process item from a pipeline | |
} | |
This file contains hidden or 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
protected override void BeginProcessing() | |
{ | |
// before processing of the first item in a pipeline | |
} | |
protected override void ProcessRecord() | |
{ | |
// process item from a pipeline | |
} |
This file contains hidden or 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
protected override void ProcessRecord() | |
{ | |
// processing logic | |
} |
This file contains hidden or 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; | |
using System.Collections.Generic; | |
using System.Linq; | |
namespace TTRider.Collections | |
{ | |
public class WeightedValue<T> | |
{ | |
public WeightedValue() |
This file contains hidden or 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 titlecase = CultureInfo.CurrentCulture | |
.TextInfo | |
.ToTitleCase(" here is my string in title case"); | |
// Here Is My String In Title Case |
This file contains hidden or 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 wrongResult = "Straße" == "Strasse"; // false | |
var rightResult = string.Equals("Straße", "Strasse", StringComparison.CurrentCulture); // true |
This file contains hidden or 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
bool Better02(string arg) | |
{ | |
foreach (var str in mystrings) | |
{ | |
if (string.Equals(arg, str, StringComparison.CurrentCultureIgnoreCase)) | |
{ | |
return true; | |
} | |
} | |
return false; |
NewerOlder