示例#1
0
        /// <summary>
        /// Create the netgraph for a connection
        /// </summary>
        /// <param name="factory">The netgraph factory</param>
        /// <param name="meta">Current meta data</param>
        /// <param name="properties">Property bag</param>
        /// <returns>The created graph</returns>
        private NetGraph CreateNetGraph(NetGraphFactory factory, MetaDictionary meta, PropertyBag properties)
        {
            NetGraph g = factory == null?_factory.Create(_logger, null, _globalMeta, meta, properties) : factory.Create(_logger, null, _globalMeta, meta, properties);

            if (g != null)
            {
                g.LogPacketEvent  += new EventHandler <LogPacketEventArgs>(log_AddLogPacket);
                g.EditPacketEvent += new EventHandler <EditPacketEventArgs>(edit_InputReceived);
                g.GraphShutdown   += new EventHandler(graph_GraphShutdown);
            }

            return(g);
        }
示例#2
0
        /// <summary>
        /// Create the netgraph for a connection
        /// </summary>
        /// <param name="factory">The netgraph factory</param>
        /// <param name="meta">Current meta data</param>
        /// <param name="properties">Property bag</param>
        /// <returns>The created graph</returns>
        private NetGraph CreateNetGraph(NetGraphFactory factory, MetaDictionary meta, PropertyBag properties)
        {
            NetGraph g = factory == null?_factory.Create(_logger, null, _globalMeta, meta, properties) : factory.Create(_logger, null, _globalMeta, meta, properties);

            if (g != null)
            {
                g.LogPacketEvent  += new EventHandler <LogPacketEventArgs>(log_AddLogPacket);
                g.EditPacketEvent += new EventHandler <EditPacketEventArgs>(edit_InputReceived);
                g.GraphShutdown   += new EventHandler(graph_GraphShutdown);

                // Add service to provider
                g.ServiceProvider.RegisterService(typeof(ProxyNetworkService), this);
                g.ServiceProvider.RegisterService(typeof(CredentialsManagerService), _credentialManager);
            }

            return(g);
        }
示例#3
0
        /// <summary>
        /// Create the test graph container
        /// </summary>
        /// <param name="logger">The logger to use</param>
        /// <param name="globals">Global meta</param>
        /// <returns>The new test graph container</returns>
        public override TestDocument.TestGraphContainer CreateTestGraph(Utils.Logger logger, MetaDictionary globals)
        {
            NetGraphFactory factory = _document.Factory;

            ClientEndpointFactory[] clients = factory.GetNodes <ClientEndpointFactory>();
            ServerEndpointFactory[] servers = factory.GetNodes <ServerEndpointFactory>();

            if ((clients.Length == 0) || (servers.Length == 0))
            {
                throw new ArgumentException("Graph must have a one client and one server endpoint to perform a test");
            }

            Guid inputNode  = _clientToServer ? clients[0].Id : servers[0].Id;
            Guid outputNode = _clientToServer ? servers[0].Id : clients[0].Id;

            NetGraph graph = factory.Create(logger, null, globals, new MetaDictionary(), new PropertyBag("Connection"));

            return(new TestDocument.TestGraphContainer(graph, graph.Nodes[inputNode], graph.Nodes[outputNode]));
        }
