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);
                }
            }
        }
예제 #2
0
 public DeleteFileOperation(
     IFileTask man,
     OperationOptions options)
 {
     _man = NamedNullException.Assert(man, nameof(man));
     NamedNullException.Assert(options, nameof(options));
     NotTrueException.Assert(options.DoDelete, nameof(options.DoDelete));
 }
예제 #3
0
 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));
 }
예제 #4
0
        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;
        }
예제 #5
0
        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;
        }
예제 #6
0
        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);
        }