Skip to content

Instantly share code, notes, and snippets.

Continual death march. May not respond quickly, sorry.

Troy Willmot Yortw

Continual death march. May not respond quickly, sorry.
View GitHub Profile
Yortw / Xamarin Forms Instanced Behaviour
Created Feb 12, 2015
A base class for Xamarin Behaviours that support bound properties but not instance sharing (one behaviour instance used against multiple associated objects simultaneously).
View Xamarin Forms Instanced Behaviour
/// <summary>
/// Base class for creating Xamarin Forms behaviours that support bound properties on the behaviour, and as a neccesity do not support being shared across multiple associated objects.
/// </summary>
/// <typeparam name="T">The type of item this behaviour is bound to, must dervice from <see cref="Xamarin.Forms.BindableObject"/>.</typeparam>
/// <remarks>
/// <para>See and for details on why <see cref="Xamarin.Forms.Behavior{T}"/> isn't suitable on it's own.</para>
/// <para>Note, behaviours using this base class cannot be reused (simultaneously) across multiple objects. For example you can't attach the same behaviour instance to two different <see cref="Xamarin.Forms.View"/> instances, you must create a seperate behaviour instance for each one. It is also possible for Xamarin forms to attempt instance sharing under some conditions (triggers, styles), so these behaviour are not suitable fo
Yortw / JsonEnumerableConverter.cs
Last active Aug 30, 2015
A Json.Net converter for IEnumerator<T> types, serialises enumerator results as a json array. Great when you need to include type information in serialised data but want to return raw linq results for controller actions, instead of calling toarray/tolist. See
View JsonEnumerableConverter.cs
internal class JsonEnumerableConverter : JsonConverter
public override bool CanConvert(Type objectType)
if (!objectType.IsGenericType) return false;
var genericType = objectType.GenericTypeArguments.First();
var enumeratorType = typeof(IEnumerator<>).MakeGenericType(genericType);
return (objectType.GetInterface(enumeratorType.Name) != null);

Keybase proof

I hereby claim:

  • I am yortw on github.
  • I am yort ( on keybase.
  • I have a public key whose fingerprint is 4EE7 8C5A FE9A C8DB 893C 855B B442 B768 C80B 5A3B

To claim this, I am signing this object:

Yortw / CachedReflectionJsonConverter.cs
Created Jan 14, 2017
UWP Json.Net CachedReflection Converter
View CachedReflectionJsonConverter.cs
public sealed class CachedReflectionJsonConverter : JsonConverter
private IEnumerable<Type> _HandledTypes;
private static Dictionary<Type, CachedTypeInformation> _ReflectionCache = new Dictionary<Type, CachedTypeInformation>();
public CachedReflectionJsonConverter(IEnumerable<Type> handledTypes)
_HandledTypes = handledTypes.ToArray();