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); }
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); }
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()); }
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>(); }
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)); }
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)); }
public AutoClearControl(IControl control, int maxCount) { _condition = maxCount >= 1 ? new Condition(maxCount) : default; _control = NamedNullException.Assert(control, nameof(control)); }
public XmlFoldingHelper(TextEditor editor) { _textEditor = NamedNullException.Assert(editor, nameof(editor)); _init(); }
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; }
public TextBoxControl(TextBox textBox) { _textBox = NamedNullException.Assert(textBox, nameof(textBox)); }
public static IServiceCollection AddAkaCache(this IServiceCollection services) { NamedNullException.Assert(services, nameof(services)); services.AddSingleton <IAkavacheManager, DefaultAkavacheManager>(); return(services); }