private IList <TypeRepTemplate> mkTemplates(string typeName) { List <TypeRepTemplate> rets = new List <TypeRepTemplate>(); Type t = assembly.GetType(typeName); if (t == null) { throw new Exception(String.Format("Type {0} not found", typeName)); } foreach (Type nestedTy in t.GetNestedTypes()) { foreach (TypeRepTemplate nestedRep in mkTemplates(nestedTy.FullName)) { rets.Add(nestedRep); } } TypeRepTemplate retRep = null; if (t.IsClass) { if (t.IsSubclassOf(typeof(System.Delegate))) { DelegateRepTemplate delRep = new DelegateRepTemplate(); buildDelegate(delRep, t); retRep = delRep; } else { ClassRepTemplate classRep = new ClassRepTemplate(); buildClass(classRep, t); retRep = classRep; } } else if (t.IsInterface) { InterfaceRepTemplate intRep = new InterfaceRepTemplate(); buildInterface(intRep, t); retRep = intRep; } else if (t.IsEnum) { EnumRepTemplate enumRep = new EnumRepTemplate(); enumRep.TypeName = TypeHelper.buildTypeName(t); foreach (FieldInfo f in t.GetFields(BindingFlags.Public | BindingFlags.Static)) { enumRep.Members.Add(new EnumMemberRepTemplate(f.Name, f.GetRawConstantValue().ToString())); } retRep = enumRep; } rets.Add(retRep); return(rets); }
private IList<TypeRepTemplate> mkTemplates(string typeName) { List<TypeRepTemplate> rets = new List<TypeRepTemplate>(); Type t = assembly.GetType(typeName); if (t == null) throw new Exception(String.Format("Type {0} not found", typeName)); foreach (Type nestedTy in t.GetNestedTypes()) { foreach (TypeRepTemplate nestedRep in mkTemplates(nestedTy.FullName)) { rets.Add(nestedRep); } } TypeRepTemplate retRep = null; if (t.IsClass) { if (t.IsSubclassOf(typeof(System.Delegate))) { DelegateRepTemplate delRep = new DelegateRepTemplate(); buildDelegate(delRep, t); retRep = delRep; } else { ClassRepTemplate classRep = new ClassRepTemplate(); buildClass(classRep, t); retRep = classRep; } } else if (t.IsInterface) { InterfaceRepTemplate intRep = new InterfaceRepTemplate(); buildInterface(intRep, t); retRep = intRep; } else if (t.IsEnum) { EnumRepTemplate enumRep = new EnumRepTemplate(); enumRep.TypeName = TypeHelper.buildTypeName(t); foreach (FieldInfo f in t.GetFields(BindingFlags.Public | BindingFlags.Static)) { enumRep.Members.Add(new EnumMemberRepTemplate(f.Name, f.GetRawConstantValue().ToString())); } retRep = enumRep; } rets.Add(retRep); return rets; }