Пример #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
 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();
 }