示例#1
0
 private DLoggerManager(String appName,
                        Boolean forceDummy)
 {
     if (ForceAllToDummy || forceDummy)
     {
         _defaultLogger = new DummyDLogger();
     }
     else
     {
         if (DLoggerConfig.LoadDefault(appName, out _config))
         {
             InitialiseDefaultLogger();
             if (_config.DefaultEnabled)
             {
                 _defaultLogger = new DLogger(_config);
             }
             else
             {
                 _defaultLogger = new DummyDLogger();
             }
         }
         else
         {
             _defaultLogger = new DummyDLogger();
         }
     }
 }
示例#2
0
 public static void Initialise(
     IDLogger logger,
     Func <ClipboardObfuscatorGeneratedFakeEventArgs, Task> action)
 {
     _instance = CreateDefault(
         logger,
         action);
 }
        public static CloudStorageProviderBase CreateOAuth <T>(IDLogger logger,
                                                               string accessToken) where T : CloudStorageProviderBase
        {
            DLoggerManager.Instance.Logger.Log(LoggerMessageType.VerboseLow | LoggerMessageType.Information, "Creating CloudStorageProviderBase instance of type '{0}'.", typeof(T).Name);

            T instance = (T)Activator.CreateInstance(typeof(T), logger, accessToken);

            return(instance);
        }
        public AmazonS3StorageProvider(IDLogger logger,
                                       AmazonS3Config config) : base(logger)
        {
            _config = config;
            RegionEndpoint regionEndpoint = AmazonS3Regions.GetRegionByDisplayName(config.Region);

            _s3Client = new AmazonS3Client(
                config.AccessID,
                config.SecretKey,
                regionEndpoint);
        }
示例#5
0
 private ClipboardObfuscator(
     IDLogger logger,
     bool fakeUsernames,
     bool fakePasswords,
     Func <ClipboardObfuscatorGeneratedFakeEventArgs, Task> action)
 {
     _logger        = logger;
     _fakeUsernames = fakeUsernames;
     _fakePassword  = fakePasswords;
     _action        = action;
 }
示例#6
0
        public static void Initialise(IDLogger logger,
                                      Func <string, string, object> getProviderValueCallback,
                                      Func <string, string> getCredentialCallback)
        {
            DLoggerManager.Instance.Logger.Log(LoggerMessageType.VerboseLow | LoggerMessageType.Information, "Initialising static instance of CloudStorageSyncManager.");

            _instance = new CloudStorageSyncManager(
                logger,
                getProviderValueCallback,
                getCredentialCallback);
        }
示例#7
0
        public CloudStorageSyncManager(IDLogger logger,
                                       Func <string, string, object> getProviderValueCallback,
                                       Func <string, string> getCredentialCallback)
        {
            DLoggerManager.Instance.Logger.Log(LoggerMessageType.VerboseLow | LoggerMessageType.Information, "Creating instance of CloudStorageSyncManager.");

            _logger = logger;
            _getProviderValueCallback = getProviderValueCallback;
            _getCredentialCallback    = getCredentialCallback;
            _providers = new Dictionary <VaultIndex, CloudStorageProviderBase>();
        }
示例#8
0
 public void InitialiseDefaultLogger()
 {
     if (_config.DefaultEnabled)
     {
         _defaultLogger = new DLogger(_config);
     }
     else
     {
         _defaultLogger = new DummyDLogger();
     }
 }
示例#9
0
        private static ClipboardObfuscator CreateDefault(
            IDLogger logger,
            Func <ClipboardObfuscatorGeneratedFakeEventArgs, Task> action)
        {
            ClipboardObfuscator instance = new ClipboardObfuscator(
                logger,
                true,
                true,
                action);

            return(instance);
        }
示例#10
0
        public static CloudStorageProviderBase Create(
            IDLogger logger,
            VaultIndex vaultIndex,
            Dictionary <string, string> parameters)
        {
            if (vaultIndex.SyncMode == Common.SyncMode.CloudProvider)
            {
                string providerKey = parameters["ProviderKey"];
                switch (providerKey)
                {
                case "Dropbox":
                {
                    string accessToken = parameters["AccessToken"];
                    return(CreateOAuth <DropboxStorageProvider>(
                               logger,
                               accessToken));
                }

                case "OneDrive":
                {
                    string accessToken = parameters["AccessToken"];
                    return(CreateOAuth <OneDriveStorageProvider>(
                               logger,
                               accessToken));
                }

                case "AmazonS3":
                {
                    string accessID   = parameters["AccessID"];
                    string secretKey  = parameters["SecretKey"];
                    string region     = parameters["Region"];
                    string bucketName = parameters["BucketName"];
                    string path       = parameters["Path"];
                    return(CreateAmazon <AmazonS3StorageProvider>(
                               logger,
                               accessID,
                               secretKey,
                               region,
                               bucketName,
                               path));
                }

                default:
                {
                    throw new NotSupportedException(String.Format("Sync OAuth provider of type '{0}' not supported.", providerKey));
                }
                }
            }
            else
            {
                return(null);
            }
        }
示例#11
0
        public static CloudStorageProviderBase CreateAmazon <T>(IDLogger logger,
                                                                string accessID,
                                                                string secretKey,
                                                                string region,
                                                                string bucketName,
                                                                string path) where T : CloudStorageProviderBase
        {
            DLoggerManager.Instance.Logger.Log(LoggerMessageType.VerboseLow | LoggerMessageType.Information, "Creating CloudStorageProviderBase instance of type '{0}'.", typeof(T).Name);

            AmazonS3Config config = new AmazonS3Config(
                accessID,
                secretKey,
                region,
                bucketName,
                path);
            T instance = (T)Activator.CreateInstance(typeof(T), logger, config);

            return(instance);
        }
示例#12
0
 public OneDriveStorageProvider(IDLogger logger,
                                string accessToken) : base(logger)
 {
     _accessToken = accessToken;
     _client      = new HttpClient();
 }
示例#13
0
 protected CloudStorageProviderBase(IDLogger logger)
 {
     _logger = logger;
 }
示例#14
0
 public DropboxStorageProvider(IDLogger logger,
                               string accessToken) : base(logger)
 {
     _client = new DropboxClient(accessToken,
                                 new DropboxClientConfig());
 }