Ejemplo n.º 1
0
 public FileInterface(ItemInterface item) : base(item.GoogleDriveFile, item.GDrive)
 {
     if (item.IsFolder())
     {
         throw new ArgumentException("item represents a folder!", "item");
     }
 }
Ejemplo n.º 2
0
 public DirectoryInterface(ItemInterface item) : base(item.GoogleDriveFile, item.GDrive)
 {
     if (!item.IsFolder())
     {
         throw new ArgumentException("item doesn't represent a folder!", "item");
     }
 }
Ejemplo n.º 3
0
        public ItemInterface FindItemFromPath(string fullPath, bool rootFirst = true)
        {
            fullPath = PathNormalizer.Normalize(fullPath);
            string[] items = PathNormalizer.Normalize(fullPath).Split("/");
            //Page page = this.RunQueryAsPage($"name = '{items[0]}'");
            ItemInterface current =
                rootFirst ? this.GetFileById("root") : this.GetFileById(this.FindID(items[0]).ID);

            for (int i = 1; i < items.Length; i++)
            {
                string item   = items[i];
                var    result = this.GetDirectoryContent(current.ItemIdentifier);
                foreach (var resultFile in result.Items)
                {
                    if (resultFile.Name == item)
                    {
                        current = resultFile;
                        break;
                    }
                }
            }

            string check = current.GetFullName();
            bool   equal = check == fullPath;

            if (!equal)
            {
                return(null);
            }

            return(current);
        }
Ejemplo n.º 4
0
        public ItemInterface FindParent(ItemInterface child)
        {
            if (child.GoogleDriveFile.Parents == null ||
                child.GoogleDriveFile.Parents.Count == 0 ||
                child.GoogleDriveFile.Parents[0] == null)
            {
                return(null);
            }

            string id     = child.GoogleDriveFile.Parents[0];
            var    parent = GetFileById(id);

            return(parent);
        }
Ejemplo n.º 5
0
        public string GetFullName()
        {
            if (!String.IsNullOrEmpty(fullName))
            {
                return(fullName);
            }

            ItemInterface item = this;

            while (item != null)
            {
                fullName = item.Name + (string.IsNullOrEmpty(fullName) ? String.Empty : "\\") + fullName;
                item     = item.GetParent();
            }

            return(Multisync.App.Util.PathNormalizer.Normalize(fullName));
        }
Ejemplo n.º 6
0
        public Page RunQueryAsPage(string query, int pageSize = 100, string pageToken = null)
        {
            FileList list = RunQuery(query, pageSize, pageToken);

            List <ItemInterface> files = new List <ItemInterface>();

            foreach (DriveFile dfile in list.Files)
            {
                ItemInterface IFile = new ItemInterface(dfile, this);
                files.Add(IFile);
            }

            Page page = new Page(pageToken, list.NextPageToken, files.ToArray());

            page.SearchQuery    = query;
            page.MaxAllowedSize = pageSize;
            return(page);
        }