Esempio n. 1
0
 /// <summary>
 /// Constructor        
 /// </summary>
 /// <param name="filters">List of filters used to determine when to create new graph</param>        
 /// <param name="defaultMode">Default mode of the layer section</param>
 /// <param name="direction">The direction of the node</param>
 public LayerSectionNode(LayerSectionFilter[] filters, LayerSectionNodeDefaultMode defaultMode, LayerSectionGraphDirection direction)
 {
     _filters = filters;
     _defaultMode = defaultMode;
     _graphEntries = new Dictionary<string, GraphEntry>();
     _direction = direction;
     IsMaster = true;
 }
Esempio n. 2
0
 public GraphEntry(LayerSectionFilter filter, LayerSectionDataAdapter clientAdapter,
                   LayerSectionDataAdapter serverAdapter, NetGraph graph, Guid clientEndpoint,
                   Guid serverEndpoint, NetworkLayerBinding defaultBinding)
 {
     Filter          = filter;
     _clientAdapter  = clientAdapter;
     _serverAdapter  = serverAdapter;
     Graph           = graph;
     _clientEndpoint = clientEndpoint;
     _serverEndpoint = serverEndpoint;
     _defaultBinding = defaultBinding;
 }
Esempio n. 3
0
        private string GenerateName(LayerSectionFilter filter, DataFrame frame)
        {
            string ret = filter.FilterId.ToString();

            if (!String.IsNullOrWhiteSpace(filter.SelectionPath))
            {
                DataNode node = SelectSingleNode(frame);

                if (node != null)
                {
                    ret = String.Format(CultureInfo.InvariantCulture, "{0}.{1}", ret, node);
                }
            }

            return(ret);
        }
Esempio n. 4
0
        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();
            }
        }
Esempio n. 5
0
 public GraphEntry(LayerSectionFilter filter, LayerSectionDataAdapter clientAdapter,
     LayerSectionDataAdapter serverAdapter, NetGraph graph, Guid clientEndpoint,
     Guid serverEndpoint, NetworkLayerBinding defaultBinding)
 {
     Filter = filter;
     _clientAdapter = clientAdapter;
     _serverAdapter = serverAdapter;
     Graph = graph;
     _clientEndpoint = clientEndpoint;
     _serverEndpoint = serverEndpoint;
     _defaultBinding = defaultBinding;
 }
Esempio n. 6
0
        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();
            }
        }
Esempio n. 7
0
        private string GenerateName(LayerSectionFilter filter, DataFrame frame)
        {
            string ret = filter.FilterId.ToString();

            if (!String.IsNullOrWhiteSpace(filter.SelectionPath))
            {
                DataNode node = SelectSingleNode(frame);

                if (node != null)
                {
                    ret = String.Format(CultureInfo.InvariantCulture, "{0}.{1}", ret, node);
                }
            }

            return ret;
        }