Exemple #1
0
        public static IEntry ToEntry(this FolderInfoResult data, Link ulink, string origPath)
        {
            MailRuCloud.ItemType itemType;
            if (null == ulink)
            {
                itemType = data.body.home == origPath
                                        ? MailRuCloud.ItemType.Folder
                                        : MailRuCloud.ItemType.File;
            }
            else
            {
                itemType = ulink.ItemType;
            }


            var entry = itemType == MailRuCloud.ItemType.File
                                ? (IEntry)data.ToFile(
                home: WebDavPath.Parent(origPath),
                ulink: ulink,
                filename: ulink == null ? WebDavPath.Name(origPath) : ulink.OriginalName,
                nameReplacement: WebDavPath.Name(origPath))
                                : data.ToFolder(origPath, ulink);

            return(entry);
        }
Exemple #2
0
        public static IEntry ToEntry(this FolderInfoResult data)
        {
            if (data.body.kind == "file")
            {
                var file = data.ToFile();
                return(file);
            }

            var folder = new Folder(data.body.size, WebDavPath.Combine(data.body.home ?? WebDavPath.Root, data.body.name))
            {
                Folders = data.body.list?
                          .Where(it => FolderKinds.Contains(it.kind))
                          .Select(item => item.ToFolder())
                          .ToList(),
                Files = data.body.list?
                        .Where(it => it.kind == "file")
                        .Select(item => item.ToFile())
                        .ToGroupedFiles()
                        .ToList()
            };


            return(folder);
        }
Exemple #3
0
        public static IEntry ToEntry(this FolderInfoResult data, string publicBaseUrl)
        {
            if (data.Body.Kind == "file")
            {
                var file = data.ToFile(publicBaseUrl);
                return(file);
            }

            var folder = new Folder(data.Body.Size, WebDavPath.Combine(data.Body.Home ?? WebDavPath.Root, data.Body.Name))
            {
                Folders = data.Body.List?
                          .Where(it => FolderKinds.Contains(it.Kind))
                          .Select(item => item.ToFolder(publicBaseUrl))
                          .ToList(),
                Files = data.Body.List?
                        .Where(it => it.Kind == "file")
                        .Select(item => item.ToFile(publicBaseUrl, ""))
                        .ToGroupedFiles()
                        .ToList()
            };


            return(folder);
        }