コード例 #1
0
        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 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));
 }
コード例 #3
0
ファイル: Sender.cs プロジェクト: DaneSpiritGOD/Scanner
        public Sender(string addr)
        {
            StringNullOrEmptyException.Assert(addr, nameof(addr));

            _socket = new PushSocket();
            _socket.Options.SendTimeout       = TimeSpan.FromMilliseconds(100);
            _socket.Options.ReconnectInterval = TimeSpan.FromMilliseconds(150);
            _socket.Connect(addr.ToLower());
        }
コード例 #4
0
 public SimpleFtpClient(
     string ftpRoot,
     string userName,
     string password = null,
     int timeout     = 500)
 {
     _credentials   = new NetworkCredential(StringNullOrEmptyException.Assert(userName, nameof(userName)), password);
     _ftpRoot       = StringNullOrEmptyException.Assert(ftpRoot, nameof(ftpRoot)).Trim();
     _ftpUploadRoot = normalizedRoot(_ftpRoot);
     _timeout       = NumberOutOfRangeException <int> .Assert(timeout, 0, FtpOptions.MaxFtpTimeout, nameof(timeout));
 }
コード例 #5
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;
        }
コード例 #6
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;
        }
コード例 #7
0
        public static string ToMd5Hash(this string source)
        {
            StringNullOrEmptyException.Assert(source, nameof(source));

            // Create a new instance of the MD5CryptoServiceProvider object.
            using var hasher = new MD5CryptoServiceProvider();

            // Convert the input string to a byte array and compute the hash.
            var data = hasher.ComputeHash(Encoding.UTF8.GetBytes(source));

            // Create a new Stringbuilder to collect the bytes
            // and create a string.
            var sb = new StringBuilder();

            // Loop through each byte of the hashed data 
            // and format each one as a hexadecimal string.
            for (var i = 0; i < data.Length; i++)
            {
                sb.Append(data[i].ToString("x2"));
            }

            // Return the hexadecimal string.
            return sb.ToString();
        }
コード例 #8
0
 private Singleton(string mutexName)
 {
     _mutexName   = StringNullOrEmptyException.Assert(mutexName, nameof(mutexName));
     _systemMutex = default;
 }