// 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); }
// 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; }