public static void PostAction(AppOptions mo) { NamedNullException.Assert(mo, nameof(mo)); var defaultMonitor = mo.Default?.Monitor; var defaultOperation = mo.Default?.Operation; NumberOutOfRangeException <int> .Assert( mo.FileReadSpinWaitTimeout, 0, AppOptions.MaxFileReadSpinWaitTimeout, nameof(mo.FileReadSpinWaitTimeout)); var groups = NamedNullException.Assert(mo.Groups, nameof(mo.Groups)); foreach (var group in groups) { NamedNullException.Assert(group, nameof(group)); StringNullOrEmptyException.Assert(group.Name, nameof(group.Name)); group.Monitor = postMonitor(group.Monitor, in defaultMonitor); NamedNullException.Assert(group.Operations, nameof(group.Operations)); NotTrueException.Assert(group.Operations.Count() > 0, nameof(group.Operations)); foreach (var op in group.Operations) { postOperation(op, defaultOperation); } } }
public DeleteFileOperation( IFileTask man, OperationOptions options) { _man = NamedNullException.Assert(man, nameof(man)); NamedNullException.Assert(options, nameof(options)); NotTrueException.Assert(options.DoDelete, nameof(options.DoDelete)); }
public static void EnsureValid(FtpOptions ftp) { NamedNullException.Assert(ftp, nameof(ftp)); StringNullOrEmptyException.Assert(ftp.FtpRoot, nameof(ftp.FtpRoot)); StringNullOrEmptyException.Assert(ftp.UserName, nameof(ftp.UserName)); NotTrueException.Assert(ftp.Timeout.HasValue, nameof(ftp.Timeout.HasValue)); NumberOutOfRangeException <int> .Assert(ftp.Timeout.Value, 0, MaxFtpTimeout, nameof(ftp.Timeout.Value)); }
public MoveFileOperation( IFileTask man, OperationOptions options) { _man = NamedNullException.Assert(man, nameof(man)); NamedNullException.Assert(options, nameof(options)); NotTrueException.Assert(options.DoMove, nameof(options.DoMove)); StringNullOrEmptyException.Assert(options.MovePath, nameof(options.MovePath)); _options = options; }
public BackupOperation( string groupName, IFileTask man, OperationOptions options) { _backupDirLinks = StringNullOrEmptyException.Assert(groupName, nameof(groupName)); _man = NamedNullException.Assert(man, nameof(man)); NamedNullException.Assert(options, nameof(options)); NotTrueException.Assert(options.DoBackup, nameof(options.DoBackup)); StringNullOrEmptyException.Assert(options.BackupPath, nameof(options.BackupPath)); _options = options; }
public static BitmapSource CreateFromFileContent(this Memory <byte> data) { NotTrueException.Assert(!data.IsEmpty, nameof(data)); var img = new BitmapImage(); //2017-11-12 //var mem = new MemoryStream(data.ToArray()); //尝试直接array的原引用,而不复制array var mem = new MemoryStream(data.GetZeroIndexedArrayOrCopyedContent()); img.BeginInit(); img.StreamSource = mem; img.CacheOption = BitmapCacheOption.OnLoad; img.EndInit(); img.Freeze(); return(img); }