public static async Task <SelectorItem> GetFolder(ICloudDriveService driveService) { try { DriveService = driveService; // INITIATE THE VIEW MODEL var vm = new FolderDialogVM(); // LOCATE ROOT CHILDS var rootChilds = await getChildren(null); vm.Data.AddRange(rootChilds); vm.CurrentItem = null; // HOOK UP EVENT FOR ITEM SELECTION vm.OnItemSelected += async(sender, item) => { try { vm.IsBusy = true; var folderChilds = await getChildren(item); vm.Data.ReplaceRange(folderChilds); vm.CurrentItem = item; } catch (Exception ex) { Console.WriteLine(ex.ToString()); } finally { vm.IsBusy = false; } }; // SHOW DIALOG var folder = await vm.OpenPage(); return(folder); } catch (Exception) { throw; } }
async Task Connection_Connect() { if (string.IsNullOrEmpty(this.SelectedCloundDrive)) { await this.DisplayAlert("Select the drive implementation first"); return; } switch (this.SelectedCloundDrive) { case "LocalDrive": this.DriveService = Xamarin.Forms.DependencyService.Get <LocalDriveService>(); break; case "OneDrive": this.DriveService = Xamarin.Forms.DependencyService.Get <OneDriveService>(); break; default: await this.DisplayAlert("Select the drive implementation first"); return; } if (!await this.DriveService.ConnectAsync()) { return; } await this.Connection_Connected(); }
public DriveController(ICloudDriveService cloudDriveService) { _cloudDriveService = cloudDriveService; }