コード例 #1
0
        /// <summary>
        /// Guild the default graph factory
        /// </summary>
        /// <returns>The graph factory</returns>
        protected static NetGraphFactory BuildDefaultProxyFactory()
        {
            NetGraphBuilder       builder = new NetGraphBuilder();
            ServerEndpointFactory server  = builder.AddServer("SERVER", Guid.NewGuid());
            ClientEndpointFactory client  = builder.AddClient("CLIENT", Guid.NewGuid());
            LogPacketNodeFactory  logOut  = builder.AddLog("LOGOUT", Guid.NewGuid(), new ColorValue(0xFF, 0xC0, 0xCB, 0xFF), "Out", false);
            LogPacketNodeFactory  logIn   = builder.AddLog("LOGIN", Guid.NewGuid(), new ColorValue(0xB0, 0xE0, 0xE6, 0xFF), "In", false);

            builder.AddLine(server, logOut, null);
            builder.AddLine(logOut, client, null);
            builder.AddLine(client, logIn, null);
            builder.AddLine(logIn, server, null);

            return(builder.Factory);
        }
コード例 #2
0
        private void AddStateFromEntry(NetGraphBuilder builder, StateGraphEntry entry, BaseNodeFactory inputNode, BaseNodeFactory outputNode, bool clientToServer)
        {
            BaseNodeFactory currentFactory;

            if (entry.Graph != null)
            {
                currentFactory = builder.AddNode(new NetGraphContainerNodeFactory(String.Format("{0} {1}", entry.StateName,
                                                                                                GetDirection(clientToServer)), Guid.NewGuid(), entry.Graph.Factory,
                                                                                  clientToServer ? NetGraphContainerNode.GraphDirection.ClientToServer : NetGraphContainerNode.GraphDirection.ServerToClient));
                currentFactory.Hidden = true;

                builder.AddLine(inputNode, currentFactory, entry.StateName);
            }
            else
            {
                currentFactory = inputNode;
            }

            if (entry.LogPackets)
            {
                LogPacketNodeFactory log = builder.AddLog(String.Format("{0} Log {1}", entry.StateName, GetDirection(clientToServer)),
                                                          Guid.NewGuid(), entry.Color, null, false);
                log.Hidden = true;

                builder.AddLine(currentFactory, log, null);

                currentFactory = log;
            }

            builder.AddLine(currentFactory, outputNode, null);
        }
コード例 #3
0
        private LogPacketNodeFactory AddLog(NetGraphBuilder builder, StateGraphEntry entry, BaseNodeFactory currentFactory, bool clientToServer)
        {
            LogPacketNodeFactory log = builder.AddLog(String.Format("{0} Log {1}", entry.StateName,
                                                                    GetDirection(clientToServer)), Guid.NewGuid(), entry.Color, null, false);

            log.Hidden = true;

            builder.AddLine(currentFactory, log, null);

            return(log);
        }
コード例 #4
0
        private SwitchNodeFactory CreateBaseGraph(NetGraphBuilder builder, BaseNodeFactory inputNode, BaseNodeFactory outputNode, bool clientToServer)
        {
            SwitchNodeFactory switchNode = builder.AddNode(new SwitchNodeFactory(String.Format("{0} Switch {1}",
                                                                                               _metaName, GetDirection(clientToServer)), Guid.NewGuid(),
                                                                                 false, CANAPE.Nodes.SwitchNodeSelectionMode.ExactMatch));

            switchNode.Hidden        = true;
            switchNode.SelectionPath = "#" + (String.IsNullOrWhiteSpace(_metaName) ? "Invalid" : _metaName.Trim());

            builder.AddLine(inputNode, switchNode, null);

            LogPacketNodeFactory log = builder.AddLog(String.Format("Invalid Traffic {0}", GetDirection(clientToServer)),
                                                      Guid.NewGuid(), new ColorValue(255, 0, 0), null, false);

            log.Hidden = true;
            builder.AddLine(switchNode, log, null);
            builder.AddLine(log, outputNode, null);

            return(switchNode);
        }
コード例 #5
0
        /// <summary>
        /// Create the test graph
        /// </summary>
        /// <param name="logger">The logger to use</param>
        /// <param name="globals">The global meta</param>
        /// <returns>The new test graph container</returns>
        /// <exception cref="ArgumentException">Throw if script invalid</exception>
        public override TestGraphContainer CreateTestGraph(Logger logger, MetaDictionary globals)
        {
            if (String.IsNullOrWhiteSpace(_config.ClassName))
            {
                throw new ArgumentException(CANAPE.Documents.Properties.Resources.ScriptTestDocument_MustProvideClassname);
            }

            NetGraphBuilder       builder = new NetGraphBuilder();
            ServerEndpointFactory server  = builder.AddServer("server", Guid.NewGuid());
            DynamicNodeFactory    node    = builder.AddNode((DynamicNodeFactory)_config.CreateFactory());
            LogPacketNodeFactory  log     = builder.AddLog("Test Network", Guid.NewGuid(), new ColorValue(0xFF, 0xFF, 0xFF, 0xFF), "Entry", false);
            ClientEndpointFactory client  = builder.AddClient("client", Guid.NewGuid());

            builder.AddLine(server, node, null);
            builder.AddLine(node, log, null);
            builder.AddLine(log, client, null);

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

            return(new TestGraphContainer(graph, graph.Nodes[server.Id], graph.Nodes[client.Id]));
        }
