public static List <NodeHandleAttribute> GetHandles(System.Type node) { if (nodeRawHandleCache.ContainsKey(node)) { return(GetCachedHandles(node)); } List <NodeHandleAttribute> fields = new List <NodeHandleAttribute>(); FieldInfo[] connectionFields = node.GetFields(BindingFlags.Instance | BindingFlags.Public); for (int i = 0; i < connectionFields.Length; i++) { NodeHandleAttribute attribute = Attribute.GetCustomAttribute(connectionFields[i], typeof(NodeHandleAttribute)) as NodeHandleAttribute; if (connectionFields[i].FieldType == typeof(NodeConnection)) { if (attribute != null) { fields.Add(attribute); } } } nodeRawHandleCache.Add(node, fields.ToArray()); return(fields); }
/// <summary> /// Collects all NodeHandles in the given node /// </summary> /// <param name="node">The Node which should expose it's handles</param> /// <param name="type">The Type of handle searched</param> /// <returns>A List of all collected NodeHandlePackes</returns> public static List <NodeHandlePackage> GetConnections(Node node, ConnectionType type) { List <NodeHandlePackage> fields = new List <NodeHandlePackage>(); FieldInfo[] connectionFields = node.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public); for (int i = 0; i < connectionFields.Length; i++) { NodeHandleAttribute attribute = Attribute.GetCustomAttribute(connectionFields[i], typeof(NodeHandleAttribute)) as NodeHandleAttribute; if (attribute != null && attribute.handleType == type) { if (connectionFields[i].FieldType == typeof(NodeConnection)) { fields.Add(new NodeHandlePackage(attribute, connectionFields[i])); } } } return(fields); }
/// <summary> /// Collects all NodeHandles in the given node /// </summary> /// <param name="node">The Node which should expose it's handles</param> /// <param name="type">The Type of handle searched</param> /// <returns>A List of all collected NodeHandlePackes</returns> public static List <NodeHandlePackage> GetConnections(Node node, ConnectionType type) { if (nodeHandleCache.ContainsKey(node.GetType())) { return(GetCachedConnections(node, type)); } List <NodeHandlePackage> fields = new List <NodeHandlePackage>(); List <NodeHandlePackage> cachableFields = new List <NodeHandlePackage>(); FieldInfo[] connectionFields = node.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public); for (int i = 0; i < connectionFields.Length; i++) { NodeHandleAttribute attribute = Attribute.GetCustomAttribute(connectionFields[i], typeof(NodeHandleAttribute)) as NodeHandleAttribute; if (connectionFields[i].FieldType == typeof(NodeConnection)) { if (attribute != null) { NodeHandlePackage package = new NodeHandlePackage(attribute, connectionFields[i]); if (attribute.handleType == type) { fields.Add(package); } cachableFields.Add(package); } } } nodeHandleCache.Add(node.GetType(), cachableFields.ToArray()); return(fields); }
/// <summary> /// Creates a NodeHandlePackage to transfer a FieldInfo with the according NodeHandleAttribute /// </summary> /// <param name="handle">A NodeHandle to be transfered together with the FieldInfo</param> /// <param name="info">A FieldInfo to be transfered together with the NodeHandle</param> public NodeHandlePackage(NodeHandleAttribute handle, FieldInfo info) { this.handle = handle; this.info = info; }