コード例 #1
0
            public void Configure(Action <PolicyConfiguration> configuration)
            {
                var impl = new PolicyConfigurationImpl();

                configuration(impl);

                _applyTo   = impl.AppllyTo;
                _pattern   = impl.Pattern;
                _priority  = impl.Priority;
                _arguments = impl.Arguments;

                if (!_arguments.ContainsKey("ha-mode"))
                {
                    return;
                }

                if (!_arguments.TryGetValue("ha-mode", out var value))
                {
                    _errors.Add(new ErrorImpl($"Argument 'ha-mode' was set without a corresponding value."));
                }

                string mode = value.ToString().Trim();

                if ((mode.ConvertTo() == HighAvailabilityModes.Exactly || mode.ConvertTo() == HighAvailabilityModes.Nodes) &&
                    !_arguments.ContainsKey("ha-params"))
                {
                    _errors.Add(new ErrorImpl($"Argument 'ha-mode' has been set to {mode}, which means that argument 'ha-params' has to also be set"));
                }
            }
コード例 #2
0
ファイル: PolicyImpl.cs プロジェクト: ahives/HareDu1
            public void Configure(Action <PolicyConfiguration> configuration)
            {
                var impl = new PolicyConfigurationImpl();

                configuration(impl);

                _applyTo   = impl.WhereToApply;
                _pattern   = impl.Pattern;
                _priority  = impl.Priority;
                _arguments = impl.Arguments;

                foreach (var argument in _arguments?.Where(x => x.Value.IsNull()).Select(x => x.Key))
                {
                    _errors.Add(new ErrorImpl($"Argument '{argument}' has been set without a corresponding value."));
                }

                if (!_arguments.TryGetValue("ha-mode", out var haMode))
                {
                    return;
                }

                string mode = haMode.Value.ToString().Trim();

                if ((mode.Convert() == HighAvailabilityModes.Exactly ||
                     mode.Convert() == HighAvailabilityModes.Nodes) && !_arguments.ContainsKey("ha-params"))
                {
                    _errors.Add(new ErrorImpl($"Argument 'ha-mode' has been set to {mode}, which means that argument 'ha-params' has to also be set"));
                }
            }