public override ICloudFileSystemEntry RequestResource(IStorageProviderSession session, string name, ICloudDirectoryEntry parent) { var path = DropBoxResourceIDHelpers.GetResourcePath(parent, name); var uriString = GetResourceUrlInternal(session, path); int code; var res = DropBoxRequestParser.RequestResourceByUrl(uriString, this, session, out code); if (res.Length == 0) { if (code != (int)HttpStatusCode.OK) { throw new SharpBoxException( code == (int)HttpStatusCode.NotFound ? SharpBoxErrorCodes.ErrorFileNotFound : SharpBoxErrorCodes.ErrorCouldNotRetrieveDirectoryList, new HttpException(Convert.ToInt32(code), "HTTP Error")); } throw new SharpBoxException(SharpBoxErrorCodes.ErrorCouldNotRetrieveDirectoryList); } // build the entry and subchilds var entry = DropBoxRequestParser.CreateObjectsFromJsonString(res, this, session); var hash = entry.GetPropertyValue("hash"); if (!string.IsNullOrEmpty(hash)) { DropBoxRequestParser.Addhash(uriString, hash, res, session); } // check if it was a deleted file if (entry.IsDeleted) { return(null); } // set the parent if (parent is BaseDirectoryEntry && parent.Id.Equals(entry.ParentID)) { (parent as BaseDirectoryEntry).AddChild(entry); } return(entry); }
public override void RefreshResource(IStorageProviderSession session, ICloudFileSystemEntry resource) { var path = GetResourceUrlInternal(session, DropBoxResourceIDHelpers.GetResourcePath(resource)); int code; var res = DropBoxRequestParser.RequestResourceByUrl(path, this, session, out code); if (res.Length == 0) { throw new SharpBoxException(SharpBoxErrorCodes.ErrorCouldNotRetrieveDirectoryList); } // build the entry and subchilds DropBoxRequestParser.UpdateObjectFromJsonString(res, resource as BaseFileEntry, this, session); var hash = resource.GetPropertyValue("hash"); if (!string.IsNullOrEmpty(hash)) { DropBoxRequestParser.Addhash(path, hash, res, session); } }