/// <summary> /// Store MetaDataObjects for each method part of this member /// </summary> private void BuildBodies() { switch (Member.MemberType) { case MemberTypes.Constructor: Bodies.Add(new MetadataObject(Member, null)); break; case MemberTypes.Event: EventInfo E = (EventInfo)Member; List <MethodInfo> methods = new MethodInfo[3] { E.GetAddMethod(), E.GetRemoveMethod(), E.GetRaiseMethod() }.ToList(); methods.AddRange(E.GetOtherMethods()); methods.FindAll(m => m.GetMethodBody() != null).ForEach(m => Bodies.Add(new MetadataObject(Member, m))); break; case MemberTypes.Method: Bodies.Add(new MetadataObject(Member, (MethodInfo)Member)); break; case MemberTypes.Property: PropertyInfo P = (PropertyInfo)Member; new MethodInfo[2] { P.GetGetMethod(), P.GetSetMethod() }.ToList().FindAll( m => m != null).ForEach(m => Bodies.Add(new MetadataObject(Member, m))); break; default: break; } }
/// <summary> /// Assign direct reference information to original types and members /// </summary> private void DetermineReferences() { // This method is created separately to provide recursive function of NestedTypes List <Type> types = DeclaringType.Architecture.BaseTypes; switch (Member.MemberType) { case MemberTypes.Constructor: // parameter types, local types, method ConstructorInfo C = (ConstructorInfo)Member; C.GetParameters().ToList().ForEach(param => { if (types.Contains(param.ParameterType)) { DirectRefTypes.Add(param.ParameterType); } }); C.GetMethodBody().LocalVariables.ToList().ForEach(local => { if (types.Contains(local.LocalType)) { DirectRefTypes.Add(local.LocalType); } }); InterpretBody(); break; case MemberTypes.Method: // return type, parameter types, local types, method MethodInfo Mthd = (MethodInfo)Member; if (types.Contains(Mthd.ReturnType)) { DirectRefTypes.Add(Mthd.ReturnType); } Mthd.GetParameters().ToList().ForEach(param => { if (types.Contains(param.ParameterType)) { DirectRefTypes.Add(param.ParameterType); } }); Mthd.GetMethodBody().LocalVariables.ToList().ForEach(local => { if (types.Contains(local.LocalType)) { DirectRefTypes.Add(local.LocalType); } }); InterpretBody(); break; case MemberTypes.Property: // type, get method, set method PropertyInfo P = (PropertyInfo)Member; if (types.Contains(P.PropertyType)) { DirectRefTypes.Add(P.PropertyType); } new MethodInfo[2] { P.GetGetMethod(), P.GetSetMethod() }.ToList().FindAll(M => M != null).ForEach(M => { M.GetMethodBody().LocalVariables.ToList().ForEach(local => { if (types.Contains(local.LocalType)) { DirectRefTypes.Add(local.LocalType); } }); }); InterpretBody(); break; case MemberTypes.Event: // add method, remove method, raise method, 'other' methods EventInfo E = (EventInfo)Member; List <MethodInfo> methods = new MethodInfo[3] { E.GetAddMethod(), E.GetRemoveMethod(), E.GetRaiseMethod() }.ToList(); methods.AddRange(E.GetOtherMethods()); methods.FindAll(M => M != null).ForEach(M => { M.GetMethodBody().LocalVariables.ToList().ForEach(local => { if (types.Contains(local.LocalType)) { DirectRefTypes.Add(local.LocalType); } }); }); InterpretBody(); break; case MemberTypes.Field: // type FieldInfo F = ((FieldInfo)Member); if (types.Contains(F.FieldType)) { DirectRefTypes.Add(F.FieldType); } break; default: // Nested, TypeInfo, Custom, All break; } }