internal static ParseStringSegmentDelegate GetGenericQueueParseFn() { var enumerableInterface = typeof(T).GetTypeWithGenericInterfaceOf(typeof(IEnumerable <>)); var elementType = enumerableInterface.GetGenericArguments()[0]; var genericType = typeof(SpecializedQueueElements <>).MakeGenericType(elementType); var mi = genericType.GetStaticMethod("ConvertToQueue"); var convertToQueue = (ConvertObjectDelegate)mi.MakeDelegate(typeof(ConvertObjectDelegate)); var parseFn = DeserializeEnumerable <T, TSerializer> .GetParseStringSegmentFn(); return(x => convertToQueue(parseFn(x))); }
public static ParseStringSegmentDelegate GetGenericEnumerableParseStringSegmentFn() { var enumerableInterface = typeof(T).GetTypeWithGenericInterfaceOf(typeof(IEnumerable <>)); if (enumerableInterface == null) { return(null); } var elementType = enumerableInterface.GetGenericArguments()[0]; var genericType = typeof(SpecializedEnumerableElements <,>).MakeGenericType(typeof(T), elementType); var fi = genericType.GetPublicStaticField("ConvertFn"); if (!(fi.GetValue(null) is ConvertObjectDelegate convertFn)) { return(null); } var parseFn = DeserializeEnumerable <T, TSerializer> .GetParseStringSegmentFn(); return(x => convertFn(parseFn(x))); }