示例#1
0
        internal FileTree(IDisk disk, DiskInformation info)
        {
            this.Disk = disk;
            this.Root = new Folder(disk.Index.ToString());

            this.ProcessDirectory(info.files, this.Root as IFolder);
        }
示例#2
0
        internal DiskInformation ToDiskInformation () {
            var result = new DiskInformation {
                                                 index = this.Index.ToString (),
                                                 type = this.Type,
                                                 state = this.State,
                                                 content_type = this.ContentType,
                                                 available = this.Available,
                                                 name = this.Name,
                                                 content = new List <ContentInformation> ()
                                             };

            foreach (var content_item in this.Content) {
                var content = new ContentInformation {
                                                         name = content_item.Name,
                                                         backward = content_item.HasPrev ()
                                                                        ? new LinkedLinkInformation {
                                                                                                        index =
                                                                                                            content_item
                                                                                                            .Prev.Disk.
                                                                                                            Index.
                                                                                                            ToString (),
                                                                                                        name =
                                                                                                            content_item
                                                                                                            .Prev.Name
                                                                                                    }
                                                                        : null,
                                                         forward = content_item.HasNext ()
                                                                       ? new LinkedLinkInformation {
                                                                                                       index =
                                                                                                           content_item.
                                                                                                           Next.Disk.
                                                                                                           Index.
                                                                                                           ToString (),
                                                                                                       name =
                                                                                                           content_item.
                                                                                                           Next.Name
                                                                                                   }
                                                                       : null,
                                                         file_links = new List <LinkInformation> ()
                                                     };

                foreach (var file_link in content_item)
                    content.file_links.Add (new LinkInformation { reference = file_link.Path });

                result.content.Add (content);
            }

            if (this.FileTree != null) {
                result.files = new FolderInformation ();
                this.SaveFolderInformation (result.files, this.FileTree.Root as IFolder);
            }

            return result;
        }
示例#3
0
        internal DiskContent (IDisk disk, DiskInformation info)
            : this (disk) {
            foreach (var item in info.content) {
                var _item = new ContentItem (item.name, disk);

                foreach (var link in item.file_links)
                    _item.Add (link.reference);

                this.items.Add (_item);
            }
        }
示例#4
0
        internal DiskContent(IDisk disk, DiskInformation info)
            : this(disk) {
            foreach (var item in info.content)
            {
                var _item = new ContentItem(item.name, disk);

                foreach (var link in item.file_links)
                {
                    _item.Add(link.reference);
                }

                this.items.Add(_item);
            }
        }
示例#5
0
        internal Disk (DiskInformation info) {
            this.Type = info.type;
            this.State = info.state;
            this.ContentType = info.content_type;
            this.Index = DiskIndex.Parse (info.index);
            this.Available = info.available;
            this.Name = info.name;

            if (info.files != null)
                this.FileTree = new FileTree (this, info);

            if (info.content != null)
                this.Content = new DiskContent (this, info);
        }
示例#6
0
        internal Disk(DiskInformation info)
        {
            this.Type        = info.type;
            this.State       = info.state;
            this.ContentType = info.content_type;
            this.Index       = DiskIndex.Parse(info.index);
            this.Available   = info.available;
            this.Name        = info.name;

            if (info.files != null)
            {
                this.FileTree = new FileTree(this, info);
            }

            if (info.content != null)
            {
                this.Content = new DiskContent(this, info);
            }
        }
示例#7
0
        internal DiskInformation ToDiskInformation()
        {
            var result = new DiskInformation {
                index        = this.Index.ToString(),
                type         = this.Type,
                state        = this.State,
                content_type = this.ContentType,
                available    = this.Available,
                name         = this.Name,
                content      = new List <ContentInformation> ()
            };

            foreach (var content_item in this.Content)
            {
                var content = new ContentInformation {
                    name     = content_item.Name,
                    backward = content_item.HasPrev()
                                                                        ? new LinkedLinkInformation {
                        index =
                            content_item
                            .Prev.Disk.
                            Index.
                            ToString(),
                        name =
                            content_item
                            .Prev.Name
                    }
                                                                        : null,
                    forward = content_item.HasNext()
                                                                       ? new LinkedLinkInformation {
                        index =
                            content_item.
                            Next.Disk.
                            Index.
                            ToString(),
                        name =
                            content_item.
                            Next.Name
                    }
                                                                       : null,
                    file_links = new List <LinkInformation> ()
                };

                foreach (var file_link in content_item)
                {
                    content.file_links.Add(new LinkInformation {
                        reference = file_link.Path
                    });
                }

                result.content.Add(content);
            }

            if (this.FileTree != null)
            {
                result.files = new FolderInformation();
                this.SaveFolderInformation(result.files, this.FileTree.Root as IFolder);
            }

            return(result);
        }