Beispiel #1
0
        // Public Methods 

        public ClassReplaceInfo FindOneClassReplacer(Type srcType)
        {
            var type = srcType;

            if (type.IsGenericType)
            {
                type = type.GetGenericTypeDefinition();
            }
            var replacers = ClassReplacers.Where(i => i.SourceType == type).ToArray();

            if (!replacers.Any())
            {
                return(null);
            }
            if (replacers.Length > 1)
            {
                throw new Exception(string.Format("wise gecko, class replacers has more than 1 replacer for {0}",
                                                  type.FullName));
            }
            var atype = replacers[0];

            if (srcType.IsGenericType)
            {
                var a     = srcType.GetGenericArguments();
                var gtype = atype.ReplaceBy.MakeGenericType(a);
                atype = new ClassReplaceInfo(srcType, gtype);
            }

            return(atype);
        }
Beispiel #2
0
		// Public Methods 

        public ClassReplaceInfo FindOneClassReplacer(Type srcType)
        {
            var type = srcType;
            if (type.IsGenericType)
                type = type.GetGenericTypeDefinition();
            var replacers = ClassReplacers.Where(i => i.SourceType == type).ToArray();
            if (!replacers.Any()) return null;
            if (replacers.Length > 1)
                throw new Exception(string.Format("wise gecko, class replacers has more than 1 replacer for {0}", type.FullName));
            var atype = replacers[0];

            if (srcType.IsGenericType)
            {
                var a = srcType.GetGenericArguments();
                var gtype = atype.ReplaceBy.MakeGenericType(a);
                atype = new ClassReplaceInfo(srcType, gtype);
            }
            return atype;
        }