コード例 #1
0
 private void RouterAddCommand_Executed(object sender, ExecutedRoutedEventArgs e)
 {
     RouterController.Add();
 }
コード例 #2
0
        private void ReadRouter(XmlReader reader)
        {
            if (reader.IsEmptyElement)
            {
                return;
            }

            bool   loop = true;
            string name = null;

            // Router
            Entity                 entity  = new Entity();
            ServerComponent        server  = new ServerComponent();
            ServerOptionsComponent options = new ServerOptionsComponent();
            ServerListComponent    servers = new ServerListComponent();

            server.Enabled = bool.Parse(reader.GetAttribute(XmlTag.Enabled));

            while (loop && reader.Read())
            {
                switch (reader.NodeType)
                {
                case XmlNodeType.Element:
                {
                    name = reader.Name;

                    switch (name)
                    {
                    case XmlTag.Servers:
                    {
                        ReadServers(reader, ref servers);
                        break;
                    }

                    case XmlTag.Options:
                    {
                        ReadOptions(reader, ref options);
                        break;
                    }
                    }

                    break;
                }

                case XmlNodeType.Text:
                {
                    switch (name)
                    {
                    case XmlTag.Id:
                    {
                        entity.Id = reader.Value;
                        break;
                    }

                    case XmlTag.Name:
                    {
                        server.Name = reader.Value;
                        break;
                    }

                    case XmlTag.Passphrase:
                    {
                        server.Passphrase = reader.Value;
                        break;
                    }

                    case XmlTag.Address:
                    {
                        server.Address = reader.Value;
                        break;
                    }

                    case XmlTag.Port:
                    {
                        server.Port = int.Parse(reader.Value);
                        break;
                    }
                    }

                    break;
                }

                case XmlNodeType.EndElement:
                {
                    if (XmlTag.Router.Equals(reader.Name))
                    {
                        loop = false;
                    }

                    break;
                }
                }
            }

            // Router
            entity.Add(server);
            entity.Add(options);
            entity.Add(servers);

            ServerStatusComponent status = new ServerStatusComponent();

            entity.Add(status);

            MachineComponent machine = new RouterMachineComponent();

            entity.Add(machine);

            EntityMapComponent entities = new EntityMapComponent();

            entity.Add(entities);

            SessionMapComponent sessions = new SessionMapComponent();

            entity.Add(sessions);

            GroupListMapComponent groups = new GroupListMapComponent();

            entity.Add(groups);

            ClientMapComponent clients = new ClientMapComponent();

            entity.Add(clients);

            TransferMapComponent transfers = new TransferMapComponent();

            entity.Add(transfers);
#if DEBUG
            LogComponent log = new LogComponent(LogController);
            entity.Add(log);
#endif
            RouterController.Add(entity);
        }