public static IUIPropertyWriter Create <TType>() where TType : struct { var type = typeof(TType); UIPropertyParser <TType> parser = type.GetMethods(BindingFlags.Static | BindingFlags.Public).FirstOrDefault(x => x.Name == "TryParse" && x.GetParameters().Length == 2)?.CreateDelegate(typeof(UIPropertyParser <>).MakeGenericType(type)) as UIPropertyParser <TType>; //object parser = targetType.GetMethod("TryParse", BindingFlags.Static | BindingFlags.Public) Contract.Ensures(parser != null); return(new UIPropertyWriter <TType>(parser)); }
public UIPropertyWriter(UIPropertyParser <TValue> parser) { this.parser = parser; }