示例#1
0
        public void Add(ClientComponent client, ServerComponent server, GroupComponent group)
        {
            Entity entity = new Entity();

            entity.Add(client);

            ClientOptionsComponent options = new ClientOptionsComponent();

            entity.Add(options);

            entity.Add(server);

            entity.Add(group);

            FolderListComponent folderList = new FolderListComponent();

            entity.Add(folderList);

            FileMapComponent fileMap = new FileMapComponent();

            entity.Add(fileMap);

            FolderMapComponent folderMap = new FolderMapComponent();

            entity.Add(folderMap);

            ClientMachineComponent machine = new ClientMachineComponent();

            entity.Add <MachineComponent>(machine);

            SessionComponent session = new SessionComponent();

            entity.Add(session);

            FileComponent file = new FileComponent();

            entity.Add(file);

            SearchListComponent search = new SearchListComponent(SearchController.Dispatcher);

            entity.Add(search);

            BrowseComponent browse = new BrowseComponent();

            entity.Add(browse);

            DownloadListComponent download = new DownloadListComponent(DownloadController.Dispatcher);

            entity.Add(download);

            UploadListComponent upload = new UploadListComponent(UploadController.Dispatcher);

            entity.Add(upload);
#if DEBUG
            LogComponent log = new LogComponent(LogController);
            entity.Add(log);
#endif
            Add(entity);
        }
示例#2
0
        private void ReadClient(XmlReader reader)
        {
            if (reader.IsEmptyElement)
            {
                return;
            }

            bool   loop = true;
            string name = null;

            // Components
            Entity                 entity  = new Entity();
            ClientComponent        client  = new ClientComponent();
            ClientOptionsComponent options = new ClientOptionsComponent();

            GroupComponent  group  = new GroupComponent();
            ServerComponent server = new ServerComponent();
            List <string>   paths  = new List <string>();

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

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

                    switch (name)
                    {
                    case XmlTag.Router:
                    {
                        ReadRouter(reader, ref server);
                        break;
                    }

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

                    case XmlTag.Folders:
                    {
                        ReadFolders(reader, ref paths);
                        break;
                    }
                    }

                    break;
                }

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

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

                    case XmlTag.Download:
                    {
                        client.Download = reader.Value;
                        break;
                    }

                    case XmlTag.Group:
                    {
                        group.Path = reader.Value;
                        break;
                    }
                    }

                    break;
                }

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

                    break;
                }
                }
            }

            // Components
            entity.Add(client);
            entity.Add(options);
            entity.Add(group);
            entity.Add(server);

            FolderListComponent folderList = new FolderListComponent();

            entity.Add(folderList);

            FileMapComponent fileMap = new FileMapComponent();

            entity.Add(fileMap);

            FolderMapComponent folderMap = new FolderMapComponent();

            entity.Add(folderMap);

            ClientMachineComponent machine = new ClientMachineComponent();

            entity.Add <MachineComponent>(machine);

            SessionComponent session = new SessionComponent();

            entity.Add(session);

            FileComponent file = new FileComponent();

            entity.Add(file);

            SearchListComponent search = new SearchListComponent(SearchController.Dispatcher);

            entity.Add(search);

            BrowseComponent browse = new BrowseComponent();

            entity.Add(browse);

            DownloadListComponent download = new DownloadListComponent(DownloadController.Dispatcher);

            entity.Add(download);

            UploadListComponent upload = new UploadListComponent(UploadController.Dispatcher);

            entity.Add(upload);
#if DEBUG
            LogComponent log = new LogComponent(LogController);
            entity.Add(log);
#endif
            ClientController.Add(entity);

            foreach (string path in paths)
            {
                FileComponent shared = new FileComponent(path)
                {
                    Owner = entity
                };
                folderList.Add(shared);
            }
        }