public DeclarationsGenerator(TrustedType type, string generatedClassName) { ArrayList list = new ArrayList(); list.Add(new ConstructorGenerator(type, generatedClassName)); if (type.IsAbstract) { TrustedMethodInfo[] methodInfos = type.GetMethods(flags); if (methodInfos != null) { foreach (TrustedMethodInfo method in methodInfos) { // PropertyGenerators will be created in the next step. Don't add them here. if (!method.Name.Contains("get_") && !method.Name.Contains("set_") && MethodNeedsOverride(method, type)) { list.Add(new MethodGenerator(method)); } } } TrustedPropertyInfo[] properties = type.GetProperties(flags); if (properties != null) { foreach (TrustedPropertyInfo property in properties) { TrustedMethodInfo get = property.GetGetMethod(); TrustedMethodInfo set = property.GetSetMethod(); if (MethodNeedsOverride(get, type) || MethodNeedsOverride(set, type)) { list.Add(new PropertyGenerator(property)); } } } } methods = new MethodGeneratorBase[list.Count]; list.CopyTo(methods); }
/// <summary> /// Walk up the inheritance tree until we find an override /// or the class where the abstract method was defined /// </summary> private bool IsOverridden(TrustedMethodBase method, TrustedType type) { if (method.DeclaringType == type) { return(false); } TrustedMethodInfo[] methods = type.GetMethods(flags); if (methods != null) { foreach (TrustedMethodInfo info in methods) { if (MethodSignaturesMatch(info, method)) { MethodBody body = info.GetMethodBody(); if (body != null) { return(true); } } } } return(IsOverridden(method, type.BaseType)); }