Esempio n. 1
0
        public FtpTransferOperation(
            OperationOptions oo,
            ILoggerFactory loggerFactory)
        {
            _options = NamedNullException.Assert(oo, nameof(oo));
            var fo = _options.Ftp;

            NamedNullException.Assert(fo, nameof(fo));
            _timeout   = fo.Timeout.HasValue ? fo.Timeout.Value : FtpOptions.MaxFtpTimeout;
            _ftpClient = new SimpleFtpClient(fo.FtpRoot, fo.UserName, fo.Password, _timeout);

            _logger        = NamedNullException.Assert(loggerFactory, nameof(loggerFactory)).CreateLogger <FtpTransferOperation>();
            _timeoutPolicy = Policy.TimeoutAsync(TimeSpan.FromMilliseconds(_timeout), TimeoutStrategy.Pessimistic);
        }
Esempio n. 2
0
 public static IServiceCollection AddAkaCache(this IServiceCollection services, params AkaCacheOptions[] options)
 {
     NamedNullException.Assert(services, nameof(services));
     services.AddSingleton <IAkavacheManager>(_ =>
     {
         var mgr = new DefaultAkavacheManager();
         for (var index = 0; index < options.Length; ++index)
         {
             mgr.AddPersistenceMedia(options[index]);
         }
         return(mgr);
     });
     return(services);
 }
Esempio n. 3
0
        public static IEnumerable <T> Filter <T>(this IEnumerable <T> items, string key,
                                                 Func <T, string, bool> judger,
                                                 int maxDisplayCount)
        {
            NamedNullException.Assert(items, nameof(items));
            NamedNullException.Assert(judger, nameof(judger));

            maxDisplayCount = maxDisplayCount > 0 ? maxDisplayCount : int.MaxValue;

            return(string.IsNullOrWhiteSpace(key) ? items.Take(maxDisplayCount).ToArray() :
                   items.Where(x => judger(x, key))
                   .Take(maxDisplayCount)
                   .ToArray());
        }
Esempio n. 4
0
        public MonitorCrowd(
            IOptions <AppOptions> options,
            ILogger <MonitorCrowd> log)
        {
            NamedNullException.Assert(options, nameof(options));

            _readSpinTimeout = options.Value.FileReadSpinWaitTimeout;
            _scs             = options.Value.Groups.Select(x => x.Monitor).ToList();
            _log             = NamedNullException.Assert(log, nameof(log));
            _monitors        = _scs.Select(x => x.Path.ToMonitoredPath())
                               .Distinct(MonitoredPath.Comparer)
                               .Select(x => new PathMonitor(x))
                               .ToList();
            _observers = new List <IPathObserver>();
        }
Esempio n. 5
0
        public void AddPersistenceMedia(AkaCacheOptions options)
        {
            NamedNullException.Assert(options, nameof(options));

            var name = StringNullOrWhiteSpaceException.Assert(options.Name, nameof(options.Name));

            if (_caches.ContainsKey(name))
            {
                throw new CreateSameNameMediaException(name);
            }

            var path = Path.GetFullPath(options.PersistenceMediaDirPath);

            path.EnsureDirExists();

            var full = Path.Combine(path, $"{name}.db");

            _caches[name] = options.NeedEncryption ? new SQLiteEncryptedBlobCache(full) : new SqlRawPersistentBlobCache(full);
        }
 public DefaultHttpApiFactory(IServiceProvider provider)
 {
     _serviceProvider = NamedNullException.Assert(provider, nameof(provider));
 }
Esempio n. 7
0
 public CacheProvider(IMemoryCache cache)
 {
     _cache = NamedNullException.Assert(cache, nameof(cache));
     _keys  = new ConcurrentDictionary <string, string>();
 }
 public ControlLoggerProvider(IControl control)
 {
     _filter  = null;
     _control = NamedNullException.Assert(control, nameof(control));
 }
Esempio n. 9
0
 public AutoClearControl(IControl control, int maxCount)
 {
     _condition = maxCount >= 1 ? new Condition(maxCount) : default;
     _control   = NamedNullException.Assert(control, nameof(control));
 }
Esempio n. 10
0
        public XmlFoldingHelper(TextEditor editor)
        {
            _textEditor = NamedNullException.Assert(editor, nameof(editor));

            _init();
        }
Esempio n. 11
0
 public ControlLogger(string name, Func <string, LogLevel, bool> filter, IControl control)
 {
     _control = NamedNullException.Assert(control, nameof(control));
     _name    = (string.IsNullOrEmpty(name) ? "ControlLogger" : name);
     _filter  = filter;
 }
Esempio n. 12
0
 public TextBoxControl(TextBox textBox)
 {
     _textBox = NamedNullException.Assert(textBox, nameof(textBox));
 }
Esempio n. 13
0
 public static IServiceCollection AddAkaCache(this IServiceCollection services)
 {
     NamedNullException.Assert(services, nameof(services));
     services.AddSingleton <IAkavacheManager, DefaultAkavacheManager>();
     return(services);
 }