コード例 #1
0
 /// <summary>
 /// Returns the list of providers associated with the drive. This means, Google drive can have multiple providers and one provider per account resulting in supporting multiple accounts on the same provider.
 /// </summary>
 /// <param name="drive"></param>
 /// <returns></returns>
 public static ICloudProvider[] GetProvider(SupportedDrive drive)
 {
     if (DriveProviderCollection.ContainsKey(drive))
     {
         return(DriveProviderCollection[drive].ToArray());
     }
     return(null);
 }
コード例 #2
0
 /// <summary>
 /// Returns the authenticator for the given SupportedDrive
 /// </summary>
 /// <param name="fromDrive"></param>
 /// <returns></returns>
 internal static CloudAuthenticator GetAuthenticator(SupportedDrive fromDrive)
 {
     if (Authenticators.ContainsKey(fromDrive))
     {
         return Authenticators[fromDrive];
     }
     return null;
 }
コード例 #3
0
 /// <summary>
 /// Returns the provider for a particular drive and fixed user name.
 /// </summary>
 /// <param name="fromDrive"></param>
 /// <param name="userName"></param>
 /// <returns></returns>
 public static ICloudProvider GetProvider(SupportedDrive fromDrive, string userName)
 {
     if (DriveProviderCollection.ContainsKey(fromDrive))
     {
         return(DriveProviderCollection[fromDrive].FirstOrDefault(provider => provider.UserName == userName));
     }
     return(null); //Provider not registered.
 }
コード例 #4
0
 /// <summary>
 /// Returns the authenticator for the given SupportedDrive
 /// </summary>
 /// <param name="fromDrive"></param>
 /// <returns></returns>
 internal static CloudAuthenticator GetAuthenticator(SupportedDrive fromDrive)
 {
     if (Authenticators.ContainsKey(fromDrive))
     {
         return(Authenticators[fromDrive]);
     }
     return(null);
 }
コード例 #5
0
 public static string TranslatePathForDrive(string uniquePath, SupportedDrive fromDrive)
 {
     switch (fromDrive)
     {
     case SupportedDrive.SkyDrive:
         return(GetTranslatePathForSkyDrive(uniquePath));
     }
     return(null);
 }
コード例 #6
0
        public static string TranslatePathForDrive(string uniquePath, SupportedDrive fromDrive)
        {
            switch (fromDrive)
            {
                case SupportedDrive.SkyDrive:
                    return GetTranslatePathForSkyDrive(uniquePath);

            }
            return null;
        }
コード例 #7
0
 /// <summary>
 /// Verifies if the drive is authenticated.
 /// </summary>
 /// <param name="drive"></param>
 /// <param name="userName"></param>
 /// <returns></returns>
 public static bool IsAuthenticated(SupportedDrive drive, string userName = null)
 {
     if (string.IsNullOrWhiteSpace(userName))
     {
         return(DriveProviderCollection.ContainsKey(drive));
     }
     if (DriveProviderCollection.ContainsKey(drive))
     {
         if (DriveProviderCollection[drive].Any(provider => provider.UserName == userName))
         {
             return(true);
         }
     }
     return(false);
 }
コード例 #8
0
        /// <summary>
        /// Authenticates the given drive. If one account is already authenticated then the method forces authentication of the drive on a different account. This also registers a provider for the supported drive.
        /// </summary>
        /// <param name="drive"></param>
        public static async Task <AuthenticationResult> AuthenticateAsync(SupportedDrive drive)
        {
            CloudAuthenticator   authenticator = CloudAuthenticator.GetAuthenticator(drive);
            AuthenticationResult result        = await authenticator.AuthenticateAsync();

            if (result == AuthenticationResult.Success)
            {
                ICloudProvider provider = null;
                switch (drive)
                {
                case SupportedDrive.SkyDrive:
                    provider = new SkyDriveProvider((LiveConnectSession)authenticator.GetSession());
                    break;
                    //case SupportedDrive.DropBox:
                    //    provider = new SkyDriveProvider((LiveConnectSession) authenticator.GetSession());
                    //    break;
                }
                RegisterProvider(provider);
            }
            return(result);
        }
コード例 #9
0
ファイル: CloudProvider.cs プロジェクト: haydenprock/OneDrive
 protected CloudProvider(string name, SupportedDrive drive, string baseUrl)
 {
     this.Name    = name;
     this.Drive   = drive;
     this.BaseUrl = baseUrl;
 }
コード例 #10
0
 /// <summary>
 /// Authenticates a particular drive with the given user name and password. Please not that this method may deprecate in future considering each account can provide their own mechanism of authentication like skydrive does not allows to capture user credentials and it provides its own interface OAuth 2.0
 /// </summary>
 /// <param name="drive"></param>
 /// <param name="userName"></param>
 /// <param name="password"></param>
 /// <returns></returns>
 public static bool Authenticate(SupportedDrive drive, string userName, string password)
 {
     throw new NotImplementedException();
 }