/// <summary> /// Default constructor /// </summary> /// <param name="globalMeta">Global meta data</param> /// <param name="logger">Logger</param> /// <param name="meta">Local meta data</param> /// <param name="parent">Parent graph if available</param> /// <param name="properties">A property bag associated with this connection</param> public NetGraph(Logger logger, NetGraph parent, MetaDictionary globalMeta, MetaDictionary meta, PropertyBag properties) { Nodes = new Dictionary <Guid, BasePipelineNode>(); if (meta == null) { Meta = new MetaDictionary(); } else { Meta = meta; } Properties = new ConcurrentDictionary <string, string>(); ConnectionProperties = properties; GlobalMeta = globalMeta; Uuid = Guid.NewGuid(); if (logger != null) { Logger = logger; } else { Logger = Logger.GetSystemLogger(); } NetworkDescription = "Unknown"; Name = String.Empty; Parent = parent; Created = DateTime.Now; CreatedTicks = new TimeSpan(DateTime.UtcNow.Ticks); if (parent == null) { ServiceProvider = new CANAPEServiceProvider(); } else { ServiceProvider = parent.ServiceProvider; } }
/// <summary> /// Constructor /// </summary> /// <param name="dict">Other dictionary</param> public MetaDictionary(MetaDictionary dict) : base(dict.ToArray()) { }
private void HandleFrame(LayerSectionFilter filter, DataFrame frame) { string name = GenerateName(filter, frame); GraphEntry startEntry = null; lock (_graphEntries) { if (!_shuttingDown) { if (_graphEntries.ContainsKey(name)) { _graphEntries[name].GetInputAdapter(_direction).Enqueue(frame); } else { LayerSectionDataAdapter clientAdapter = new LayerSectionDataAdapter(this); LayerSectionDataAdapter serverAdapter = new LayerSectionDataAdapter(_linkedNode); if (_direction == LayerSectionGraphDirection.ClientToServer) { LayerSectionDataAdapter temp = clientAdapter; clientAdapter = serverAdapter; serverAdapter = temp; } var clients = filter.Factory.GetNodes <ClientEndpointFactory>(); var servers = filter.Factory.GetNodes <ServerEndpointFactory>(); if ((clients.Length > 0) && (servers.Length > 0)) { MetaDictionary meta = filter.IsolatedGraph ? new MetaDictionary() : Graph.Meta; NetGraph graph = filter.Factory.Create(Graph.Logger, Graph, Graph.GlobalMeta, meta, Graph.ConnectionProperties.AddBag(name)); graph.Name = String.Format(CultureInfo.InvariantCulture, "{0}.{1}", Name, name); startEntry = new GraphEntry(filter, clientAdapter, serverAdapter, graph, clients[0].Id, servers[0].Id, ProxyNetworkService.GetLayerBinding(Graph)); startEntry.GetInputAdapter(_direction).Enqueue(frame); _graphEntries[name] = startEntry; } else { throw new ArgumentException(CANAPE.Net.Properties.Resources.LayerSectionNode_InvalidGraph); } } } } // Ensure this is done outside the lock if (startEntry != null) { startEntry.NegotiationThread = new Thread(() => { try { startEntry.Start(); } catch (Exception ex) { Graph.Logger.LogException(ex); lock (_graphEntries) { _graphEntries.Remove(name); startEntry.Dispose(); } } } ); startEntry.NegotiationThread.CurrentUICulture = Thread.CurrentThread.CurrentUICulture; startEntry.NegotiationThread.IsBackground = true; startEntry.NegotiationThread.Start(); } }