PowerArgs.CommandLineArgument.Validate C# (CSharp) Method

Validate() private method

private Validate ( string &commandLineValue ) : void
commandLineValue string
return void
        internal void Validate(ref string commandLineValue)
        {
            if (ArgumentType == typeof(SecureStringArgument) && Validators.Count() > 0)
            {
                throw new InvalidArgDefinitionException("Properties of type SecureStringArgument cannot be validated.  If your goal is to make the argument required then the[ArgRequired] attribute is not needed.  The SecureStringArgument is designed to prompt the user for a value only if your code asks for it after parsing.  If your code never reads the SecureString property then the user is never prompted and it will be treated as an optional parameter.  Although discouraged, if you really, really need to run custom logic against the value before the rest of your program runs then you can implement a custom ArgHook, override RunAfterPopulateProperty, and add your custom attribute to the SecureStringArgument property.");
            }

            foreach (var v in Validators)
            {
                if (v.ImplementsValidateAlways)
                {
                    try { v.ValidateAlways(this, ref commandLineValue); }
                    catch (NotImplementedException)
                    {
                        // TODO P0 - Test to make sure the old, PropertyInfo based validators properly work.
                        v.ValidateAlways(Source as PropertyInfo, ref commandLineValue);
                    }
                }
                else if (commandLineValue != null)
                {
                    v.Validate(Aliases.First(), ref commandLineValue);
                }
            }
        }