internal static ParseStringDelegate GetGenericQueueParseFn() { var enumerableInterface = typeof(T).GetTypeWithGenericInterfaceOf(typeof(IEnumerable <>)); var elementType = enumerableInterface.GenericTypeArguments()[0]; var genericType = typeof(SpecializedQueueElements <>).MakeGenericType(elementType); var mi = genericType.GetPublicStaticMethod("ConvertToQueue"); var convertToQueue = (ConvertObjectDelegate)mi.MakeDelegate(typeof(ConvertObjectDelegate)); var parseFn = DeserializeEnumerable <T, TSerializer> .GetParseFn(); return(x => convertToQueue(parseFn(x))); }
internal static ParseStringDelegate GetGenericStackParseFn() { var enumerableInterface = typeof(T).GetTypeWithGenericInterfaceOf(typeof(IEnumerable <>)); var elementType = enumerableInterface.GetGenericArguments()[0]; var genericType = typeof(SpecializedQueueElements <>).MakeGenericType(elementType); var mi = genericType.GetMethod("ConvertToStack", BindingFlags.Static | BindingFlags.Public); var convertToQueue = (ConvertObjectDelegate)Delegate.CreateDelegate(typeof(ConvertObjectDelegate), mi); var parseFn = DeserializeEnumerable <T, TSerializer> .GetParseFn(); return(x => convertToQueue(parseFn(x))); }
public static ParseStringDelegate GetGenericEnumerableParseFn() { var enumerableInterface = typeof(T).GetTypeWithGenericInterfaceOf(typeof(IEnumerable <>)); var elementType = enumerableInterface.GenericTypeArguments()[0]; var genericType = typeof(SpecializedEnumerableElements <,>).MakeGenericType(typeof(T), elementType); var fi = genericType.GetPublicStaticField("ConvertFn"); var convertFn = fi.GetValue(null) as ConvertObjectDelegate; if (convertFn == null) { return(null); } var parseFn = DeserializeEnumerable <T, TSerializer> .GetParseFn(); return(x => convertFn(parseFn(x))); }