protected override void AddFieldChildren(NodeInfoCollection c, NodeInfo parent, FieldInfo field) { Trace.WriteLineIf(info.Enabled, "Getting Field Children"); AddMemberChildren(parent, field, c); AddMembers(parent, field, "Attributes", c); AddMembers(parent, field, "FieldHandle", c); AddMembers(parent, field, "FieldType", c); AddMembers(parent, field, "IsAssembly", c); AddMembers(parent, field, "IsFamily", c); AddMembers(parent, field, "IsFamilyAndAssembly", c); AddMembers(parent, field, "IsFamilyOrAssembly", c); AddMembers(parent, field, "IsInitOnly", c); AddMembers(parent, field, "IsLiteral", c); AddMembers(parent, field, "IsNotSerialized", c); AddMembers(parent, field, "IsPinvokeImpl", c); AddMembers(parent, field, "IsPublic", c); AddMembers(parent, field, "IsSpecialName", c); AddMembers(parent, field, "IsStatic", c); try { object o = field.GetValue(parent.ReflectionInstance); c.Add(new NodeInfo(parent, NodeTypes.ReturnValue, o.GetType(), o, o)); } catch (Exception e) { string r = string.Format("{{can't get field value; through exception: {0}}}", e.Message); c.Add(new NodeInfo(parent, NodeTypes.ReturnValue, null, null, r)); } }
private void AddNode(NodeInfoCollection c, NodeInfo parent, MemberInfo mi, object instance) { // FIXME: there has to be a cleaner way than this... // Don't add node if we don't want to display them. bool quit = false; switch (mi.MemberType) { case MemberTypes.Constructor: quit = !ShowConstructors; break; case MemberTypes.Event: quit = !ShowEvents; break; case MemberTypes.Field: quit = !ShowFields; break; case MemberTypes.Method: quit = !ShowMethods; break; case MemberTypes.Property: quit = !ShowProperties; break; case MemberTypes.TypeInfo: // either a Base type or an Interface // this is bound to produce buggy behavior... quit = !ShowBase && !ShowInterfaces; break; // case MemberTypes.NestedType // we don't break out nested types yet } if (quit) { return; } if (!seenReflectionObjects.Found(mi)) { seenReflectionObjects.Add(mi); NodeInfo n = new NodeInfo(parent, mi, instance); c.Add(n); } else { NodeInfo n = new NodeInfo(parent, "Seen: " + mi.ToString()); n.NodeType = NodeTypes.Alias; c.Add(n); } }
private void GetReturnValue(NodeInfoCollection c, NodeInfo parent, MethodInfo method) { if (method != null && method.GetParameters().Length == 0) { try { object o = method.Invoke(parent.ReflectionInstance, null); c.Add(new NodeInfo(parent, NodeTypes.ReturnValue, o.GetType(), o, o)); } catch (Exception e) { string r = string.Format("{{method has 0 args; through exception: {0}}}", e.Message); c.Add(new NodeInfo(parent, NodeTypes.ReturnValue, null, null, r)); } } }
private void AddMethodBaseChildren(NodeInfo parent, MethodBase mb, NodeInfoCollection c) { AddMemberChildren(parent, mb, c); AddMembers(parent, mb, "Attributes", c); AddMembers(parent, mb, "CallingConvention", c); AddMembers(parent, mb, "IsAbstract", c); AddMembers(parent, mb, "IsAssembly", c); AddMembers(parent, mb, "IsConstructor", c); AddMembers(parent, mb, "IsFamily", c); AddMembers(parent, mb, "IsFamilyAndAssembly", c); AddMembers(parent, mb, "IsFamilyOrAssembly", c); AddMembers(parent, mb, "IsFinal", c); AddMembers(parent, mb, "IsHideBySig", c); AddMembers(parent, mb, "IsPrivate", c); AddMembers(parent, mb, "IsPublic", c); AddMembers(parent, mb, "IsSpecialName", c); AddMembers(parent, mb, "IsStatic", c); AddMembers(parent, mb, "IsVirtual", c); AddMembers(parent, mb, "MethodHandle", c); AddMembers(parent, mb, "GetMethodImplementationFlags", c); c.Add(new NodeInfo(parent, new NodeGroup(parameters, mb, new NodeGrouper(GetParametersChildren)))); // c.Add (new NodeInfo (parent, mb, parameters, NodeTypes.Other)); }
private void GetTypeInformationChildren(NodeInfoCollection c, NodeInfo parent, object args) { Type type = (Type)args; AddMemberChildren(parent, type, c); AddMembers(parent, type, "Delimiter", c); AddMembers(parent, type, "EmptyTypes", c); AddMembers(parent, type, "FilterAttribute", c); AddMembers(parent, type, "FilterName", c); AddMembers(parent, type, "FilterNameIgnoreCase", c); AddMembers(parent, type, "Missing", c); AddMembers(parent, type, "Assembly", c); c.Add(new NodeInfo(parent, new NodeGroup("Assembly Attributes", type.Assembly, new NodeGrouper(GetAssemblyChildren)))); AddMembers(parent, type, "AssemblyQualifiedName", c); AddMembers(parent, type, "Attributes", c); AddMembers(parent, type, "BaseType", c); AddMembers(parent, type, "DeclaringType", c); AddMembers(parent, type, "DefaultBinder", c); AddMembers(parent, type, "FullName", c); AddMembers(parent, type, "GUID", c); AddMembers(parent, type, "HasElementType", c); AddMembers(parent, type, "IsAbstract", c); AddMembers(parent, type, "IsAnsiClass", c); AddMembers(parent, type, "IsArray", c); AddMembers(parent, type, "IsAutoClass", c); AddMembers(parent, type, "IsAutoLayout", c); AddMembers(parent, type, "IsByRef", c); AddMembers(parent, type, "IsClass", c); AddMembers(parent, type, "IsCOMObject", c); AddMembers(parent, type, "IsContextful", c); AddMembers(parent, type, "IsEnum", c); AddMembers(parent, type, "IsExplicitLayout", c); AddMembers(parent, type, "IsImport", c); AddMembers(parent, type, "IsInterface", c); AddMembers(parent, type, "IsLayoutSequential", c); AddMembers(parent, type, "IsMarshalByRef", c); AddMembers(parent, type, "IsNestedAssembly", c); AddMembers(parent, type, "IsNestedFamORAssem", c); AddMembers(parent, type, "IsNestedPrivate", c); AddMembers(parent, type, "IsNotPublic", c); AddMembers(parent, type, "IsPointer", c); AddMembers(parent, type, "IsPrimitive", c); AddMembers(parent, type, "IsPublic", c); AddMembers(parent, type, "IsSealed", c); AddMembers(parent, type, "IsSerializable", c); AddMembers(parent, type, "IsSpecialName", c); AddMembers(parent, type, "IsUnicodeClass", c); AddMembers(parent, type, "IsValueType", c); AddMembers(parent, type, "Module", c); AddMembers(parent, type, "Namespace", c); AddMembers(parent, type, "TypeHandle", c); AddMembers(parent, type, "TypeInitializer", c); AddMembers(parent, type, "UnderlyingSystemType", c); }
private void AddGroup(string name, NodeInfoCollection collection, NodeInfo root) { NodeInfoCollection nic = (NodeInfoCollection)nodes[name]; if (nic.Count > 0) { collection.Add(CreateGroupingNode(name, root)); } }
private void GetCustomAttributeProviderChildren(NodeInfoCollection c, NodeInfo root, object args) { object[] attrs = (object[])args; foreach (object attr in attrs) { // TODO: specify type? c.Add(new NodeInfo(root, attr)); } }
private void GetParametersChildren(NodeInfoCollection c, NodeInfo parent, object args) { MethodBase mb = (MethodBase)args; foreach (ParameterInfo pi in mb.GetParameters()) { c.Add(new NodeInfo(parent, NodeTypes.Parameter, pi, pi)); } }
private void AddMembers(NodeInfo parent, object instance, string member, NodeInfoCollection c) { Type type = instance.GetType(); foreach (MemberInfo mi in type.GetMember(member, BindingFlags)) { c.Add(new NodeInfo(parent, mi, instance)); } }
private void AddMemberChildren(NodeInfo parent, MemberInfo mi, NodeInfoCollection c) { AddMembers(parent, mi, "DeclaringType", c); AddMembers(parent, mi, "MemberType", c); AddMembers(parent, mi, "Name", c); AddMembers(parent, mi, "ReflectedType", c); // AddMembers (parent, mi, "GetCustomAttributes", c); c.Add(new NodeInfo(parent, new NodeGroup(customAttributes, mi.GetCustomAttributes(true), new NodeGrouper(GetCustomAttributeProviderChildren)))); // c.Add (new NodeInfo (parent, mi, customAttributes, NodeTypes.Other)); // c.Add (new NodeInfo (parent, mi, mi, NodeTypes.CustomAttributeProvider)); }
protected virtual void AddUnhandledChildren (NodeInfoCollection c, NodeInfo root) { c.Add (new NodeInfo (root, "Unhandled child: NodeType=" + root.NodeType)); }
private void AddMembers (NodeInfo parent, object instance, string member, NodeInfoCollection c) { Type type = instance.GetType (); foreach (MemberInfo mi in type.GetMember (member, BindingFlags)) { c.Add (new NodeInfo (parent, mi, instance)); } }
private void AddMemberChildren (NodeInfo parent, MemberInfo mi, NodeInfoCollection c) { AddMembers (parent, mi, "DeclaringType", c); AddMembers (parent, mi, "MemberType", c); AddMembers (parent, mi, "Name", c); AddMembers (parent, mi, "ReflectedType", c); // AddMembers (parent, mi, "GetCustomAttributes", c); c.Add (new NodeInfo (parent, new NodeGroup (customAttributes, mi.GetCustomAttributes (true), new NodeGrouper (GetCustomAttributeProviderChildren)))); // c.Add (new NodeInfo (parent, mi, customAttributes, NodeTypes.Other)); // c.Add (new NodeInfo (parent, mi, mi, NodeTypes.CustomAttributeProvider)); }
protected override void AddTypeChildren(NodeInfoCollection c, NodeInfo parent, Type type) { object instance = parent.ReflectionInstance; // System.Type information if (ShowTypeProperties) { c.Add(new NodeInfo(parent, new NodeGroup(typeInformation, type, new NodeGrouper(GetTypeInformationChildren)))); } // Base Type if (ShowBase) { c.Add(new NodeInfo(parent, NodeTypes.BaseType, type.BaseType, type.BaseType)); } // Implemented Interfaces if (ShowInterfaces) { foreach (Type t in type.GetInterfaces()) { c.Add(new NodeInfo(parent, NodeTypes.Interface, t, instance)); } } // Constructors if (ShowConstructors) { foreach (ConstructorInfo ci in type.GetConstructors(BindingFlags)) { c.Add(new NodeInfo(parent, ci, instance)); } } // Methods if (ShowMethods) { foreach (MethodInfo mi in type.GetMethods(BindingFlags)) { c.Add(new NodeInfo(parent, mi, instance)); } } // Fields if (ShowFields) { foreach (FieldInfo fi in type.GetFields(BindingFlags)) { c.Add(new NodeInfo(parent, fi, instance)); } } // Properties if (ShowProperties) { foreach (PropertyInfo pi in type.GetProperties(BindingFlags)) { c.Add(new NodeInfo(parent, pi, instance)); } } // Events if (ShowEvents) { foreach (EventInfo ei in type.GetEvents(BindingFlags)) { c.Add(new NodeInfo(parent, ei, instance)); } } }
private void GetCustomAttributeProviderChildren (NodeInfoCollection c, NodeInfo root, object args) { object[] attrs = (object[]) args; foreach (object attr in attrs) { // TODO: specify type? c.Add (new NodeInfo (root, attr)); } }
private void AddNode (NodeInfoCollection c, NodeInfo parent, MemberInfo mi, object instance) { // FIXME: there has to be a cleaner way than this... // Don't add node if we don't want to display them. bool quit = false; switch (mi.MemberType) { case MemberTypes.Constructor: quit = !ShowConstructors; break; case MemberTypes.Event: quit = !ShowEvents; break; case MemberTypes.Field: quit = !ShowFields; break; case MemberTypes.Method: quit = !ShowMethods; break; case MemberTypes.Property: quit = !ShowProperties; break; case MemberTypes.TypeInfo: // either a Base type or an Interface // this is bound to produce buggy behavior... quit = !ShowBase && !ShowInterfaces; break; // case MemberTypes.NestedType // we don't break out nested types yet } if (quit) return; if (!seenReflectionObjects.Found (mi)) { seenReflectionObjects.Add (mi); NodeInfo n = new NodeInfo (parent, mi, instance); c.Add (n); } else { NodeInfo n = new NodeInfo (parent, "Seen: " + mi.ToString()); n.NodeType = NodeTypes.Alias; c.Add (n); } }
private void GetTypeInformationChildren (NodeInfoCollection c, NodeInfo parent, object args) { Type type = (Type) args; AddMemberChildren (parent, type, c); AddMembers (parent, type, "Delimiter", c); AddMembers (parent, type, "EmptyTypes", c); AddMembers (parent, type, "FilterAttribute", c); AddMembers (parent, type, "FilterName", c); AddMembers (parent, type, "FilterNameIgnoreCase", c); AddMembers (parent, type, "Missing", c); AddMembers (parent, type, "Assembly", c); c.Add (new NodeInfo (parent, new NodeGroup ("Assembly Attributes", type.Assembly, new NodeGrouper (GetAssemblyChildren)))); AddMembers (parent, type, "AssemblyQualifiedName", c); AddMembers (parent, type, "Attributes", c); AddMembers (parent, type, "BaseType", c); AddMembers (parent, type, "DeclaringType", c); AddMembers (parent, type, "DefaultBinder", c); AddMembers (parent, type, "FullName", c); AddMembers (parent, type, "GUID", c); AddMembers (parent, type, "HasElementType", c); AddMembers (parent, type, "IsAbstract", c); AddMembers (parent, type, "IsAnsiClass", c); AddMembers (parent, type, "IsArray", c); AddMembers (parent, type, "IsAutoClass", c); AddMembers (parent, type, "IsAutoLayout", c); AddMembers (parent, type, "IsByRef", c); AddMembers (parent, type, "IsClass", c); AddMembers (parent, type, "IsCOMObject", c); AddMembers (parent, type, "IsContextful", c); AddMembers (parent, type, "IsEnum", c); AddMembers (parent, type, "IsExplicitLayout", c); AddMembers (parent, type, "IsImport", c); AddMembers (parent, type, "IsInterface", c); AddMembers (parent, type, "IsLayoutSequential", c); AddMembers (parent, type, "IsMarshalByRef", c); AddMembers (parent, type, "IsNestedAssembly", c); AddMembers (parent, type, "IsNestedFamORAssem", c); AddMembers (parent, type, "IsNestedPrivate", c); AddMembers (parent, type, "IsNotPublic", c); AddMembers (parent, type, "IsPointer", c); AddMembers (parent, type, "IsPrimitive", c); AddMembers (parent, type, "IsPublic", c); AddMembers (parent, type, "IsSealed", c); AddMembers (parent, type, "IsSerializable", c); AddMembers (parent, type, "IsSpecialName", c); AddMembers (parent, type, "IsUnicodeClass", c); AddMembers (parent, type, "IsValueType", c); AddMembers (parent, type, "Module", c); AddMembers (parent, type, "Namespace", c); AddMembers (parent, type, "TypeHandle", c); AddMembers (parent, type, "TypeInitializer", c); AddMembers (parent, type, "UnderlyingSystemType", c); }
protected override void AddFieldChildren (NodeInfoCollection c, NodeInfo parent, FieldInfo field) { Trace.WriteLineIf (info.Enabled, "Getting Field Children"); AddMemberChildren (parent, field, c); AddMembers (parent, field, "Attributes", c); AddMembers (parent, field, "FieldHandle", c); AddMembers (parent, field, "FieldType", c); AddMembers (parent, field, "IsAssembly", c); AddMembers (parent, field, "IsFamily", c); AddMembers (parent, field, "IsFamilyAndAssembly", c); AddMembers (parent, field, "IsFamilyOrAssembly", c); AddMembers (parent, field, "IsInitOnly", c); AddMembers (parent, field, "IsLiteral", c); AddMembers (parent, field, "IsNotSerialized", c); AddMembers (parent, field, "IsPinvokeImpl", c); AddMembers (parent, field, "IsPublic", c); AddMembers (parent, field, "IsSpecialName", c); AddMembers (parent, field, "IsStatic", c); try { object o = field.GetValue (parent.ReflectionInstance); c.Add (new NodeInfo (parent, NodeTypes.ReturnValue, o.GetType(), o, o)); } catch (Exception e) { string r = string.Format ("{{can't get field value; through exception: {0}}}", e.Message); c.Add (new NodeInfo (parent, NodeTypes.ReturnValue, null, null, r)); } }
protected override void AddTypeChildren (NodeInfoCollection c, NodeInfo parent, Type type) { object instance = parent.ReflectionInstance; // System.Type information if (ShowTypeProperties) c.Add (new NodeInfo (parent, new NodeGroup (typeInformation, type, new NodeGrouper (GetTypeInformationChildren)))); // Base Type if (ShowBase) c.Add (new NodeInfo (parent, NodeTypes.BaseType, type.BaseType, type.BaseType)); // Implemented Interfaces if (ShowInterfaces) foreach (Type t in type.GetInterfaces()) c.Add (new NodeInfo (parent, NodeTypes.Interface, t, instance)); // Constructors if (ShowConstructors) foreach (ConstructorInfo ci in type.GetConstructors (BindingFlags)) c.Add (new NodeInfo (parent, ci, instance)); // Methods if (ShowMethods) foreach (MethodInfo mi in type.GetMethods (BindingFlags)) c.Add (new NodeInfo (parent, mi, instance)); // Fields if (ShowFields) foreach (FieldInfo fi in type.GetFields (BindingFlags)) c.Add (new NodeInfo (parent, fi, instance)); // Properties if (ShowProperties) foreach (PropertyInfo pi in type.GetProperties (BindingFlags)) c.Add (new NodeInfo (parent, pi, instance)); // Events if (ShowEvents) foreach (EventInfo ei in type.GetEvents (BindingFlags)) c.Add (new NodeInfo (parent, ei, instance)); }
private void GetReturnValue (NodeInfoCollection c, NodeInfo parent, MethodInfo method) { if (method != null && method.GetParameters().Length == 0) { try { object o = method.Invoke (parent.ReflectionInstance, null); c.Add (new NodeInfo (parent, NodeTypes.ReturnValue, o.GetType(), o, o)); } catch (Exception e) { string r = string.Format ("{{method has 0 args; through exception: {0}}}", e.Message); c.Add (new NodeInfo (parent, NodeTypes.ReturnValue, null, null, r)); } } }
private void GetParametersChildren (NodeInfoCollection c, NodeInfo parent, object args) { MethodBase mb = (MethodBase) args; foreach (ParameterInfo pi in mb.GetParameters()) { c.Add (new NodeInfo (parent, NodeTypes.Parameter, pi, pi)); } }
private void AddMethodBaseChildren (NodeInfo parent, MethodBase mb, NodeInfoCollection c) { AddMemberChildren (parent, mb, c); AddMembers (parent, mb, "Attributes", c); AddMembers (parent, mb, "CallingConvention", c); AddMembers (parent, mb, "IsAbstract", c); AddMembers (parent, mb, "IsAssembly", c); AddMembers (parent, mb, "IsConstructor", c); AddMembers (parent, mb, "IsFamily", c); AddMembers (parent, mb, "IsFamilyAndAssembly", c); AddMembers (parent, mb, "IsFamilyOrAssembly", c); AddMembers (parent, mb, "IsFinal", c); AddMembers (parent, mb, "IsHideBySig", c); AddMembers (parent, mb, "IsPrivate", c); AddMembers (parent, mb, "IsPublic", c); AddMembers (parent, mb, "IsSpecialName", c); AddMembers (parent, mb, "IsStatic", c); AddMembers (parent, mb, "IsVirtual", c); AddMembers (parent, mb, "MethodHandle", c); AddMembers (parent, mb, "GetMethodImplementationFlags", c); c.Add (new NodeInfo (parent, new NodeGroup (parameters, mb, new NodeGrouper (GetParametersChildren)))); // c.Add (new NodeInfo (parent, mb, parameters, NodeTypes.Other)); }
protected virtual void AddUnhandledChildren(NodeInfoCollection c, NodeInfo root) { c.Add(new NodeInfo(root, "Unhandled child: NodeType=" + root.NodeType)); }
private void AddGroup (string name, NodeInfoCollection collection, NodeInfo root) { NodeInfoCollection nic = (NodeInfoCollection) nodes[name]; if (nic.Count > 0) collection.Add (CreateGroupingNode (name, root)); }