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.Generic; | |
| using System.Collections.ObjectModel; | |
| using System.Threading; | |
| namespace WpfApplication1 | |
| { | |
| public class AsyncObservableCollection<T> : ObservableCollection<T> | |
| { | |
| private readonly SynchronizationContext _synchronizationContext = SynchronizationContext.Current; |
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 class Deferral : IDisposable | |
| { | |
| private TaskCompletionSource<object> _completionSource = new TaskCompletionSource<object>(); | |
| ~Deferral() | |
| { | |
| Dispose(false); | |
| } | |
| public void Dispose() |
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
| async void Main() | |
| { | |
| try | |
| { | |
| await FooAsync().AsyncTrace(); | |
| } | |
| catch(Exception ex) | |
| { | |
| ex.FullTrace().Dump(); | |
| } |
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.Runtime.InteropServices; | |
| namespace ADS | |
| { | |
| public static class AlternateDataStream | |
| { | |
| public static FileStream Open(string path, string streamName, FileMode mode) | |
| { |
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 IEnumerable<T> Distinct<T, U>(this IEnumerable<T> source, IEqualityComparer<U> comparer) | |
| where T : U | |
| { | |
| IEqualityComparer<T> comparer2 = (IEqualityComparer<T>)comparer; | |
| return Enumerable.Distinct<T>(source, comparer2); | |
| } |
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 field = typeof(DayOfWeek).GetField("value__"); | |
| var d = DayOfWeek.Monday; | |
| Console.WriteLine (d); | |
| TypedReference r = __makeref(d); | |
| field.SetValueDirect(r, 4); | |
| Console.WriteLine (d); |
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
| async void Main() | |
| { | |
| Console.WriteLine ("Before Using"); | |
| await Async.Using(new Test(), t => | |
| { | |
| Console.WriteLine ("In Using body"); | |
| throw new Exception("Oops"); | |
| }); | |
| Console.WriteLine ("After Using"); | |
| } |
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.Threading.Tasks; | |
| using Windows.Security.Cryptography; | |
| using Windows.Security.Cryptography.DataProtection; | |
| namespace App1 | |
| { | |
| public static class DataProtectionExtensions | |
| { | |
| public static async Task<string> ProtectAsync(this string clearText, string scope = "LOCAL=user") |
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
| <#@ template debug="false" hostspecific="true" language="C#" #> | |
| <#@ assembly name="System.Core" #> | |
| <#@ assembly name="System.Xml" #> | |
| <#@ assembly name="System.Xml.Linq" #> | |
| <#@ assembly name="EnvDTE" #> | |
| <#@ import namespace="System.IO" #> | |
| <#@ import namespace="System.Linq" #> | |
| <#@ import namespace="System.Text" #> | |
| <#@ import namespace="System.Globalization" #> | |
| <#@ import namespace="System.Collections.Generic" #> |
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.Windows.Input; | |
| namespace QuestionableContent.Input | |
| { | |
| public class DelegateCommand : ICommand | |
| { | |
| private readonly Action _execute; | |
| private readonly Func<bool> _canExecute; |