public static async Task <DriverNodeMock> CreateNodeMock(Guid guid, string name, IDispatcher dispatcher, INodeInstanceCache cache = null, IDriverNodesStore store = null) { var mockNode = new NodeInstance { ObjId = Guid.NewGuid(), Name = name + "Parent" }; var mockNodeChild = new NodeInstance { ObjId = guid, Name = name }; cache?.Add(mockNode.ObjId, mockNode); cache?.Add(mockNodeChild.ObjId, mockNodeChild); mockNode.InverseThis2ParentNodeInstanceNavigation.Add(mockNodeChild); var mock = new DriverNodeMock(new DriverContextMock(mockNode, new NodeTemplateFactoryMock(), dispatcher)); mock.Configure(); await mock.Start(); store?.Add(mock.Id, mock); store?.Add(mock.Children[0].Id, mock.Children[0]); return(mock); }
public Task LoadDriverFactory(NodeInstance nodeInstance, IDriverFactory factory, IDriverContext context) { var driver = factory.CreateDriver(context); nodeInstance.State = NodeInstanceState.Loaded; if (driver.BeforeInit()) { _driverStore.Add(driver.Id, driver); nodeInstance.State = NodeInstanceState.Initialized; driver.Configure(); } else { nodeInstance.State = NodeInstanceState.UnknownError; } _driverNodeStore.Add(driver.Id, driver); for (int i = 0; i <= driver.ChildrensCreated; ++i) { _licenseContract.IncrementDriverCount(); } AddDriverRecursive(driver); return(Task.CompletedTask); }
public void Add(IDriverNode node) { _store.Add(node.Id, node); }