示例#4
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="name">Name of the factory</param>
        /// <param name="factory">Factory</param>
        /// <param name="direction">Direction of graph</param>
        /// <param name="containerGraph">The parent graph</param>
        /// <param name="logger">The logger to use</param>
        /// <param name="stateDictionary">Forwarded state dictionary</param>
        /// <param name="linked">If true then we are creating a linked master node</param>
        public NetGraphContainerNode(string name, NetGraphFactory factory,
                                     GraphDirection direction, NetGraph containerGraph, Logger logger,
                                     Dictionary <string, object> stateDictionary, bool linked)
        {
            var clients = factory.GetNodes <ClientEndpointFactory>();
            var servers = factory.GetNodes <ServerEndpointFactory>();

            if ((clients.Length > 0) && (servers.Length > 0))
            {
                Guid outputNode = direction == GraphDirection.ClientToServer
                    ? servers[0].Id : clients[0].Id;
                Guid inputNode = direction == GraphDirection.ClientToServer
                    ? clients[0].Id : servers[0].Id;

                if (linked)
                {
                    _graph = factory.Create(name, logger, containerGraph, containerGraph.GlobalMeta,
                                            containerGraph.Meta, containerGraph.ConnectionProperties);
                }
                else
                {
                    _graph = factory.CreateFiltered(name, logger, containerGraph, containerGraph.GlobalMeta,
                                                    containerGraph.Meta, inputNode, containerGraph.ConnectionProperties, stateDictionary);
                }

                _graph.BindEndpoint(outputNode, new EventDataAdapter(this));

                _inputNode        = (PipelineEndpoint)_graph.Nodes[inputNode];
                _inputNode.Hidden = true;

                _outputNode        = (PipelineEndpoint)_graph.Nodes[outputNode];
                _outputNode.Hidden = true;
            }
            else
            {
                throw new ArgumentException(CANAPE.Properties.Resources.NetGraphContainerNode_InvalidGraph);
            }
        }
示例#5
0
        /// <summary>
        /// Create the netgraph for a connection
        /// </summary>
        /// <param name="factory">The netgraph factory</param>
        /// <param name="meta">Current meta data</param>
        /// <param name="properties">Property bag</param>
        /// <returns>The created graph</returns>
        private NetGraph CreateNetGraph(NetGraphFactory factory, MetaDictionary meta, PropertyBag properties)
        {
            NetGraph g = factory == null ? _factory.Create(_logger, null, _globalMeta, meta, properties) : factory.Create(_logger, null, _globalMeta, meta, properties);
            if (g != null)
            {
                g.LogPacketEvent += new EventHandler<LogPacketEventArgs>(log_AddLogPacket);
                g.EditPacketEvent += new EventHandler<EditPacketEventArgs>(edit_InputReceived);
                g.GraphShutdown += new EventHandler(graph_GraphShutdown);

                // Add service to provider
                g.ServiceProvider.RegisterService(typeof(ProxyNetworkService), this);
                g.ServiceProvider.RegisterService(typeof(CredentialsManagerService), _credentialManager);
            }

            return g;
        }
示例#6
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="name">Name of the factory</param>
        /// <param name="factory">Factory</param>
        /// <param name="direction">Direction of graph</param>        
        /// <param name="containerGraph">The parent graph</param>
        /// <param name="logger">The logger to use</param>
        /// <param name="stateDictionary">Forwarded state dictionary</param>
        /// <param name="linked">If true then we are creating a linked master node</param>
        public NetGraphContainerNode(string name, NetGraphFactory factory,  
            GraphDirection direction, NetGraph containerGraph, Logger logger, 
            Dictionary<string, object> stateDictionary, bool linked)
        {
            var clients = factory.GetNodes<ClientEndpointFactory>();
            var servers = factory.GetNodes<ServerEndpointFactory>();

            if ((clients.Length > 0) && (servers.Length > 0))
            {
                Guid outputNode = direction == GraphDirection.ClientToServer
                    ? servers[0].Id : clients[0].Id;
                Guid inputNode = direction == GraphDirection.ClientToServer
                    ? clients[0].Id : servers[0].Id;

                if (linked)
                {
                    _graph = factory.Create(name, logger, containerGraph, containerGraph.GlobalMeta,
                        containerGraph.Meta, containerGraph.ConnectionProperties);
                }
                else
                {
                    _graph = factory.CreateFiltered(name, logger, containerGraph, containerGraph.GlobalMeta,
                        containerGraph.Meta, inputNode, containerGraph.ConnectionProperties, stateDictionary);
                }

                _graph.BindEndpoint(outputNode, new EventDataAdapter(this));

                _inputNode = (PipelineEndpoint)_graph.Nodes[inputNode];
                _inputNode.Hidden = true;

                _outputNode = (PipelineEndpoint)_graph.Nodes[outputNode];
                _outputNode.Hidden = true;
            }
            else
            {
                throw new ArgumentException(CANAPE.Properties.Resources.NetGraphContainerNode_InvalidGraph);
            }
        }