コード例 #6
0
ファイル: StateGraphDocument.cs プロジェクト: michyer/canape
        private SwitchNodeFactory CreateBaseGraph(NetGraphBuilder builder, BaseNodeFactory inputNode, BaseNodeFactory outputNode, bool clientToServer)
        {
            SwitchNodeFactory switchNode = builder.AddNode(new SwitchNodeFactory(String.Format("{0} Switch {1}",
                _metaName, GetDirection(clientToServer)), Guid.NewGuid(),
                false, CANAPE.Nodes.SwitchNodeSelectionMode.ExactMatch));
            switchNode.Hidden = true;
            switchNode.SelectionPath = "#" + (String.IsNullOrWhiteSpace(_metaName) ? "Invalid" : _metaName.Trim());

            builder.AddLine(inputNode, switchNode, null);

            LogPacketNodeFactory log = builder.AddLog(String.Format("Invalid Traffic {0}", GetDirection(clientToServer)),
                    Guid.NewGuid(), new ColorValue(255, 0, 0), null, false);

            log.Hidden = true;
            builder.AddLine(switchNode, log, null);
            builder.AddLine(log, outputNode, null);

            return switchNode;
        }
コード例 #7
0
ファイル: StateGraphDocument.cs プロジェクト: michyer/canape
        private void AddStateFromEntry(NetGraphBuilder builder, StateGraphEntry entry, BaseNodeFactory inputNode, BaseNodeFactory outputNode, bool clientToServer)
        {
            BaseNodeFactory currentFactory;

            if (entry.Graph != null)
            {
                currentFactory = builder.AddNode(new NetGraphContainerNodeFactory(String.Format("{0} {1}", entry.StateName,
                    GetDirection(clientToServer)), Guid.NewGuid(), entry.Graph.Factory,
                    clientToServer ? NetGraphContainerNode.GraphDirection.ClientToServer : NetGraphContainerNode.GraphDirection.ServerToClient));
                currentFactory.Hidden = true;

                builder.AddLine(inputNode, currentFactory, entry.StateName);
            }
            else
            {
                currentFactory = inputNode;
            }

            if (entry.LogPackets)
            {
                LogPacketNodeFactory log = builder.AddLog(String.Format("{0} Log {1}", entry.StateName, GetDirection(clientToServer)),
                    Guid.NewGuid(), entry.Color, null, false);
                log.Hidden = true;

                builder.AddLine(currentFactory, log, null);

                currentFactory = log;
            }

            builder.AddLine(currentFactory, outputNode, null);
        }
コード例 #8
0
ファイル: StateGraphDocument.cs プロジェクト: michyer/canape
        private LogPacketNodeFactory AddLog(NetGraphBuilder builder, StateGraphEntry entry, BaseNodeFactory currentFactory, bool clientToServer)
        {
            LogPacketNodeFactory log = builder.AddLog(String.Format("{0} Log {1}", entry.StateName,
                GetDirection(clientToServer)), Guid.NewGuid(), entry.Color, null, false);
            log.Hidden = true;

            builder.AddLine(currentFactory, log, null);

            return log;
        }
コード例 #9
0
ファイル: ScriptTestDocument.cs プロジェクト: michyer/canape
        /// <summary>
        /// Create the test graph
        /// </summary>
        /// <param name="logger">The logger to use</param>
        /// <param name="globals">The global meta</param>
        /// <returns>The new test graph container</returns>
        /// <exception cref="ArgumentException">Throw if script invalid</exception>
        public override TestGraphContainer CreateTestGraph(Logger logger, MetaDictionary globals)
        {
            if (String.IsNullOrWhiteSpace(_config.ClassName))
            {
                throw new ArgumentException(CANAPE.Documents.Properties.Resources.ScriptTestDocument_MustProvideClassname);
            }

            NetGraphBuilder builder = new NetGraphBuilder();
            ServerEndpointFactory server = builder.AddServer("server", Guid.NewGuid());
            DynamicNodeFactory node = builder.AddNode((DynamicNodeFactory)_config.CreateFactory());
            LogPacketNodeFactory log = builder.AddLog("Test Network", Guid.NewGuid(), new ColorValue(0xFF, 0xFF, 0xFF, 0xFF), "Entry", false);
            ClientEndpointFactory client = builder.AddClient("client", Guid.NewGuid());

            builder.AddLine(server, node, null);
            builder.AddLine(node, log, null);
            builder.AddLine(log, client, null);

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

            return new TestGraphContainer(graph, graph.Nodes[server.Id], graph.Nodes[client.Id]);
        }