public void Oauth(CloudType type) { CheckThread(true); Type type_oauthUI; switch (type) { case CloudType.Dropbox: DropboxOauthv2 oauth_dropbox = new DropboxOauthv2(); oauth_dropbox.TokenCallBack += Oauth_dropbox_TokenCallBack; type_oauthUI = LoadDllUI.GetTypeInterface(typeof(UIinterfaceDB)); AppSetting.UIOauth = (OauthUI)Activator.CreateInstance(type_oauthUI); oauth_dropbox.GetCode(AppSetting.UIOauth, AppSetting.UIMain); break; case CloudType.GoogleDrive: GoogleAPIOauth2 oauth_gd = new GoogleAPIOauth2(); oauth_gd.TokenCallBack += Oauth_gd_TokenCallBack; type_oauthUI = LoadDllUI.GetTypeInterface(typeof(UIinterfaceGD)); AppSetting.UIOauth = (OauthUI)Activator.CreateInstance(type_oauthUI); oauth_gd.GetCode(AppSetting.UIOauth, AppSetting.UIMain); break; case CloudType.Mega: type_oauthUI = LoadDllUI.GetTypeInterface(typeof(UIinterfaceMegaNz)); UIinterfaceMegaNz mega = (UIinterfaceMegaNz)Activator.CreateInstance(type_oauthUI); bool error = false; reoauthMega: if (!error) { mega.ShowDialog_(); } else { mega.ShowError("Wrong email or password."); } if (mega.Success) { MegaApiClient.AuthInfos oauthinfo = MegaApiClient.GenerateAuthInfos(mega.Email, mega.Pass); MegaApiClient client = new MegaApiClient(); try { client.Login(oauthinfo); } catch (Exception) { error = true; goto reoauthMega; } SaveToken(mega.Email, JsonConvert.SerializeObject(oauthinfo), CloudType.Mega); } break; default: throw new Exception("Not support"); } }
public DriveAPIHttprequestv2(TokenGoogleDrive token, GD_LimitExceededDelegate LimitExceeded = null) { this.Token = token; oauth = new GoogleAPIOauth2(token); this.limit = LimitExceeded; this.Files = new DriveFiles(this); this.About = new DriveAbout(this); this.Parent = new DriveParent(this); this.Extend = new DriveExtend(this); }