Example #1
0
        private static Type CreateDuckTypeFor <T>(bool isFuzzy)
        {
            var typeMaker = new TypeMaker();

            return(isFuzzy
                ? typeMaker.MakeFuzzyTypeImplementing <T>()
                : typeMaker.MakeTypeImplementing <T>());
        }
Example #2
0
        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 } }));
        }
Example #3
0
        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>());
        }