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
[SuppressMessage("ReSharper", "VirtualMemberNeverOverridden.Global", Justification = "Public API")] | |
[SuppressMessage("ReSharper", "UnusedMember.Global", Justification = "Public API")] | |
public class NotifyPropertyChangedBase : INotifyPropertyChanged { | |
/// <summary> | |
/// Sets a backing field value and if it's changed raise a notification. | |
/// </summary> | |
/// <typeparam name="T">The type of the value being set.</typeparam> | |
/// <param name="oldValue">A reference to the field to update.</param> | |
/// <param name="newValue">The new value.</param> |
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
<d:DesignProperties.DataContext> | |
<$ViewModel$ /> | |
</d:DesignProperties.DataContext> | |
d:DataContext="{d:DesignInstance Type=$ViewModel$, IsDesignTimeCreatable=False}" |
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
// http://jake.ginnivan.net/pack-uri-in-unit-tests/ | |
PackUriHelper.Create(new Uri("reliable://0")); // register pack-uri |
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
// Source: https://gist.github.com/SchreinerK/73002d709fe6ee365cd3d7b43186300c#file-mockservices-cs | |
// Version: 1.6 | |
using System; | |
using System.Collections.Generic; | |
using System.Reflection; | |
using System.Runtime.Serialization; | |
// ReSharper disable LocalizableElement | |
// ReSharper disable CheckNamespace |
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 dpd = DependencyPropertyDescriptor.FromProperty(TextEditor.IsModifiedProperty, typeof(TextEditor)); | |
dpd.AddValueChanged(_textEditor, TextEditor_IsModifiedChanged); | |
dpd.RemoveValueChanged(_textEditor, TextEditor_IsModifiedChanged); |
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 static string GenerateFullTypeName(Type type) | |
{ | |
var retType = new StringBuilder(); | |
if (type.IsGenericType) | |
{ | |
var parentType = type.FullName.Split('`'); | |
var arguments = type.GetGenericArguments(); | |
var argList = new StringBuilder(); |
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 static class AsyncHelpers | |
{ | |
/// <summary> | |
/// Execute's an async Task<T> method which has a void return value synchronously | |
/// </summary> | |
/// <param name="task">Task<T> method to execute</param> | |
public static void RunSync(Func<Task> task) | |
{ | |
var oldContext = SynchronizationContext.Current; | |
var synch = new ExclusiveSynchronizationContext(); |
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 static class WaitHandleAsyncExtension | |
{ | |
public static async Task<bool> WaitOneAsync(this WaitHandle handle, int millisecondsTimeout, CancellationToken cancellationToken) | |
{ | |
RegisteredWaitHandle registeredHandle = null; | |
var tokenRegistration = new CancellationTokenRegistration(); | |
try | |
{ | |
var tcs = new TaskCompletionSource<bool>(); | |
registeredHandle = ThreadPool.RegisterWaitForSingleObject( |
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 struct Result<TValue> | |
{ | |
internal Result(TValue value, bool success, object failureInfo) | |
{ | |
Value = value; | |
Success = success; | |
FailureInfo = failureInfo; | |
} | |
public TValue Value { get; private set; } |
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 sealed class GuidSemaphoreSlim : IDisposable | |
{ | |
private static readonly Dictionary<Guid,SemaphoreSlim> Handles=new Dictionary<Guid, SemaphoreSlim>(); | |
private readonly Guid _guid; | |
private readonly SemaphoreSlim _semaphore; | |
/// <summary> | |
/// Usage: using(await GuidSemaphoreSlim.WaitAsync(myGuid)) {...} | |
/// </summary> | |
public static async Task<IDisposable> WaitAsync(Guid guid) |