Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Continual death march. May not respond quickly, sorry.

Troy Willmot Yortw

💭
Continual death march. May not respond quickly, sorry.
View GitHub Profile
@Yortw
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 http://forums.xamarin.com/discussion/comment/101682 and https://bugzilla.xamarin.com/show_bug.cgi?id=26521 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
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 http://www.yortondotnet.com/2015/08/getting-lazy-with-linq-jsonnet-and.html
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);
View keybase.md

Keybase proof

I hereby claim:

  • I am yortw on github.
  • I am yort (https://keybase.io/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
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();
}
You can’t perform that action at this time.