public NodeContext(NodeCoroutine nodeCoroutine, NodeProvider provider, ExternalDataProvider externalDataProvider, GraphData data) { _nodeCoroutine = nodeCoroutine; _provider = provider; _externalDataProvider = externalDataProvider; _nodes = new Dictionary <Guid, Node>(); _sockets = new Dictionary <Guid, Socket>(); _connections = new Dictionary <Guid, Connection>(); _nodeFactory = new NodeFactory(_externalDataProvider); _history = new ActionsHistory(); _graphData = data ?? new GraphData { Connections = new ConnectionData[0], Nodes = new NodeData[0] }; ParseGraph(); }
private void PostCreate(ExternalDataProvider externalDataProvider, Guid guid) { _externalDataProvider = externalDataProvider; Guid = guid; var fields = GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.GetField | BindingFlags.SetField); var properties = GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.GetProperty | BindingFlags.SetProperty); foreach (var fieldInfo in fields) { var attributes = fieldInfo.GetCustomAttributes(typeof(SocketAttribute), true); if (attributes.Length != 0 && fieldInfo.FieldType.IsSubclassOf(typeof(Socket))) { var value = (Socket)fieldInfo.GetValue(this); if (value == null) { value = (Socket)Activator.CreateInstance(fieldInfo.FieldType, new object[] { fieldInfo.Name, this }); fieldInfo.SetValue(this, value); } switch (value.Type) { case SocketType.Input: _in.Add((SocketIn)value); break; case SocketType.Output: _out.Add((SocketOut)value); break; } _sockets.Add(fieldInfo.Name, value); MethodInvoker<Socket, PostCreateAttribute>.Invoke(value); } } foreach (var propertyInfo in properties) { var attributes = propertyInfo.GetCustomAttributes(typeof(SocketAttribute), true); if (attributes.Length != 0 && propertyInfo.PropertyType.IsSubclassOf(typeof(Socket))) { var value = (Socket)propertyInfo.GetValue(this, null); if (value == null) { value = (Socket)Activator.CreateInstance(propertyInfo.PropertyType, new object[] { propertyInfo.Name, this }); propertyInfo.SetValue(this, value, null); } switch (value.Type) { case SocketType.Input: _in.Add((SocketIn)value); break; case SocketType.Output: _out.Add((SocketOut)value); break; } _sockets.Add(propertyInfo.Name, value); MethodInvoker<Socket, PostCreateAttribute>.Invoke(value); } } }
public NodeFactory(ExternalDataProvider externalDataProvider) { _externalDataProvider = externalDataProvider; }