public override string GetResourceUrl(IStorageProviderSession session, ICloudFileSystemEntry fileSystemEntry, string additionalPath) { var id = SkyDriveHelpers.GetResourceID(additionalPath); if (!String.IsNullOrEmpty(id) || additionalPath != null && additionalPath.Equals("/")) { return("/" + id); } if (String.IsNullOrEmpty(additionalPath) && fileSystemEntry != null) { return("/" + (!fileSystemEntry.Id.Equals("/") ? fileSystemEntry.Id : "")); } return(base.GetResourceUrl(session, fileSystemEntry, additionalPath)); }
public override ICloudFileSystemEntry RequestResource(IStorageProviderSession session, String nameOrID, ICloudDirectoryEntry parent) { /* In this method name could be either requested resource name or it's ID. * In first case just refresh the parent and then search child with an appropriate. * In second case it does not matter if parent is null or not a parent because we use only resource ID. */ if (SkyDriveHelpers.HasResourceID(nameOrID) || nameOrID.Equals("/") && parent == null) //If request by ID or root folder requested { var id = SkyDriveHelpers.GetResourceID(nameOrID); var uri = id != String.Empty ? String.Format("{0}/{1}", SkyDriveConstants.BaseAccessUrl, id) : SkyDriveConstants.RootAccessUrl; if (SkyDriveHelpers.IsFolderID(id)) { var contents = new List <ICloudFileSystemEntry>(); BaseDirectoryEntry entry = null; /*var completeContent = new AutoResetEvent(false); * ThreadPool.QueueUserWorkItem(state => * { * contents.AddRange(RequestContentByUrl(session, uri + "/files")); * ((AutoResetEvent) state).Set(); * }, completeContent); * * var completeEntry = new AutoResetEvent(false); * ThreadPool.QueueUserWorkItem(state => * { * entry = RequestResourseByUrl(session, uri) as BaseDirectoryEntry; * ((AutoResetEvent) state).Set(); * }, completeEntry); * * WaitHandle.WaitAll(new WaitHandle[] {completeContent, completeEntry});*/ entry = RequestResourseByUrl(session, uri) as BaseDirectoryEntry; contents.AddRange(RequestContentByUrl(session, uri + "/files")); if (entry != null && contents.Any()) { entry.AddChilds(contents.Cast <BaseFileEntry>()); } return(entry); } return(RequestResourseByUrl(session, uri)); } else { String uri; if (SkyDriveHelpers.HasParentID(nameOrID)) { uri = String.Format(SkyDriveConstants.FilesAccessUrlFormat, SkyDriveHelpers.GetParentID(nameOrID)); } else if (parent != null) { uri = String.Format(SkyDriveConstants.FilesAccessUrlFormat, parent.GetPropertyValue(SkyDriveConstants.InnerIDKey)); } else { uri = SkyDriveConstants.RootAccessUrl + "/files"; } nameOrID = Path.GetFileName(nameOrID); var entry = RequestContentByUrl(session, uri).FirstOrDefault(x => x.Name.Equals(nameOrID)); return(entry); } }