protected virtual void AddReturnValueChildren(NodeInfoCollection c, NodeInfo root) { if (root.ReflectionObject != null) { AddTypeChildren(c, root, (Type)root.ReflectionObject); } }
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 AddSubnodes(NodeInfoCollection c, NodeInfo parent, Type type, object instance) { foreach (MemberInfo mi in GetMembers(type)) { AddNode(c, parent, mi, instance); } }
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 override void AddReturnValueChildren(NodeInfoCollection c, NodeInfo parent) { if (parent.ReflectionObject != null) { AddTypeChildren(c, parent, (Type)parent.ReflectionObject); } }
protected override void AddMethodChildren(NodeInfoCollection c, NodeInfo parent, MethodInfo node) { AddMethodBaseChildren(parent, node, c); AddMembers(parent, node, "ReturnType", c); AddMembers(parent, node, "ReturnTypeCustomAttributes", c); GetReturnValue(c, parent, node); }
public NodeInfoCollection GetChildren(NodeInfo root) { Trace.WriteLineIf(info.Enabled, "GroupingNodeFinder.GetChildren"); NodeInfoCollection collection = null; switch (root.NodeType) { case NodeTypes.Type: GroupChildNodes(root); collection = new NodeInfoCollection(); collection.AddRange((NodeInfoCollection)nodes[""]); AddGroup(nestedClasses, collection, root); AddGroup(baseNode, collection, root); AddGroup(interfacesNode, collection, root); AddGroup(constructorsNode, collection, root); AddGroup(methodsNode, collection, root); AddGroup(fieldsNode, collection, root); AddGroup(propertiesNode, collection, root); AddGroup(eventsNode, collection, root); return(collection); case NodeTypes.Other: if (root.Description is GroupingInfo) { Trace.WriteLineIf(info.Enabled, "Found GroupingInfo"); GroupingInfo g = (GroupingInfo)root.Description; collection = (NodeInfoCollection)nodes[g.Group]; return(collection); } break; } return(finder.GetChildren(root)); }
protected override void AddEventChildren(NodeInfoCollection c, NodeInfo parent, EventInfo node) { AddMemberChildren(parent, node, c); AddMembers(parent, node, "Attributes", c); AddMembers(parent, node, "EventHandlerType", c); AddMembers(parent, node, "IsMulticast", c); AddMembers(parent, node, "IsSpecialName", c); }
protected override void AddTypeChildren (NodeInfoCollection c, NodeInfo parent, Type type) { object instance = parent.ReflectionInstance; foreach (MemberInfo mi in GetMembers (type)) { AddNode (c, parent, mi, instance); } }
protected virtual void AddOtherChildren(NodeInfoCollection c, NodeInfo root) { if (root.Description is NodeGroup) { NodeGroup g = (NodeGroup)root.Description; g.Invoke(c, root); } }
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 AddTypeChildren(NodeInfoCollection c, NodeInfo parent, Type type) { object instance = parent.ReflectionInstance; foreach (MemberInfo mi in GetMembers(type)) { AddNode(c, parent, mi, 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 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 AddGroup(string name, NodeInfoCollection collection, NodeInfo root) { NodeInfoCollection nic = (NodeInfoCollection)nodes[name]; if (nic.Count > 0) { collection.Add(CreateGroupingNode(name, root)); } }
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); } }
protected override void AddPropertyChildren(NodeInfoCollection c, NodeInfo parent, PropertyInfo node) { AddMemberChildren(parent, node, c); AddMembers(parent, node, "Attributes", c); AddMembers(parent, node, "CanRead", c); AddMembers(parent, node, "CanWrite", c); AddMembers(parent, node, "IsSpecialName", c); AddMembers(parent, node, "PropertyType", c); GetReturnValue(c, parent, node.GetGetMethod()); }
private void GetAssemblyChildren(NodeInfoCollection c, NodeInfo parent, object args) { Assembly a = (Assembly)args; AddMembers(parent, a, "CodeBase", c); AddMembers(parent, a, "EntryPoint", c); AddMembers(parent, a, "EscapedCodeBase", c); AddMembers(parent, a, "Evidence", c); AddMembers(parent, a, "FullName", c); AddMembers(parent, a, "GlobalAssemblyCache", c); AddMembers(parent, a, "Location", c); }
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)); }
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)); } } }
protected override void AddParameterChildren(NodeInfoCollection c, NodeInfo parent, ParameterInfo pi) { // TODO: handle custom attributes... // c.Add (new NodeInfo (parent, pi, customAttributes, NodeTypes.Other)); // c.Add (new NodeInfo (parent, pi, pi, NodeTypes.CustomAttributeProvider)); AddMembers(parent, pi, "Attributes", c); AddMembers(parent, pi, "DefaultValue", c); AddMembers(parent, pi, "IsIn", c); AddMembers(parent, pi, "IsLcid", c); AddMembers(parent, pi, "IsOptional", c); AddMembers(parent, pi, "IsOut", c); AddMembers(parent, pi, "IsRetval", c); AddMembers(parent, pi, "Member", c); AddMembers(parent, pi, "Name", c); AddMembers(parent, pi, "ParameterType", c); AddMembers(parent, pi, "Position", c); }
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); } }
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)); }
public virtual NodeInfoCollection GetChildren (NodeInfo root) { Trace.WriteLineIf (info.Enabled, "NodeFinder.GetChildren"); NodeInfoCollection c = new NodeInfoCollection (); // always handle NodeTypes.Type if (root.NodeType == NodeTypes.Type) AddTypeChildren (c, root, (Type) root.ReflectionObject); else if (VerboseOutput) { switch (root.NodeType) { case NodeTypes.BaseType: AddBaseTypeChildren (c, root, (Type) root.ReflectionObject); break; case NodeTypes.Interface: AddInterfaceChildren (c, root, (Type) root.ReflectionObject); break; case NodeTypes.Field: AddFieldChildren (c, root, (FieldInfo) root.ReflectionObject); break; case NodeTypes.Constructor: AddConstructorChildren (c, root, (ConstructorInfo) root.ReflectionObject); break; case NodeTypes.Method: AddMethodChildren (c, root, (MethodInfo) root.ReflectionObject); break; case NodeTypes.Parameter: AddParameterChildren (c, root, (ParameterInfo) root.ReflectionObject); break; case NodeTypes.Property: AddPropertyChildren (c, root, (PropertyInfo) root.ReflectionObject); break; case NodeTypes.Event: AddEventChildren (c, root, (EventInfo) root.ReflectionObject); break; case NodeTypes.ReturnValue: AddReturnValueChildren (c, root); break; case NodeTypes.Other: case NodeTypes.Alias: AddOtherChildren (c, root); break; default: AddUnhandledChildren (c, root); break; } } return c; }
protected virtual void AddInterfaceChildren(NodeInfoCollection c, NodeInfo root, Type iface) { }
protected virtual void AddConstructorChildren(NodeInfoCollection c, NodeInfo root, ConstructorInfo ctor) { }
protected override void AddReturnValueChildren (NodeInfoCollection c, NodeInfo parent) { if (parent.ReflectionObject != null) AddTypeChildren (c, parent, (Type) parent.ReflectionObject); }
protected virtual void AddConstructorChildren (NodeInfoCollection c, NodeInfo root, ConstructorInfo ctor) { }
private void GetMethodBaseChildren (NodeInfoCollection c, NodeInfo parent, MethodBase mb) { AddSubnodes (c, parent, mb.GetType(), mb); }
protected override void AddPropertyChildren (NodeInfoCollection c, NodeInfo parent, PropertyInfo pi) { AddSubnodes (c, parent, pi.GetType(), pi); }
protected virtual void AddEventChildren (NodeInfoCollection c, NodeInfo root, EventInfo e) { }
protected virtual void AddPropertyChildren (NodeInfoCollection c, NodeInfo root, PropertyInfo property) { }
protected virtual void AddEventChildren(NodeInfoCollection c, NodeInfo root, EventInfo e) { }
protected override void AddMethodChildren (NodeInfoCollection c, NodeInfo parent, MethodInfo node) { AddMethodBaseChildren (parent, node, c); AddMembers (parent, node, "ReturnType", c); AddMembers (parent, node, "ReturnTypeCustomAttributes", c); GetReturnValue (c, parent, node); }
protected virtual void AddReturnValueChildren (NodeInfoCollection c, NodeInfo root) { if (root.ReflectionObject != null) AddTypeChildren (c, root, (Type) root.ReflectionObject); }
protected virtual void AddOtherChildren (NodeInfoCollection c, NodeInfo root) { if (root.Description is NodeGroup) { NodeGroup g = (NodeGroup) root.Description; g.Invoke (c, root); } }
protected virtual void AddUnhandledChildren (NodeInfoCollection c, NodeInfo root) { c.Add (new NodeInfo (root, "Unhandled child: NodeType=" + root.NodeType)); }
protected override void AddConstructorChildren (NodeInfoCollection c, NodeInfo parent, ConstructorInfo ctor) { GetMethodBaseChildren (c, parent, ctor); }
protected virtual void AddParameterChildren(NodeInfoCollection c, NodeInfo root, ParameterInfo param) { }
protected override void AddMethodChildren (NodeInfoCollection c, NodeInfo parent, MethodInfo method) { GetMethodBaseChildren (c, parent, method); }
protected virtual void AddFieldChildren (NodeInfoCollection c, NodeInfo root, FieldInfo field) { }
protected override void AddParameterChildren (NodeInfoCollection c, NodeInfo parent, ParameterInfo param) { AddSubnodes (c, parent, param.GetType(), param); }
protected override void AddPropertyChildren (NodeInfoCollection c, NodeInfo parent, PropertyInfo node) { AddMemberChildren (parent, node, c); AddMembers (parent, node, "Attributes", c); AddMembers (parent, node, "CanRead", c); AddMembers (parent, node, "CanWrite", c); AddMembers (parent, node, "IsSpecialName", c); AddMembers (parent, node, "PropertyType", c); GetReturnValue (c, parent, node.GetGetMethod()); }
protected override void AddEventChildren (NodeInfoCollection c, NodeInfo parent, EventInfo e) { AddSubnodes (c, parent, e.GetType(), e); }
protected virtual void AddParameterChildren (NodeInfoCollection c, NodeInfo root, ParameterInfo param) { }
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)); } } }
protected virtual void AddMethodChildren (NodeInfoCollection c, NodeInfo root, MethodInfo method) { }
protected virtual void AddBaseTypeChildren(NodeInfoCollection c, NodeInfo root, Type baseType) { }
private void AddSubnodes (NodeInfoCollection c, NodeInfo parent, Type type, object instance) { foreach (MemberInfo mi in GetMembers (type)) { AddNode (c, parent, mi, instance); } }
protected virtual void AddFieldChildren(NodeInfoCollection c, NodeInfo root, FieldInfo field) { }
protected override void AddFieldChildren (NodeInfoCollection c, NodeInfo parent, FieldInfo field) { AddSubnodes (c, parent, field.GetType(), field); }
protected virtual void AddMethodChildren(NodeInfoCollection c, NodeInfo root, MethodInfo method) { }
protected virtual void AddBaseTypeChildren (NodeInfoCollection c, NodeInfo root, Type baseType) { }
protected virtual void AddPropertyChildren(NodeInfoCollection c, NodeInfo root, PropertyInfo property) { }
protected virtual void AddInterfaceChildren (NodeInfoCollection c, NodeInfo root, Type iface) { }
protected override void AddConstructorChildren (NodeInfoCollection c, NodeInfo parent, ConstructorInfo node) { AddMethodBaseChildren (parent, node, c); }
protected override void AddEventChildren (NodeInfoCollection c, NodeInfo parent, EventInfo node) { AddMemberChildren (parent, node, c); AddMembers (parent, node, "Attributes", c); AddMembers (parent, node, "EventHandlerType", c); AddMembers (parent, node, "IsMulticast", c); AddMembers (parent, node, "IsSpecialName", c); }
protected virtual void AddUnhandledChildren(NodeInfoCollection c, NodeInfo root) { c.Add(new NodeInfo(root, "Unhandled child: NodeType=" + root.NodeType)); }
protected override void AddParameterChildren (NodeInfoCollection c, NodeInfo parent, ParameterInfo pi) { // TODO: handle custom attributes... // c.Add (new NodeInfo (parent, pi, customAttributes, NodeTypes.Other)); // c.Add (new NodeInfo (parent, pi, pi, NodeTypes.CustomAttributeProvider)); AddMembers (parent, pi, "Attributes", c); AddMembers (parent, pi, "DefaultValue", c); AddMembers (parent, pi, "IsIn", c); AddMembers (parent, pi, "IsLcid", c); AddMembers (parent, pi, "IsOptional", c); AddMembers (parent, pi, "IsOut", c); AddMembers (parent, pi, "IsRetval", c); AddMembers (parent, pi, "Member", c); AddMembers (parent, pi, "Name", c); AddMembers (parent, pi, "ParameterType", c); AddMembers (parent, pi, "Position", c); }