public Node AddNode(NodeConfigurationModel configurationModel) { try { var node = _nodeFactory.Create(configurationModel.TypeFullName, configurationModel.JsonConfiguration); node.Name = configurationModel.Name; node.ParentGuid = configurationModel.ParentGuid; if (_nodes.ContainsKey(configurationModel.DeviceGuid)) { var l = _nodes[configurationModel.DeviceGuid]; l.Add(node); return(node); } else { _nodes.Add(configurationModel.DeviceGuid, new List <Node>() { node }); return(node); } } catch (Exception ex) { _logger.LogError(ex.Message); return(null); } }
private void CrawlInternal(Uri domainUri, Node node) { // Gets the response and saves the visisted Uri. var response = _http.Get(node.Uri); SaveVisited(node.Uri); SaveVisited(response.RequestUri); if (!response.IsSuccess) { return; } // Gets the nodes out of the reponse HTML. var html = response.Content; node.Nodes = _nodeFactory.Create(domainUri, html); // Iterates through the children nodes recursively // only if the node is internal and it has not been visited yet. foreach (var child in node.Nodes) { if (child.IsInternal && !IsVisited(child)) { CrawlInternal(domainUri, child); } } }
/// <summary> /// Gets this node's adjacent nodes. /// </summary> /// <param name="nodeFactory">A reference to the factory to create new nodes.</param> /// <returns>The collection of adjacent nodes.</returns> public IEnumerable <INode> FindAdjacent(INodeFactory nodeFactory) { var adjacent = new List <INode>(); var currentLoc = this.Tile.Location; var offsets = new List <Location>(); // look at adjacent tiles. for (var dx = -1; dx <= 1; dx++) { for (var dy = -1; dy <= 1; dy++) { // skip the current tile. if (dx == 0 && dy == 0) { continue; } offsets.Insert((int)(DateTime.Now.Ticks % (offsets.Count + 1)), new Location { X = dx, Y = dy, Z = 0 }); } } foreach (var locOffset in offsets) { if (nodeFactory.Create(this.SearchContext, new TileNodeCreationArguments(currentLoc + locOffset)) is TileNode tileNode && !tileNode.Tile.IsPathBlocking()) { adjacent.Add(tileNode); } } return(adjacent); }
public static void AddNode <TNode, TPosition, TKey>( this Shape <TNode, TPosition, TKey> shape, INodeFactory <TNode, TPosition, TKey> factory, TPosition point) where TNode : INode <TPosition, TKey> { shape.AddNode(factory.Create(shape.Area, point)); }
/// <summary> /// Load all <see cref="AdapterModel"/> from database and add them to <see cref="Adapters"/> /// </summary> private void LoadAdapters() { var adapterModels = _adapterRepo.GetAdapters(); var adapters = new List <Adapter>(); foreach (var adapterModel in adapterModels) { try { var adapter = _adapterFactory.Create(adapterModel); if (adapterModel.Nodes != null) { foreach (var nodeModel in adapterModel.Nodes) { adapter.AddNode(_nodeFactory.Create(nodeModel)); } } adapters.Add(adapter); } catch (Exception ex) { _logger.LogError(ex.Message); } Adapters = adapters; } }
public TNode AddNodeToShape(Shape <TNode, TPosition, TKey> shape, INodeFactory <TNode, TPosition, TKey> nodeFactory, TPosition position) { var node = nodeFactory.Create(shape.Area, position); shape.AddNode(node); positionShapeLookup[position] = shape; return(node); }
/// <summary> /// Initializes a new instance of the <see cref="ConstantExpressionNode" /> class. /// </summary> /// <param name="factory">The factory.</param> /// <param name="value">The value.</param> /// <param name="type">The type.</param> public ConstantExpressionNode(INodeFactory factory, object value, Type type) : base(factory, ExpressionType.Constant) { Value = value; if (type != null) { base.Type = factory.Create(type); } }
public void AddModifier(Modifier modifier) { var node = _nodeFactory.Create(modifier.Value); modifier.Stats .Select(GetOrAddStatGraph) .ForEach(g => g.AddModifier(node, modifier)); _modifierNodes.GetOrAdd(modifier, k => new Stack <IDisposableNodeViewProvider>()) .Push(node); }
public void AddModifier(Modifier modifier) { var node = _nodeFactory.Create(modifier.Value, new PathDefinition(modifier.Source)); foreach (var stat in modifier.Stats) { GetOrAddStatGraph(stat).AddModifier(node, modifier); } _modifierNodes.GetOrAdd(modifier, k => new Stack <IDisposableNodeViewProvider>()) .Push(node); }
public Mixer() { kernel = new StandardKernel(); interactions = new InteractionService(); window = Substitute.For <IMainWindowViewModel>(); nodeFactory = Substitute.For <INodeFactory>(); connectionFactory = Substitute.For <IConnectionFactory>(); kernel.Bind <IInteractionService>() .ToConstant(interactions); kernel.Bind <IMainWindowViewModel>() .ToConstant(window); kernel.Bind <INodeFactory>() .ToConstant(nodeFactory); kernel.Bind <IConnectionFactory>() .ToConstant(connectionFactory); kernel.Bind <IMixerViewModel>() .To <MixerViewModel>() .InSingletonScope(); // system under test keyDown = new Subject <KeyEventArgs>(); window.KeyDown.Returns(keyDown); nodeFactory.Create <IColorNodeViewModel>() .Returns(ci => Substitute.For <IColorNodeViewModel>()); nodeFactory.Create <IOperationNodeViewModel>() .Returns(ci => Substitute.For <IOperationNodeViewModel>()); nodeFactory.Create <IResultNodeViewModel>() .Returns(ci => Substitute.For <IResultNodeViewModel>()); connectionFactory.Create() .Returns(ci => kernel.Get <IConnectionViewModel>()); }
/// <summary> /// Converts an expression to an encoded string using the given factory and serializer. /// The encoding is decided by the serializer. /// </summary> /// <param name="expression">The expression.</param> /// <param name="factory">The factory.</param> /// <param name="serializer">The serializer.</param> /// <returns></returns> /// <exception cref="System.ArgumentNullException"> /// factory /// or /// serializer /// </exception> public static string ToText(this Expression expression, INodeFactory factory, ITextSerializer serializer) { if (factory == null) { throw new ArgumentNullException(nameof(factory)); } if (serializer == null) { throw new ArgumentNullException(nameof(serializer)); } return(serializer.Serialize(factory.Create(expression))); }
public IDisposableNodeViewProvider Create(IValue value) { var transformableValue = _transformableValueFactory(value); var result = _decoratedFactory.Create(transformableValue); TransformableDictionary[result] = transformableValue; transformableValue.ValueChanged += TransformableValueValueChanged; result.Disposed += ResultDisposed; return(result); void TransformableValueValueChanged(object sender, EventArgs args) => result.RaiseValueChanged(); void ResultDisposed(object sender, EventArgs args) { TransformableDictionary.Remove(result); transformableValue.ValueChanged -= TransformableValueValueChanged; result.Disposed -= ResultDisposed; } }
public IActionResult AddNode(Guid adapterGuid, NodeConfigurationModel configModel) { try { if (_nodeSynchroniztaionService.IsRunning) { _nodeSynchroniztaionService.StopAsync(new System.Threading.CancellationToken()); } var adapter = _adapterManager.Adapters.Where(x => x.Guid == adapterGuid).FirstOrDefault(); if (adapter == null) { return(BadRequest($"Adapter with guid: '{adapterGuid}' not found.")); } var node = _nodeFactory.Create(configModel.TypeFullName, configModel.JsonConfiguration); node.Name = configModel.Name; node.Guid = Guid.NewGuid(); node.DataType = NodeDataType.Int; node.ParentGuid = configModel.ParentGuid; adapter.AddNode(node); } catch (Exception ex) { return(BadRequest(ex.Message)); } finally { if (!_nodeSynchroniztaionService.IsRunning) { _nodeSynchroniztaionService.StartAsync(new System.Threading.CancellationToken()); } } return(CreatedAtAction()); }
/// <summary> /// Creates the specified expression node an expression. /// </summary> /// <param name="expression">The expression.</param> /// <returns></returns> public ExpressionNode Create(Expression expression) { return(_innerFactory.Create(expression)); }
public override T Create <T>(INodeFactory <T> factory) { return(factory.Create(this)); }
private IDisposableNodeViewProvider Create(IValue value) => _nodeFactory.Create(value);
private IDisposableNodeViewProvider Create(IValue value, PathDefinition path) => _nodeFactory.Create(value, path);