private static Type CreateDuckTypeFor <T>(bool isFuzzy) { var typeMaker = new TypeMaker(); return(isFuzzy ? typeMaker.MakeFuzzyTypeImplementing <T>() : typeMaker.MakeTypeImplementing <T>()); }
internal static T ForceDuckAs <T>(IDictionary <string, object> src, bool allowFuzzy) { var typeMaker = new TypeMaker(); if (allowFuzzy && src.IsCaseSensitive()) { src = src.ToCaseInsensitiveDictionary(); } var type = allowFuzzy ? typeMaker.MakeTypeImplementing <T>() : typeMaker.MakeFuzzyTypeImplementing <T>(); return((T)Activator.CreateInstance(type, new object[] { new[] { src } })); }
private static Type CreateDuckTypeFor <T>(bool isFuzzy, bool allowDefaultsForMissingProperties) { var typeMaker = new TypeMaker(); if (!isFuzzy) { return(typeMaker.MakeTypeImplementing <T>()); } return(allowDefaultsForMissingProperties ? typeMaker.MakeFuzzyDefaultingTypeImplementing <T>() : typeMaker.MakeFuzzyTypeImplementing <T>()); }