private void PopulateChildren(IEnumerable<object> children) { foreach (dynamic child in children) { SkyDriveObject skyDriveObject = null; if (child.type == "folder") { skyDriveObject = new SkyDriveFolder(this, child, null); } else if (child.type == "file") { skyDriveObject = new SkyDriveFile(this, child); } else if (child.type == "photo") { skyDriveObject = new SkyDrivePhoto(this, child); } else if (child.type == "album") { skyDriveObject = new SkyDriveAlbum(this, child, null); } else if (child.type == "audio") { skyDriveObject = new SkyDriveAudio(this, child); } if(skyDriveObject != null) this._children.Add(skyDriveObject); } }
private void PopulateChildren(IEnumerable <object> children) { foreach (dynamic child in children) { SkyDriveObject skyDriveObject = null; if (child.type == "folder") { skyDriveObject = new SkyDriveFolder(this, child, null); } else if (child.type == "file") { skyDriveObject = new SkyDriveFile(this, child); } else if (child.type == "photo") { skyDriveObject = new SkyDrivePhoto(this, child); } else if (child.type == "album") { skyDriveObject = new SkyDriveAlbum(this, child, null); } else if (child.type == "audio") { skyDriveObject = new SkyDriveAudio(this, child); } if (skyDriveObject != null) { this._children.Add(skyDriveObject); } } }
private async Task<ICloudObject> _GetCloudObjectFromSkyDriveObjectIdAsync(string skyDriveObjectId, bool fetchChildren = true) { ICloudObject cloudObject = null; //TODO: Validate if session requires renewal. Skydrive does not supports unique paths with sub directories. //do some recursive calls to construct sub directory paths with some caching so that the path can be optimized. //do make sure that the path exists aka is not deleted or moved. LiveOperationResult operationResult = await _liveClient.GetAsync(skyDriveObjectId); dynamic result = operationResult.Result; ICloudFolder parent = FindParent(_rootCloudObject, result.id); if (result.type == "folder") { if (fetchChildren) { LiveOperationResult childrenResult = await _liveClient.GetAsync(skyDriveObjectId + "/files"); cloudObject = new SkyDriveFolder(parent, result, ((dynamic)childrenResult.Result).data); } else { cloudObject = new SkyDriveFolder(parent, result, null); } } else if (result.type == "album") { if (fetchChildren) { LiveOperationResult childrenResult = await _liveClient.GetAsync(skyDriveObjectId + "/files"); cloudObject = new SkyDriveAlbum(parent, result, ((dynamic)childrenResult.Result).data); } else { cloudObject = new SkyDriveAlbum(parent, result, null); } } else if (result.type == "file") { cloudObject = new SkyDriveFile(parent, result); } else if (result.type == "photo") { cloudObject = new SkyDrivePhoto(parent, result); } //Replace the oldChildRef with the new ref. We need to do it everytime to keep the offline cache updated. if (cloudObject != null && parent != null) { ICloudObject oldChildRef = parent.Children.FirstOrDefault(obj => obj.Id == cloudObject.Id); if (oldChildRef != null) { int index = parent.Children.IndexOf(oldChildRef); parent.Children.Remove(oldChildRef); parent.Children.Insert(index, cloudObject); } } return cloudObject; }