public override async Task <IEntryModel> CreateAsync(string fullPath, bool isDirectory, CancellationToken ct) { if (isDirectory) { await _profile.checkLoginAsync(); string parentPath = _profile.Path.GetDirectoryName(fullPath); string name = _profile.Path.GetFileName(fullPath); SkyDriveItemModel parentDir = await _profile.ParseAsync(parentPath) as SkyDriveItemModel; if (parentDir == null) { throw new DirectoryNotFoundException(parentPath); } var folderData = new Dictionary <string, object>(); folderData.Add("name", name); LiveConnectClient liveClient = new LiveConnectClient(_profile.Session); ct.ThrowIfCancellationRequested(); LiveOperationResult result = await liveClient.PostAsync(parentDir.UniqueId, folderData, ct); ct.ThrowIfCancellationRequested(); return(new SkyDriveItemModel(_profile, result.Result, parentDir.FullPath)); } else { return(new SkyDriveItemModel(Profile as SkyDriveProfile, fullPath, false)); } }
public override async Task <IList <IEntryModel> > ListAsync(IEntryModel entry, CancellationToken ct, Func <IEntryModel, bool> filter = null, bool refresh = false) { await checkLoginAsync(); if (filter == null) { filter = e => true; } List <IEntryModel> retList = new List <IEntryModel>(); List <SkyDriveItemModel> cacheList = new List <SkyDriveItemModel>(); SkyDriveItemModel dirModel = entry as SkyDriveItemModel; if (dirModel != null) { if (!refresh) { var cachedChild = ModelCache.GetChildModel(dirModel); if (cachedChild != null) { return(cachedChild.Where(m => filter(m)).Cast <IEntryModel>().ToList()); } } LiveConnectClient client = new LiveConnectClient(Session); LiveOperationResult listOpResult = await client.GetAsync(dirModel.UniqueId + "/files", ct); if (ct.IsCancellationRequested) { return(retList); } dynamic listResult = listOpResult.Result; foreach (dynamic itemData in listResult.data) { SkyDriveItemModel retVal = null; retVal = new SkyDriveItemModel(this, itemData, dirModel.FullPath); if (retVal != null) { cacheList.Add(ModelCache.RegisterModel(retVal)); if (filter(retVal)) { retList.Add(retVal); } } } ModelCache.RegisterChildModels(dirModel, cacheList.ToArray()); } return(retList); }
public override IEnumerable <IModelIconExtractor <IEntryModel> > GetIconExtractSequence(IEntryModel entry) { foreach (var extractor in base.GetIconExtractSequence(entry)) { yield return(extractor); } SkyDriveItemModel model = entry as SkyDriveItemModel; if (model.ImageUrl != null) { yield return(new GetUriIcon(e => new Uri((e as SkyDriveItemModel).ImageUrl))); } else { //if (model.Name.IndexOf('.') != -1) yield return(GetFromSystemImageListUsingExtension.Instance); } if (model.FullPath == Alias) { yield return(EntryModelIconExtractors.ProvideValue(ProfileIcon)); } }