public static bool IsImportant(OpenXmlElement c, INodeProvider nodeProvider) { if (nodeProvider.IsParagraph(c)) { return(true); } if (nodeProvider.IsRun(c)) { var text = c.ChildElements.Where(a => !nodeProvider.IsRunProperties(a)).Only(); if (nodeProvider.IsText(text) && string.IsNullOrWhiteSpace(nodeProvider.GetText(text !))) { return(false); } return(true); } if (c is BaseNode) { return(true); } return(false); }
/// <summary> /// Creates a new instance of <see cref="NodeHelp"/>. /// </summary> /// <param name="nodeProviderFactory">A factory that returns an instance of <see cref="INodeProvider"/>.</param> /// <param name="dialogHostFactory">A factory that returns an instance of <see cref="DialogHostBase"/>.</param> public NodeHelp( Func <INodeProvider> nodeProviderFactory, Func <DialogHostBase> dialogHostFactory) { _nodeProvider = nodeProviderFactory(); _dialogHost = dialogHostFactory(); }
public virtual void Register(INodeProvider provider) { List <INodeProvider> temp = new List <INodeProvider>(providers); temp.Add(provider); providers = temp.ToArray(); }
public RenderService(INodeProvider nodeProvider, NodeConverter[] nodeConverters, ITranslationService translationService = null) { this.TranslationService = translationService ?? new DefaultTranslationService(); this.nodeProvider = nodeProvider; DefaultConverters = nodeConverters.Where(s => s.IsLayer).ToList(); CustomConverters = nodeConverters.Where(s => !s.IsLayer).ToList(); }
/// <summary> /// Adds new edge to the tree. /// </summary> /// <param name="nodes">Node provider which hosts the nodes</param> /// <param name="rootNodeId">Tree root node ID</param> /// <param name="edge">Edge to add</param> public static void InsertEdge(INodeProvider <Guid, object, EdgeData> nodes, Guid rootNodeId, Edge <Guid, EdgeData> edge, int treeOrder) { if (treeOrder < 6) { throw new ArgumentException(); } var result = FindLeafNode(nodes, rootNodeId, edge.Data); if (result.Node.Edges.Count == treeOrder) { SplitTree(nodes, rootNodeId, true, edge.Data, treeOrder); result = FindLeafNode(nodes, rootNodeId, edge.Data); } if (!result.Node.Data.Equals(LeafNodeData)) { throw new InvalidOperationException("Leaf node expected"); } var node = nodes.GetNode(result.NodeId, NodeAccess.ReadWrite); node.AddEdge(edge); nodes.SetNode(result.NodeId, node); }
/// <summary> /// Creates a new instance of <see cref="DiagramFactory"/>. /// </summary> /// <param name="nodeProvidorFactory">A factory that creates a <see cref="NodeProvider"/> instance.</param> /// <param name="diagramInteractorsFactory">A factory that creates a list of <see cref="IDiagramInteractor"/> to add to newly created diagrams.</param> public DiagramFactory( Func <INodeProvider> nodeProvidorFactory, Func <IEnumerable <IDiagramInteractor> > diagramInteractorsFactory) { _nodeProvidor = nodeProvidorFactory.Invoke(); diagramInteractors = diagramInteractorsFactory.Invoke().OfType <DiagramInteractor>(); }
public DialogService( INodeProvider nodeProvider, IDialogRepository dialogRepository) { _nodeProvider = nodeProvider; _dialogRepository = dialogRepository; }
/// <summary> /// Creates clone of existing tree under different ID /// </summary> /// <param name="nodes">Node provider which stores the nodes</param> /// <param name="sourceId">ID of source tree root</param> /// <param name="destinationId">ID of destination tree root</param> public static void Clone(INodeProvider <Guid, object, EdgeData> nodes, Guid sourceId, Guid destinationId) { var node = nodes.GetNode(sourceId, NodeAccess.Read); if (node.Data.Equals(InternalNodeData)) { Node <Guid, object, EdgeData> newNode = new Node <Guid, object, EdgeData>(node.NodeType, node.Data); foreach (var edge in node.Edges.Values) { Guid subId = Guid.NewGuid(); Clone(nodes, edge.ToNodeId, subId); newNode.AddEdge(new Edge <Guid, EdgeData>(subId, edge.Data)); } nodes.SetNode(destinationId, newNode); } else if (node.Data.Equals(LeafNodeData)) { Node <Guid, object, EdgeData> newNode = new Node <Guid, object, EdgeData>(node.NodeType, node.Data, node.Edges); nodes.SetNode(destinationId, newNode); } else { throw new InvalidOperationException(); } }
public ClientManagerRedirector(ILogger <ClientManagerRedirector> logger, INodeProvider nodeProvider, INodeLocator nodeLocator) { _logger = logger; _nodeProvider = nodeProvider; _nodeLocator = nodeLocator; _clients = new HashSet <ClientRedirector>(); }
public ControlViewRenderingService(INodeProvider figmaProvider, NodeConverter[] figmaViewConverters = null, ViewPropertyConfigureBase propertySetter = null, ITranslationService translationService = null) : base(figmaProvider, figmaViewConverters ?? FigmaControlsContext.Current.GetConverters(), propertySetter ?? FigmaControlsContext.Current.GetViewPropertySetter(), translationService ) { }
/// <summary> /// Runs a recursive pass and prints tree nodes /// </summary> /// <param name="nodes">Node provider which contains tree nodes</param> /// <param name="nodeId">Node to print</param> /// <param name="sb">String builder which contains the string</param> /// <param name="level">Current indentation level</param> private static void PrintTreeRecursive(INodeProvider <Guid, object, EdgeData> nodes, Guid nodeId, StringBuilder sb, int level) { var node = nodes.GetNode(nodeId, NodeAccess.Read); AppendTabs(sb, level); if (node.Data.Equals(InternalNodeData)) { sb.AppendFormat("Internal\n"); foreach (var edge in node.Edges.Values) { AppendTabs(sb, level); sb.AppendFormat("MAX[{0}]\n", edge.Data.Equals(EdgeData.MaxValue) ? "*" : edge.Data.Data.ToString()); PrintTreeRecursive(nodes, edge.ToNodeId, sb, level + 1); } } else { sb.AppendFormat("Leaf\n"); foreach (var edge in node.Edges.Values) { AppendTabs(sb, level); sb.AppendFormat("TO[{0}]\n", edge.ToNodeId.ToString()); } } }
/// <summary> /// Gets next leaf in tree compared to given sample data /// </summary> /// <param name="nodes">Node provider</param> /// <param name="rootNodeId">Root node id</param> /// <param name="sampleData">Sample data in the current leaf</param> /// <returns>Leaf node next in comparison to sample data, or null if no more leaves are found</returns> private static Node <Guid, object, EdgeData> NextLeaf(INodeProvider <Guid, object, EdgeData> nodes, Guid rootNodeId, EdgeData sampleData) { var node = nodes.GetNode(rootNodeId, NodeAccess.Read); Guid id = rootNodeId; Guid nextInternalParentId = Guid.Empty; while (node.Data.Equals(InternalNodeData)) { var leadingEdgeIndex = FindLeadingEdgeIndex(sampleData, node); if (leadingEdgeIndex < node.Edges.Count - 1) { nextInternalParentId = node.Edges[node.Edges.Keys[leadingEdgeIndex + 1]].ToNodeId; } // Advance to next internal node node = nodes.GetNode(node.Edges[node.Edges.Keys[leadingEdgeIndex]].ToNodeId, NodeAccess.Read); } if (nextInternalParentId.Equals(Guid.Empty)) { return(null); } else { return(LeftLeaf(nodes, nodes.GetNode(nextInternalParentId, NodeAccess.Read))); } }
/// <summary> /// Register an instantiated INodeProvider with the node manager. The node manager will query the nodeprovider /// for a list of its node descriptions, and add these nodes to a master list of nodes which can be used /// by the scheduler. QUESTION: Do we allow duplicate Node Providers? /// </summary> /// <param name="providerToRegister"></param> /// <returns></returns> internal bool RegisterNodeProvider(INodeProvider nodeProviderToRegister) { ErrorUtilities.VerifyThrowArgumentNull(nodeProviderToRegister, "nodeProviderToRegister"); INodeDescription[] nodeDescriptions = nodeProviderToRegister.QueryNodeDescriptions(); int[] nodeIds = new int[nodeDescriptions.Length]; for (int i = 0; i < nodeIds.Length; i++) { nodeIds[i] = parentEngine.GetNextNodeId(); } nodeProviderToRegister.AssignNodeIdentifiers(nodeIds); // Go through all of the nodes as described by nodeDescriptions and add them to out list of nodes for (int i = 0; i < nodeDescriptions.Length; i++) { ProvidersNodeInformation nodeToAddFromProvider = new ProvidersNodeInformation(i, nodeIds[i], nodeDescriptions[i], nodeProviderToRegister); nodeList.Add(nodeToAddFromProvider); } nodeProviders.Add(nodeProviderToRegister); return(true); }
/// <summary> /// Returns number of edges in the tree /// </summary> /// <param name="nodes">Node provider which hosts the nodes</param> /// <param name="rootNodeId">Tree root node ID</param> /// <param name="data">Edge to find</param> /// <returns></returns> public static int Count(INodeProvider <Guid, object, EdgeData> nodes, Guid rootNodeId, EdgeType data) { var node = nodes.GetNode(rootNodeId, NodeAccess.Read); if (node.Data.Equals(LeafNodeData)) { int sum = 0; foreach (var edge in node.Edges.Values) { if (edge.Data.Semantic.Equals(data)) { sum++; } } return(sum); } else { int sum = 0; foreach (var edge in node.Edges.Values) { sum += Count(nodes, edge.ToNodeId, data); } return(sum); } }
/// <summary> /// Register an instantiated INodeProvider with the node manager. The node manager will query the nodeprovider /// for a list of its node descriptions, and add these nodes to a master list of nodes which can be used /// by the scheduler. QUESTION: Do we allow duplicate Node Providers? /// </summary> /// <param name="providerToRegister"></param> /// <returns></returns> internal bool RegisterNodeProvider(INodeProvider nodeProviderToRegister) { ErrorUtilities.VerifyThrowArgumentNull(nodeProviderToRegister,"nodeProviderToRegister"); INodeDescription[] nodeDescriptions = nodeProviderToRegister.QueryNodeDescriptions(); int[] nodeIds = new int[nodeDescriptions.Length]; for (int i = 0; i < nodeIds.Length; i++) { nodeIds[i] = parentEngine.GetNextNodeId(); } nodeProviderToRegister.AssignNodeIdentifiers(nodeIds); // Go through all of the nodes as described by nodeDescriptions and add them to out list of nodes for(int i=0; i < nodeDescriptions.Length;i++) { ProvidersNodeInformation nodeToAddFromProvider = new ProvidersNodeInformation(i, nodeIds[i], nodeDescriptions[i], nodeProviderToRegister); nodeList.Add(nodeToAddFromProvider); } nodeProviders.Add(nodeProviderToRegister); return true; }
public virtual void Unregister(INodeProvider provider) { List <INodeProvider> temp = new List <INodeProvider>(providers); temp.RemoveAll(p => p == provider); providers = temp.ToArray(); }
/// <summary> /// Shuts down the component. /// </summary> public void ShutdownComponent() { _outOfProcTaskHostNodeProvider = null; _componentHost = null; _componentShutdown = true; ClearPerBuildState(); }
internal AnyNode(INodeProvider nodeProvider, ValueProviderBase valueProvider, string operation, string value, Action <bool, string> addError) : base(nodeProvider) { this.ValueProvider = valueProvider; this.Operation = FilterValueConverter.ParseOperation(operation); this.Value = value; ValueProvider?.ValidateConditionValue(value, Operation, addError); }
public ForeachNode(INodeProvider nodeProvider, ValueProviderBase valueProvider) : base(nodeProvider) { this.ValueProvider = valueProvider; if (valueProvider != null) { valueProvider.IsForeach = true; } }
/// <summary> /// Prints tree nodes and edges /// </summary> /// <param name="nodes">Node provider which contains tree nodes</param> /// <param name="rootNodeId">Tree root node ID</param> /// <returns>String representation of the tree</returns> public static string PrintTree(INodeProvider <Guid, object, EdgeData> nodes, Guid rootNodeId) { StringBuilder sb = new StringBuilder(); PrintTreeRecursive(nodes, rootNodeId, sb, 0); return(sb.ToString()); }
/// <summary> /// Creates new instance of SequentialOrderingProblem class /// </summary> /// <param name="name">problem name</param> /// <param name="comment">comment on problem from the author</param> /// <param name="nodeProvider">provider of nodes</param> /// <param name="edgeProvider">provider of edges</param> /// <param name="edgeWeightsProvider">provider of edge weights</param> /// <param name="fixedEdgesProvider">provider of fixed edges</param> public SequentialOrderingProblem(string name, string comment, INodeProvider nodeProvider, IEdgeProvider edgeProvider, IEdgeWeightsProvider edgeWeightsProvider, IFixedEdgesProvider fixedEdgesProvider) : base(name, comment, ProblemType.SOP, nodeProvider, edgeProvider, edgeWeightsProvider, fixedEdgesProvider) { }
public LeafDifferenceEnumerator(string leftPath, string rightPath, ILeafComparer leafComparer, ILeafProvider leafProvider, INodeProvider nodeProvider) { LeftPath = leftPath; RightPath = rightPath; LeafComparer = leafComparer; LeafProvider = leafProvider; NodeProvider = nodeProvider; Initialize(); }
/// <summary> /// Creates new instance of HamiltonianCycleProblem class /// </summary> /// <param name="name">problem name</param> /// <param name="comment">comment on problem from the author</param> /// <param name="nodeProvider">provider of nodes</param> /// <param name="edgeProvider">provider of edges</param> /// <param name="edgeWeightsProvider">provider of edge weights</param> /// <param name="fixedEdgesProvider">provider of fixed edges</param> public HamiltonianCycleProblem(string name, string comment, INodeProvider nodeProvider, IEdgeProvider edgeProvider, IEdgeWeightsProvider edgeWeightsProvider, IFixedEdgesProvider fixedEdgesProvider) : base(name, comment, ProblemType.HCP, nodeProvider, edgeProvider, edgeWeightsProvider, fixedEdgesProvider) { }
internal DeclareNode(INodeProvider nodeProvider, ValueProviderBase valueProvider, Action <bool, string> addError) : base(nodeProvider) { if (!valueProvider.Variable.HasText()) { addError(true, "declare{0} should end with 'as $someVariable'".FormatWith(valueProvider.ToString())); } this.ValueProvider = valueProvider; }
/// <summary> /// Initializes the component /// </summary> /// <param name="host">The component host</param> public void InitializeComponent(IBuildComponentHost host) { ErrorUtilities.VerifyThrow(_componentHost == null, "TaskHostNodeManager already initialized."); ErrorUtilities.VerifyThrow(host != null, "We can't create a TaskHostNodeManager with a null componentHost"); _componentHost = host; _outOfProcTaskHostNodeProvider = _componentHost.GetComponent(BuildComponentType.OutOfProcTaskHostNodeProvider) as INodeProvider; _componentShutdown = false; }
/// <summary> /// Creates new instance of BPlusTreeEnumerator type /// </summary> /// <param name="nodes">Node provider which contains tree nodes</param> /// <param name="rootNodeId">Root item ID</param> /// <param name="edgeType">Edge type to use as a filter for enumeration</param> public BPlusTreeEnumerator(INodeProvider <Guid, object, EdgeData> nodes, Guid rootNodeId, EdgeType edgeType) { this.nodes = nodes; this.rootNodeId = rootNodeId; this.edgeType = edgeType; var currentLeaf = BPlusTreeOperations.LeftLeaf(nodes, nodes.GetNode(rootNodeId, NodeAccess.Read)); this.currentLeafEnumerator = currentLeaf.Edges.Values.GetEnumerator(); }
/// <summary> /// Creates new instance of AppendableChangeSet type /// </summary> /// <param name="sourceSnapshotId">Snapshot ID which is considered a base</param> /// <param name="destinationSnapshotId">Snapshot ID for new version</param> /// <param name="nodes">Nodes which are forming the change delta tree</param> /// <param name="mapping">Mapping from old->new node id</param> public AppendableChangeSet(TIdentifier sourceSnapshotId, TIdentifier destinationSnapshotId, INodeProvider <TIdentifier, TNodeData, TEdgeData> nodes, Dictionary <TIdentifier, TIdentifier> mapping, Dictionary <TIdentifier, NodeState> nodeStates, Hashtable reusedNodes) { this.SourceSnapshotId = sourceSnapshotId; this.DestinationSnapshotId = destinationSnapshotId; this.Nodes = nodes; this.Mapping = mapping; this.NodeStates = nodeStates; this.ReusedNodes = reusedNodes; }
/// <summary> /// Creates new instance of ClientContext type /// </summary> /// <param name="serverContext">Server context interface</param> /// <param name="localStorage">Storage for local data</param> public ClientContext(IServerContext serverContext, IKeyValueStorage <Guid, object> localStorage) { this.serverContext = serverContext; this.provider = new CachedReadNodeProvider <Guid, object, EdgeData>(serverContext, new DirectNodeProviderUnsafe <Guid, object, EdgeData>(localStorage, localStorage is IForceUpdateStorage)); this.snapshotIsolationEnabled = serverContext.SnapshotIsolationEnabled; this.defaultWorkspaceTimeout = serverContext.DefaultWorkspaceTimeout; InitializeServices(); }
/// <summary> /// Creates new instance of HamiltonianCycleProblem class /// </summary> /// <param name="name">problem name</param> /// <param name="comment">comment on problem from the author</param> /// <param name="nodeProvider">provider of nodes</param> /// <param name="edgeProvider">provider of edges</param> /// <param name="edgeWeightsProvider">provider of edge weights</param> /// <param name="fixedEdgesProvider">provider of fixed edges</param> public HamiltonianCycleProblem(string name, string comment, INodeProvider nodeProvider, IEdgeProvider edgeProvider, IEdgeWeightsProvider edgeWeightsProvider, IFixedEdgesProvider fixedEdgesProvider) : base(name, comment, ProblemType.HCP, nodeProvider, edgeProvider, edgeWeightsProvider, fixedEdgesProvider) { }
/// <summary> /// Creates new instance of SequentialOrderingProblem class /// </summary> /// <param name="name">problem name</param> /// <param name="comment">comment on problem from the author</param> /// <param name="nodeProvider">provider of nodes</param> /// <param name="edgeProvider">provider of edges</param> /// <param name="edgeWeightsProvider">provider of edge weights</param> /// <param name="fixedEdgesProvider">provider of fixed edges</param> public SequentialOrderingProblem(string name, string comment, INodeProvider nodeProvider, IEdgeProvider edgeProvider, IEdgeWeightsProvider edgeWeightsProvider, IFixedEdgesProvider fixedEdgesProvider) : base(name, comment, ProblemType.SOP, nodeProvider, edgeProvider, edgeWeightsProvider, fixedEdgesProvider) { }
/// <summary> /// Creates new instance of TravelingSalesmanProblem class /// </summary> /// <param name="name">problem name</param> /// <param name="comment">comment on problem from the author</param> /// <param name="type">TSP or ATSP</param> /// <param name="nodeProvider">provider of nodes</param> /// <param name="edgeProvider">provider of edges</param> /// <param name="edgeWeightsProvider">provider of edge weights</param> /// <param name="fixedEdgesProvider">provider of fixed edges</param> public TravelingSalesmanProblem(string name, string comment, ProblemType type, INodeProvider nodeProvider, IEdgeProvider edgeProvider, IEdgeWeightsProvider edgeWeightsProvider, IFixedEdgesProvider fixedEdgesProvider) : base(name, comment, type, nodeProvider, edgeProvider, edgeWeightsProvider, fixedEdgesProvider) { }
/// <summary> /// Creates new instance of TravelingSalesmanProblem class /// </summary> /// <param name="name">problem name</param> /// <param name="comment">comment on problem from the author</param> /// <param name="type">TSP or ATSP</param> /// <param name="nodeProvider">provider of nodes</param> /// <param name="edgeProvider">provider of edges</param> /// <param name="edgeWeightsProvider">provider of edge weights</param> /// <param name="fixedEdgesProvider">provider of fixed edges</param> public TravelingSalesmanProblem(string name, string comment, ProblemType type, INodeProvider nodeProvider, IEdgeProvider edgeProvider, IEdgeWeightsProvider edgeWeightsProvider, IFixedEdgesProvider fixedEdgesProvider) : base(name, comment, type, nodeProvider, edgeProvider, edgeWeightsProvider, fixedEdgesProvider) { }
public BaseNode(BaseNode original) { this.NodeProvider = original.NodeProvider; this.RunProperties = original.RunProperties; this.SetAttributes(original.GetAttributes().ToList()); foreach (var item in original.ChildElements) { this.AppendChild(item.CloneNode(true)); } }
/// <summary> /// Creates a new instance of <see cref="NodePalette"/>. /// </summary> /// <param name="nodeProviderFactory">A factory that returns an instance of <see cref="INodeProvider"/>.</param> /// <param name="dialogHostFactory">A factory that returns an instance of <see cref="DialogHostBase"/>.</param> public NodePalette(Func <INodeProvider> nodeProviderFactory, Func <DialogHostBase> dialogHostFactory) { _nodeProvider = nodeProviderFactory(); _dialogHost = dialogHostFactory(); if (_nodeProvider is NodeProvider provider) { provider.NodeRegistered += NodeProviderNodeRegistered; } AddNodes(); }
/// <summary> /// Creates new instance of CommitDataService type /// </summary> /// <param name="nodes">Nodes which will accept data changes</param> /// <param name="snapshotsService">Service which handles snapshots</param> /// <param name="mutableParentProvider">Provider of node parent information</param> public CommitDataService(INodeProvider<Guid, object, EdgeData> nodes, TypesService typesService, SnapshotsService snapshotsService, IParentMapProvider<Guid, object, EdgeData> mutableParentProvider, IParentMapProvider<Guid, object, EdgeData> immutableParentProvider, IChangeSetProvider<Guid, object, EdgeData> changeSetProvider, NodeMergeExecutor nodeMergeExecutor, ICollectedNodesProvider<Guid, object, EdgeData> collectedNodesProvider) { this.nodes = nodes; this.snapshotsService = snapshotsService; this.mutableParentProvider = mutableParentProvider; this.immutableParentProvider = immutableParentProvider; this.changeSetProvider = changeSetProvider; this.nodeMergeExecutor = nodeMergeExecutor; this.typesService = typesService; this.collectedNodesProvider = collectedNodesProvider; }
/// <summary> /// Constructor /// </summary> /// <param name="storage">The storage from which the types needed for visualisation are loaded</param> public TypesVisualisationService(IKeyValueStorage<Guid, object> storage) { if (storage is ISerializingStorage) { (storage as ISerializingStorage).Serializer = objectSerializationService; } var storageProvider = new DirectNodeProviderSafe<Guid, object, EdgeData>(storage, storage is IForceUpdateStorage); provider = new CachedReadNodeProvider<Guid, object, EdgeData>(storageProvider, new DirectNodeProviderSafe<Guid, object, EdgeData>(new LimitedMemoryStorageSafe<Guid, object>(Properties.Settings.Default.DataCacheMinimumCount, Properties.Settings.Default.DataCacheMaximumCount), false)); typesService = new TypesService(provider); typesService.InitializeTypeSystem(null); objectSerializationService.TypesService = typesService; }
public Register(IConnection connection, INodeProvider nodeProvider, INotification notification) { if(connection == null) throw new ArgumentNullException("connection"); if (nodeProvider == null) throw new ArgumentNullException("nodeProvider"); if(notification == null) throw new ArgumentNullException("notification"); _nodeProvider = nodeProvider; _connection = connection; _notification = notification; }
internal void Archive(Guid revisionId, INodeProvider<Guid, object, EdgeData> source, INodeProvider<Guid, object, EdgeData> destination) { foreach (var item in destination.EnumerateNodes()) { throw new ArgumentException("Destination provider must be empty"); } var visitedNodes = new Hashtable(); // Create types AddNodesRecursive(Constants.TypesNodeId, source, destination, visitedNodes); // Copy snapshot AddNodesRecursive(revisionId, source, destination, visitedNodes); // Create snapshots root var snapshotsNode = new Node<Guid, object, EdgeData>(NodeType.SnapshotsRoot, null); // Create link to the snapshot snapshotsNode.AddEdge(new Edge<Guid, EdgeData>(revisionId, new EdgeData(EdgeType.Contains, null))); // Store the snapshots root as the last operation of backup destination.SetNode(Constants.SnapshotsNodeId, snapshotsNode); }
/// <summary> /// Creates new instance of CapacitatedVehicleRoutingProblem class /// </summary> /// <param name="name">problem name</param> /// <param name="comment">comment on problem from the author</param> /// <param name="nodeProvider">provider of nodes</param> /// <param name="edgeProvider">provider of edges</param> /// <param name="edgeWeightsProvider">provider of edge weights</param> /// <param name="fixedEdgesProvider">provider of fixed edges</param> /// <param name="depotsProvider">provider of depot nodes</param> /// <param name="demandProvider">provider of demands on nodes</param> public CapacitatedVehicleRoutingProblem(string name, string comment, INodeProvider nodeProvider, IEdgeProvider edgeProvider, IEdgeWeightsProvider edgeWeightsProvider, IFixedEdgesProvider fixedEdgesProvider, IDepotsProvider depotsProvider, IDemandProvider demandProvider) : base(name, comment, ProblemType.CVRP, nodeProvider, edgeProvider, edgeWeightsProvider, fixedEdgesProvider) { if (depotsProvider == null) { throw new ArgumentNullException("depotsProvider"); } if (demandProvider == null) { throw new ArgumentNullException("demandProvider"); } DepotsProvider = depotsProvider; DemandProvider = demandProvider; }
/// <summary> /// Creates new instance of ProblemBase class /// </summary> /// <param name="name">Problem name</param> /// <param name="comment">Comment on problem</param> /// <param name="type">The problem type (TSP, ATSP, etc)</param> /// <param name="nodeProvider">Provider of graph nodes</param> /// <param name="edgeProvider">Provider of graph edges</param> /// <param name="edgeWeightsProvider">Provider of edge weights</param> /// <param name="fixedEdgesProvider">Provider of solution fixed edges</param> protected ProblemBase(string name, string comment, ProblemType type, INodeProvider nodeProvider, IEdgeProvider edgeProvider, IEdgeWeightsProvider edgeWeightsProvider, IFixedEdgesProvider fixedEdgesProvider) { if (nodeProvider == null) { throw new ArgumentNullException("nodeProvider"); } if (edgeProvider == null) { throw new ArgumentNullException("edgeProvider"); } if (edgeWeightsProvider == null) { throw new ArgumentNullException("edgeWeightsProvider"); } if (fixedEdgesProvider == null) { throw new ArgumentNullException("fixedEdgesProvider"); } Name = name; Comment = comment; Type = type; NodeProvider = nodeProvider; EdgeProvider = edgeProvider; EdgeWeightsProvider = edgeWeightsProvider; FixedEdgesProvider = fixedEdgesProvider; }
/// <summary> /// Initializes a new instance of the TypesService class /// </summary> /// <param name="provider">Node provider which contains nodes</param> public SnapshotsService(INodeProvider<Guid, object, EdgeData> provider) { this.provider = provider; }
private void AddNodesRecursive(Guid nodeId, INodeProvider<Guid, object, EdgeData> source, INodeProvider<Guid, object, EdgeData> destination, Hashtable visitedNodes) { if (visitedNodes.ContainsKey(nodeId)) { return; } visitedNodes.Add(nodeId, null); var node = source.GetNode(nodeId, NodeAccess.Read); var newNode = new Node<Guid, object, EdgeData>(node.NodeType, node.Data, node.Edges, node.Values); destination.SetNode(nodeId, newNode); foreach (var edge in node.Edges.Values) { if (edge.ToNodeId != Constants.NullReferenceNodeId) { AddNodesRecursive(edge.ToNodeId, source, destination, visitedNodes); } } }
internal static void LogNodesRecursive(Guid nodeId, INodeProvider<Guid, object, EdgeData> nodes, INodeProvider<Guid, object, EdgeData> changes, int tabLevel, Hashtable visited, TypesService typesService) { if (visited.ContainsKey(nodeId)) { Debug.WriteLine(LogTabs(tabLevel) + nodeId); return; } visited.Add(nodeId, null); if (changes.Contains(nodeId)) { var node = changes.GetNode(nodeId, NodeAccess.Read); switch (node.NodeType) { case NodeType.Object: LogObject(nodeId, node, nodes, changes, tabLevel, visited, typesService); break; case NodeType.Collection: LogCollection(nodeId, node, nodes, changes, tabLevel, visited, typesService); break; case NodeType.Dictionary: LogCollection(nodeId, node, nodes, changes, tabLevel, visited, typesService); break; default: Debug.WriteLine(LogTabs(tabLevel) + node.Previous + "->" + nodeId + "[" + node.NodeType + "]"); foreach (var edge in node.Edges) { Debug.WriteLine(LogTabs(tabLevel) + edge.Key + "="); LogNodesRecursive(edge.Value.ToNodeId, nodes, changes, tabLevel + 1, visited, typesService); } break; } } else { Debug.WriteLine(LogTabs(tabLevel) + nodeId); } }
public Parsers(INodeProvider nodeProvider) { NodeProvider = nodeProvider; }
public void Setup() { _connection = MockRepository.GenerateStub<IConnection>(); _nodeProvider = MockRepository.GenerateMock<INodeProvider>(); _notification = MockRepository.GenerateMock<INotification>(); _register = new Register(_connection, _nodeProvider, _notification); }
public void SetUp() { _nodeProvider = new NodeProvider(); }
public CollectionInstancesService(INodeProvider<Guid, object, EdgeData> provider, TypesService typesService) { this.provider = provider; this.typesService = typesService; }
private static void LogObject(Guid nodeId, Node<Guid, object, EdgeData> node, INodeProvider<Guid, object, EdgeData> nodes, INodeProvider<Guid, object, EdgeData> changes, int tabLevel, Hashtable visited, TypesService typesService) { var typeId = typesService.GetInstanceTypeId(node); var typeName = typesService.GetTypeFromId(typeId).Name; Debug.WriteLine(LogTabs(tabLevel) + nodeId + "(" + typeName + ")"); Debug.WriteLine(LogTabs(tabLevel) + "Previous=" + node.Previous); foreach (var value in node.Values) { Debug.WriteLine(LogTabs(tabLevel) + typesService.GetMemberName(typeId, value.Key) + "=" + value.Value); } foreach (var edge in node.Edges) { if (edge.Value.Data.Semantic == EdgeType.Property) { Debug.WriteLine(LogTabs(tabLevel) + typesService.GetMemberName(typeId, (Guid)edge.Value.Data.Data) + "="); LogNodesRecursive(edge.Value.ToNodeId, nodes, changes, tabLevel + 1, visited, typesService); } } }
/// <summary> /// Attempts to create a node on the specified machine using the specified provider. /// </summary> /// <param name="nodeProvider">The provider used to create the node.</param> /// <returns>The id of the node created.</returns> private int AttemptCreateNode(INodeProvider nodeProvider, NodeConfiguration nodeConfiguration) { // If no provider was passed in, we obviously can't create a node. if (null == nodeProvider) { ErrorUtilities.ThrowInternalError("No node provider provided."); return InvalidNodeId; } // Are there any free slots on this provider? if (nodeProvider.AvailableNodes == 0) { return InvalidNodeId; } // Assign a global ID to the node we are about to create. int nodeId = InvalidNodeId; if (nodeProvider is NodeProviderInProc) { nodeId = _inprocNodeId; } else { nodeId = _nextNodeId; _nextNodeId++; } NodeConfiguration configToSend = nodeConfiguration.Clone(); configToSend.NodeId = nodeId; // Create the node and add it to our mapping. bool createdNode = nodeProvider.CreateNode(nodeId, this, configToSend); if (!createdNode) { return InvalidNodeId; } _nodeIdToProvider.Add(nodeId, nodeProvider); return nodeId; }
/// <summary> /// Shuts down the component. /// </summary> public void ShutdownComponent() { if (_inProcNodeProvider != null && _inProcNodeProvider is IDisposable) { ((IDisposable)_inProcNodeProvider).Dispose(); } if (_outOfProcNodeProvider != null && _outOfProcNodeProvider is IDisposable) { ((IDisposable)_outOfProcNodeProvider).Dispose(); } _inProcNodeProvider = null; _outOfProcNodeProvider = null; _componentHost = null; _componentShutdown = true; ClearPerBuildState(); }
/// <summary> /// Shuts down the component. /// </summary> public void ShutdownComponent() { _outOfProcTaskHostNodeProvider = null; _componentHost = null; _componentShutdown = true; ClearPerBuildState(); }
/// <summary> /// Add a file system provider to this manager. /// </summary> /// <remarks> /// When a provider is added, its <c>SupportedUriSchemas</c> property is used to determine /// which resolution requests will be forwarded to the provider. If more than one provider /// support the same schema, the most recently added provider will be used. /// </remarks> /// <param name="provider"></param> public virtual void AddProvider(INodeProvider provider) { providers.Add(provider); }
public virtual void Register(INodeProvider provider) { List<INodeProvider> temp = new List<INodeProvider>(providers); temp.Add(provider); providers = temp.ToArray(); }
public virtual void Unregister(INodeProvider provider) { List<INodeProvider> temp = new List<INodeProvider>(providers); temp.RemoveAll(p => p == provider); providers = temp.ToArray(); }
/// <summary> /// Constructor /// </summary> /// <param name="storage">The storage from which the types needed for visualisation are loaded</param> public TypesVisualisationService(INodeProvider<Guid, object, EdgeData> provider) { this.provider = provider; typesService = new TypesService(provider); }
public ArchiveWorkspaceFacade(INodeProvider<Guid, object, EdgeData> archiveProvider) { this.archiveProvider = archiveProvider; }
internal ProvidersNodeInformation ( int nodeProviderNodeIndex, int nodeId, INodeDescription nodeProviderDescription, INodeProvider nodeProviderReference ) { this.nodeIndex = nodeProviderNodeIndex; this.nodeId = nodeId; this.description = nodeProviderDescription; this.nodeProvider = nodeProviderReference; }
private static void LogCollection(Guid nodeId, Node<Guid, object, EdgeData> node, INodeProvider<Guid, object, EdgeData> nodes, INodeProvider<Guid, object, EdgeData> changes, int tabLevel, Hashtable visited, TypesService typesService) { Edge<Guid, EdgeData> typeEdge = null; BPlusTreeOperations.TryFindEdge(nodes, nodeId, new EdgeData(EdgeType.OfType, null), out typeEdge); var typeId = typeEdge.ToNodeId; var typeName = typesService.GetTypeFromId(typeId).Name; Debug.WriteLine(LogTabs(tabLevel) + nodeId + "(" + typeName + ")"); Debug.WriteLine(LogTabs(tabLevel) + "Previous=" + node.Previous); using (var enumeration = BPlusTreeOperations.GetEnumerator(nodes, nodeId, EdgeType.ListItem)) { while (enumeration.MoveNext()) { Debug.WriteLine(LogTabs(tabLevel) + enumeration.Current.Data + "="); LogNodesRecursive(enumeration.Current.ToNodeId, nodes, changes, tabLevel + 1, visited, typesService); } } }
/// <summary> /// Initializes the component /// </summary> /// <param name="host">The component host</param> public void InitializeComponent(IBuildComponentHost host) { ErrorUtilities.VerifyThrow(_componentHost == null, "TaskHostNodeManager already initialized."); ErrorUtilities.VerifyThrow(host != null, "We can't create a TaskHostNodeManager with a null componentHost"); _componentHost = host; _outOfProcTaskHostNodeProvider = _componentHost.GetComponent(BuildComponentType.OutOfProcTaskHostNodeProvider) as INodeProvider; _componentShutdown = false; }
/// <summary> /// Initializes the component /// </summary> /// <param name="host">The component host</param> public void InitializeComponent(IBuildComponentHost host) { ErrorUtilities.VerifyThrow(_componentHost == null, "NodeManager already initialized."); ErrorUtilities.VerifyThrow(host != null, "We can't create a NodeManager with a null componentHost"); _componentHost = host; _inProcNodeProvider = _componentHost.GetComponent(BuildComponentType.InProcNodeProvider) as INodeProvider; _outOfProcNodeProvider = _componentHost.GetComponent(BuildComponentType.OutOfProcNodeProvider) as INodeProvider; _componentShutdown = false; // DISTRIBUTED: Get the remote node provider. }