static void Main(string[] args) { Console.WriteLine("Welcome to the Calculator app!"); Console.ReadLine(); string argumentOne; string argumentTwo; ArgumentType argument1Type = ArgumentType.String; ArgumentType argument2Type = ArgumentType.String; argumentOne = GetArgument("Please input first argument: "); argumentTwo = GetArgument("Please input second argument: "); argument1Type = GetArgumentType(argumentOne); argument2Type = GetArgumentType(argumentTwo); Console.WriteLine("Argument 1 is {0}", argument1Type); Console.WriteLine("Argument 2 is {0}", argument2Type); Console.ReadKey(); OperatorType operatorType = OperatorType.Unknown; operatorType = GetOperatorType("Please input your operator"); Console.WriteLine("Your operator is {0}", operatorType); Console.ReadKey(); Calculator(argumentOne, argument1Type, argumentTwo, argument2Type, operatorType); }
public static ArgumentType GetArgumentType(string argument) { ArgumentType argumentType = ArgumentType.String; double number; DateTime dateTime; TimeSpan timeSpan; if (double.TryParse(argument, out number)) { argumentType = ArgumentType.Number; return(argumentType); } else if (TimeSpan.TryParse(argument, out timeSpan)) { argumentType = ArgumentType.TimeSpan; return(argumentType); } else if (DateTime.TryParse(argument, out dateTime)) { argumentType = ArgumentType.DateTime; return(argumentType); } else { argumentType = ArgumentType.String; return(argumentType); } }
private ArgumentSummary Summarize(ArgumentDefinition arg) { var attrib = arg.Attribute; var namedAttrib = arg.Attribute as NamedArgumentAttribute; var enumType = arg.ArgumentType as IEnumArgumentType; var isCommand = false; var type = arg.ArgumentType.Type; if (type.GetTypeInfo().IsGenericType&& type.GetGenericTypeDefinition().Name == "CommandGroup`1") { enumType = ArgumentType.GetType(type.GetGenericArguments().First()) as IEnumArgumentType; isCommand = true; } return(new ArgumentSummary { name = attrib.LongName, short_name = namedAttrib?.ShortName, required = arg.IsRequired, command = isCommand, takes_rest_of_line = arg.TakesRestOfLine, type = arg.ArgumentType.DisplayName, description = attrib.Description, default_value = arg.HasDefaultValue ? attrib.DefaultValue : null, possible_values = enumType?.GetValues() .Where(value => !value.Hidden && !value.Disallowed) .Select(value => Summarize(arg, value)) .ToArray(), }); }
public object Get(ArgumentType type) { object result = null; arguments?.TryGetValue(type, out result); return(result); }
private string ArgTypeConverter(ArgumentType type) { switch (type) { case ArgumentType.boolean: return("Boolean"); case ArgumentType.text: return("Text"); case ArgumentType.number: return("Number"); case ArgumentType.datetime: return("DateTime"); case ArgumentType.collection: return("Text Collection"); case ArgumentType.unknown: return("A magic type!"); default: break; } throw new InvalidOperationException(type.ToString()); }
public Argument(ArgumentAttribute attribute, FieldInfo field, ErrorReporter reporter) { this.longName = Parser.LongName (attribute, field); this.explicitShortName = Parser.ExplicitShortName (attribute); this.shortName = Parser.ShortName (attribute, field); this.hasHelpText = Parser.HasHelpText (attribute); this.helpText = Parser.HelpText (attribute); this.defaultValue = Parser.DefaultValue (attribute); this.elementType = ElementType (field); this.flags = Flags (attribute, field); this.field = field; this.SeenValue = false; this.reporter = reporter; this.isDefault = attribute != null && attribute is DefaultArgumentAttribute; if (this.IsCollection) this.collectionValues = new ArrayList (); Debug.Assert (!String.IsNullOrEmpty (this.longName)); Debug.Assert (!this.isDefault || !this.ExplicitShortName); Debug.Assert (!this.IsCollection || this.AllowMultiple, "Collection arguments must have allow multiple"); Debug.Assert (!this.Unique || this.IsCollection, "Unique only applicable to collection arguments"); Debug.Assert (IsValidElementType (this.Type) || IsCollectionType (this.Type)); Debug.Assert ((this.IsCollection && IsValidElementType (this.elementType)) || (!this.IsCollection && this.elementType == null)); Debug.Assert (!(this.IsRequired && this.HasDefaultValue), "Required arguments cannot have default value"); Debug.Assert (!this.HasDefaultValue || (this.defaultValue.GetType () == field.FieldType), "Type of default value must match field type"); }
public static Dictionary <ArgumentType, string> Parse(string[] args) { var result = new Dictionary <ArgumentType, string>(); foreach (var a in args) { var split = a.Split(new[] { ':' }, 2); ArgumentType argType = ArgumentType.Default; switch (split[0]) { case "-sf": argType = ArgumentType.SourceFileName; break; case "-s": argType = ArgumentType.SplittedFileSize; break; case "-d": argType = ArgumentType.DestinationFolder; break; default: throw new ArgumentException($"Not registered argument passed: {split[0]}."); } if (argType != ArgumentType.Default) { result.Add(argType, split[1]); } } return(result); }
public override string ToString() { string display; if (Optional) { display = "["; } else { display = "<"; } display += StringUtil.ToUppercaseFirst(ArgumentType.ToString()); if (Optional) { display += "]"; } else { display += ">"; } return(display); }
internal string ToString(bool typed) { if (m_argumentType == null) { return(base.ToString() !); } if (ArgumentType.IsEnum) { return(typed ? $"{Value}" : $"({ArgumentType.FullName}){Value}"); } if (Value == null) { return(typed ? "null" : $"({ArgumentType.Name})null"); } if (ArgumentType == typeof(string)) { return($"\"{Value}\""); } if (ArgumentType == typeof(char)) { return($"'{Value}'"); } if (ArgumentType == typeof(Type)) { return($"typeof({((Type)Value!).FullName})"); } if (ArgumentType.IsArray) { IList <CustomAttributeTypedArgument> array = (IList <CustomAttributeTypedArgument>)Value !; Type elementType = ArgumentType.GetElementType() !; var result = new ValueStringBuilder(stackalloc char[256]); result.Append("new "); result.Append(elementType.IsEnum ? elementType.FullName : elementType.Name); result.Append('['); result.Append(array.Count.ToString()); result.Append(']'); for (int i = 0; i < array.Count; i++) { if (i != 0) { result.Append(", "); } result.Append(array[i].ToString(elementType != typeof(object))); } result.Append(" }"); return(result.ToString()); } return(typed ? $"{Value}" : $"({ArgumentType.Name}){Value}"); }
internal static XDRPCArgumentInfo GenerateArgumentInfo( Type t, object o, ArgumentType at) { return(XDRPCMarshaler.GenerateArgumentInfo(t, o, at, 0)); }
/// <summary> /// Formats the argument into a string. /// </summary> /// <param name="value">Value to format.</param> /// <param name="suppressArgNames">True to suppress argument names; /// false to leave them in.</param> /// <returns>The formatted string.</returns> public IEnumerable <string> Format(object value, bool suppressArgNames = false) { if (CollectionArgumentType != null) { foreach (var item in CollectionArgumentType.ToEnumerable(value)) { if (suppressArgNames) { yield return(CollectionArgumentType.ElementType.Format(item)); } else { yield return(Format(CollectionArgumentType.ElementType, item)); } } } else if (suppressArgNames) { yield return(ArgumentType.Format(value)); } else { yield return(Format(ArgumentType, value)); } }
public static void ThrowArgumentNegativeOrZero( double value, string argumentName, ArgumentType argumentType) { throw new ArgumentOutOfRangeException( $"{GetArgumentTypeName(argumentType)} {argumentName}={value} must be greater than zero", (Exception)null); }
public override void Write(MetadataBuffer buffer, IBinaryStreamWriter writer) { writer.WriteByte((byte)ArgumentMemberType); ArgumentType.Write(buffer, writer); // TODO: write FieldOrPropType instead. writer.WriteSerString(MemberName); Argument.Write(buffer, writer); }
static ArgumentType GetArgumentType(string argument) { ArgumentType typeToCheck = ArgumentType.String; int intVal; DateTime dateTimeVal; TimeSpan timeSpanVal; bool isInt = int.TryParse(argument, out intVal); bool isDateTimeVal = DateTime.TryParse(argument, out dateTimeVal); bool isTimeSpan = TimeSpan.TryParse(argument, out timeSpanVal); if (isInt) { typeToCheck = ArgumentType.Number; } else if (isTimeSpan) { typeToCheck = ArgumentType.TimeSpan; } else if (isDateTimeVal) { typeToCheck = ArgumentType.DateTime; } else { return(typeToCheck); } return(typeToCheck); }
private void Initialize() { commandInfos = new List <CommandInfo>(); properties = new List <ParameterInfo>(); foreach (var propertyInfo in ArgumentType.GetProperties(BindingFlags.Instance | BindingFlags.Public)) { var attributes = propertyInfo.GetCustomAttributes <CommandLineAttribute>(true).ToArray(); if (attributes.Any()) { var parameterInfo = CreateInfo(propertyInfo, attributes); properties.Add(parameterInfo); if (parameterInfo is CommandInfo commandInfo) { commandInfos.Add(commandInfo); if (IsHelpCommand(propertyInfo)) { HelpCommand = commandInfo; } if (commandInfo.IsDefault) { if (DefaultCommand != null) { throw new InvalidOperationException("Default command was defined twice."); } DefaultCommand = commandInfo; } } } } }
public override uint GetPhysicalLength() { return(sizeof(byte) + ArgumentType.GetPhysicalLength() + (MemberName == null ? sizeof(byte) : MemberName.GetSerStringSize()) + Argument.GetPhysicalLength()); }
private IParsingResultsDictionary parseConfigFromCommandLine() { var arguments = new Queue <string>(_source.Args); var plainValueCounter = 0; var resultsBuilder = new ParsingResultsBuilder(_source.DuplicateKeyBehavior); var lastArgumentString = _source.Args.First(); while (arguments.Any()) { var currentArgumentString = arguments.Dequeue(); var parsedArgument = ArgumentType.CreateFrom(currentArgumentString); switch (parsedArgument) { case ArgumentType.SingleDash dashArgument: handleSingleDashArgument(resultsBuilder, arguments, dashArgument); break; case ArgumentType.DoubleDash doubleDashArgument: handleDoubledashArgument(resultsBuilder, arguments, doubleDashArgument); break; case ArgumentType.Assignment assignment: if (_source.AllowDirectAssignments) { resultsBuilder.Add(assignment.Key, assignment.Value); } else { resultsBuilder.Error(new NotSupportedException($"Invalid argument '{assignment.Argument}' as direct assignments are not allowed.")); } break; case ArgumentType.Invalid invalid: resultsBuilder.Error(new ParsingException("Invalid argument.", $"Argument somewhere near: '{lastArgumentString.Limit(16)}'")); break; case ArgumentType.Plain plain: if (plainValueCounter < _valueDefinitions.Count) { resultsBuilder.Add(_valueDefinitions[plainValueCounter], plain.Argument); } else { resultsBuilder.Error(new IndexOutOfRangeException($"No more than {_valueDefinitions.Count} value arguments are allowed.")); } plainValueCounter++; break; } lastArgumentString = currentArgumentString; } if (_valueDefinitions.Count > plainValueCounter) { resultsBuilder.Error(new ValueRequiredException(string.Empty, $"Not all required values have been provided. Expected: {_valueDefinitions.Count}, Provided: {plainValueCounter}")); } return(resultsBuilder.GetResults()); }
public override LocalBuilder BuildArguments(ILGenerator ilGenerator) { LocalBuilder methodLocalBuilder = null; FieldBuilder contractFieldBuilder = null; LocalBuilder aspectArgLocalBuilder = null; AspectArgsMethodWeaver methodWeaver = null; ConstructorInfo ctorInterceptionArgs = null; methodLocalBuilder = LocalBuilderRepository.Declare(() => { return(ilGenerator.DeclareLocal(typeof(MethodInfo))); }); aspectArgLocalBuilder = ilGenerator.DeclareLocal(ArgumentType); contractFieldBuilder = WeavingSettings.TypeDefinition.GetFieldBuilder(WeavingSettings.ContractType); methodWeaver = new AspectArgsMethodWeaver(Member, methodLocalBuilder, Parameters, aspectWeavingSettings); methodWeaver.Weave(ilGenerator); ilGenerator.EmitLoadArg(0); ilGenerator.Emit(OpCodes.Ldfld, contractFieldBuilder); ilGenerator.EmitLoadLocal(methodLocalBuilder); ctorInterceptionArgs = ArgumentType.GetConstructors()[0]; Parameters.ForEach(1, (parameter, i) => { ilGenerator.EmitLoadArg(i); if (parameter.IsByRef) { ilGenerator.Emit(OpCodes.Ldind_I4); } }); ilGenerator.Emit(OpCodes.Newobj, ctorInterceptionArgs); ilGenerator.EmitStoreLocal(aspectArgLocalBuilder); return(aspectArgLocalBuilder); }
public override LocalBuilder BuildArguments(ILGenerator ilGenerator) { LocalBuilder propertyLocalBuilder = null; FieldBuilder contractFieldBuilder = null; LocalBuilder aspectArgLocalBuilder = null; ConstructorInfo ctorInterceptionArgs = null; AbstractAspectPropertyArgsWeaver methodWeaver = null; propertyLocalBuilder = LocalBuilderRepository.Declare(() => { return(ilGenerator.DeclareLocal(typeof(PropertyInfo))); }); ctorInterceptionArgs = ArgumentType.GetConstructors()[0]; aspectArgLocalBuilder = ilGenerator.DeclareLocal(ArgumentType); contractFieldBuilder = WeavingSettings.TypeDefinition.GetFieldBuilder(WeavingSettings.ContractType); methodWeaver = new AspectArgsSetPropertyWeaver(Member, propertyLocalBuilder, aspectWeavingSettings); methodWeaver.Weave(ilGenerator); ilGenerator.EmitLoadArg(0); ilGenerator.Emit(OpCodes.Ldfld, contractFieldBuilder); ilGenerator.EmitLoadLocal(propertyLocalBuilder); ilGenerator.Emit(OpCodes.Ldsfld, BindingsDependency); ilGenerator.EmitLoadArg(1); ilGenerator.Emit(OpCodes.Newobj, ctorInterceptionArgs); ilGenerator.EmitStoreLocal(aspectArgLocalBuilder); return(aspectArgLocalBuilder); }
/// <inheritdoc /> public override uint GetPhysicalLength(MetadataBuffer buffer) { return(sizeof(byte) + ArgumentType.GetPhysicalLength(buffer) + (MemberName?.GetSerStringSize() ?? sizeof(byte)) + Argument.GetPhysicalLength(buffer)); }
public void Execute() { ParseFileNames(); List <ArgumentOption> argumentOptions = GetArgumentOptions(); bool isArgumentTypesNotSimular = argumentOptions.Select(ao => ao.Type).Distinct().Count() != 1; if (isArgumentTypesNotSimular) { throw new ApplicationException("Arguments must be only input or output options"); } ArgumentType type = argumentOptions.First().Type; if (type == ArgumentType.Input) { argumentOptions.Reverse(); } IInputStream inputStream = new FileInputStream(_inputFileName); IOutputStream outputStream = new FileOutputStream(_outputFileName); DecorateByArgumentOptions(argumentOptions, ref inputStream, ref outputStream); WriteFromTo(inputStream, outputStream); inputStream.Dispose(); outputStream.Dispose(); }
public Argument(ArgumentType argumentType, string term, string value, bool isLongTerm = false) { ArgumentType = argumentType; Term = term; Value = value; IsLongTerm = isLongTerm; }
public static void ThrowArgumentOutOfRangeException( double value, double minValue, double maxValue, string argumentName, ArgumentType argumentType) { throw new ArgumentOutOfRangeException( $"{GetArgumentTypeName(argumentType)} {argumentName}={value} is out of range [{minValue}, {maxValue}]", (Exception)null); }
public PrepositionArgInfo(string preposition, ArgumentType argumentType, string fillerType)//:this(false,preposition, ArgumentType,argumentType,fillerType) { _passiveSentence = false; _preposition = preposition; _argumentType = argumentType; _fillerType = fillerType; }
public static string GetPropertyValuePath(ArgumentType argumentType) { switch (argumentType) { case ArgumentType.Bool: return("m_BoolValue"); case ArgumentType.Int: return("m_IntValue"); case ArgumentType.Float: return("m_FloatValue"); case ArgumentType.String: return("m_StringValue"); case ArgumentType.Vector2: return("m_Vector2Value"); case ArgumentType.Vector3: return("m_Vector3Value"); case ArgumentType.Color: return("m_ColorValue"); case ArgumentType.Object: return("m_ObjectValue"); default: return(string.Empty); } }
public PrepositionArgInfo(bool passiveSentence, string preposition, ArgumentType argumentType, string fillerType) { _passiveSentence = passiveSentence; _preposition = preposition; _argumentType = argumentType; _fillerType = fillerType; }
public ArgumentDef( char shortName, string longName, Type dataType = null, ArgumentType argType = ArgumentType.Positional, ArgumentStatus argStatus = ArgumentStatus.Required, sbyte consumption = 0 ) { if (shortName == nullChar && longName == emptyString) { throw new Exception("Argument must have a ShortName, LongName, or both."); } if (argType == ArgumentType.Positional && consumption == 0) { throw new Exception("Invalid number of values for positional argument '{0}'. Positional arguments must be represented by at least one value."); } if (dataType == null) { dataType = typeof(object); } this._dataType = null; this.ShortName = shortName; this.LongName = longName; this.ArgType = argType; this.ArgStatus = argStatus; this.Consumption = consumption; this.DataType = dataType; }
public Argument(Int32 categoryID, Int32 entryID, String message) { this._categoryID = categoryID; this._entryID = entryID; this._message = message; this._type = ArgumentType.Reference; }
public override void Weave(ILGenerator ilGenerator) { LocalBuilder argsImplLocalBuilder = null; var ctorInterceptionArgs = ArgumentType.GetConstructors()[0]; var aspectArgsType = Member.ToAspectArgumentContract(); var methodProperty = aspectArgsType.GetProperty("Method"); argsImplLocalBuilder = LocalBuilderRepository.GetOrDeclare(ArgumentType, () => { return(ilGenerator.DeclareLocal(ArgumentType)); }); ilGenerator.EmitLoadArg(1); ilGenerator.Emit(OpCodes.Ldind_Ref); WeaveAspectArg(ilGenerator); ilGenerator.Emit(OpCodes.Callvirt, methodProperty.GetGetMethod()); ilGenerator.Emit(OpCodes.Ldsfld, bindingsDependency); Parameters.ForEach(1, (parameter, i) => { var property = aspectArgsType.GetProperty("Arg{0}".Fmt(i)); WeaveAspectArg(ilGenerator); ilGenerator.Emit(OpCodes.Callvirt, property.GetGetMethod()); }); ilGenerator.Emit(OpCodes.Newobj, ctorInterceptionArgs); ilGenerator.EmitStoreLocal(argsImplLocalBuilder); }
public void TestThatDependentTypesListIsCorrect() { var type = (TupleArgumentType)ArgumentType.GetType(typeof(Tuple <bool, int, bool>)); type.DependentTypes.Should().BeEquivalentTo( new[] { typeof(bool), typeof(int) }.Select(ArgumentType.GetType)); }
public Argument(ArgumentAttribute attribute, FieldInfo field, ErrorReporter reporter) { this.longName = Parser.LongName(attribute, field); this.explicitShortName = Parser.ExplicitShortName(attribute); this.shortName = Parser.ShortName(attribute, field); this.hasHelpText = Parser.HasHelpText(attribute); this.helpText = Parser.HelpText(attribute); this.defaultValue = Parser.DefaultValue(attribute); this.elementType = ElementType(field); this.flags = Flags(attribute, field); this.field = field; this.seenValue = false; this.reporter = reporter; this.isDefault = attribute != null && attribute is DefaultArgumentAttribute; if (this.IsCollection) { this.collectionValues = new ArrayList(); } Debug.Assert(!string.IsNullOrEmpty(this.longName), "Long name"); Debug.Assert(!this.isDefault || !this.ExplicitShortName, "Short name"); Debug.Assert(!this.IsCollection || this.AllowMultiple, "Collection arguments must have allow multiple"); Debug.Assert(!this.Unique || this.IsCollection, "Unique only applicable to collection arguments"); Debug.Assert(IsValidElementType(Type) || IsCollectionType(Type), "Collection Type or Element type"); Debug.Assert((this.IsCollection && IsValidElementType(this.elementType)) || (!this.IsCollection && this.elementType == null), "Element type or Collection Type"); Debug.Assert(!(this.IsRequired && this.HasDefaultValue), "Required arguments cannot have default value"); Debug.Assert(!this.HasDefaultValue || (this.defaultValue.GetType() == field.FieldType), "Type of default value must match field type"); }
internal CommandLineArgumentAttribute(ArgumentType argType, string name) { _argumentType = argType; Name = name; Shortcut = string.Empty; Description = string.Empty; ParameterDescription = string.Empty; }
// ---------------------------------------------------------------------- public ToggleArgument( ArgumentType argumentType, string name, bool defaultValue ) : base(argumentType | ArgumentType.HasName | ArgumentType.ContainsValue, name, defaultValue) { if ( name == null ) { throw new ArgumentNullException( "name" ); } }
protected virtual void OnProcessArgument( ArgumentType type, string value ) { ProcessArgumentHandler handler = null; if ( type == ArgumentType.Parameter ) handler = ProcessParameter; else handler = ProcessOption; if ( handler != null ) handler( this, new ProcessArgumentEventArgs( type, value ) ); }
public Instruction GenericInst(OpCodes code, AddressingModes addrMode, Action<GenericInstruction, int, int> exec, ArgumentType param1type = ArgumentType.None, ArgumentType param2type = ArgumentType.None) { var inst = new GenericInstruction(cpu, code, addrMode, param1type != ArgumentType.None) { runFunction = exec }; if (param1type != ArgumentType.None) { inst.decodeArgumentsFunction = delegate(GenericInstruction sender, Memory.MemoryBin bin, ref InstructionDecodeContext context, ref int offset, ref int param1, ref int param2) { switch (param1type) { case ArgumentType.None: break; default: case ArgumentType.I1: param1 = inst.DecodeInt1Argument(bin, ref offset); break; case ArgumentType.I2: param1 = inst.DecodeInt2Argument(bin, ref offset); break; case ArgumentType.I3: param1 = inst.DecodeInt3Argument(bin, ref offset); break; } switch (param2type) { case ArgumentType.None: break; default: case ArgumentType.I1: param2 = inst.DecodeInt1Argument(bin, ref offset); break; case ArgumentType.I2: param2 = inst.DecodeInt2Argument(bin, ref offset); break; case ArgumentType.I3: param2 = inst.DecodeInt3Argument(bin, ref offset); break; } }; } return inst; }
internal List<string> ParseCommandLine(List<ProgramOption> optionList, string[] args) { /* initialize for new parsing */ expectedArgType = ArgumentType.ANY; ProcessOptions(optionList); List<string> arguments = new List<string>(); for (int argsPosition = 0; argsPosition < args.Length; argsPosition++) { string arg = args[argsPosition]; ArgumentType currentArgType = GetArgumentType(arg); switch (currentArgType) { case ArgumentType.ARGUMENT: ParseArgument(arg, arguments); break; case ArgumentType.OPTION_SHORT: ParseShortOption(arg); break; case ArgumentType.OPTION_LONG: bool continueParsing = ParseLongOption(arg); if (!continueParsing) { arguments.AddRange(args.Skip(argsPosition + 1)); argsPosition = args.Length; } break; default: /* should not happen as GetArgumentType(arg) returns only one from the above options (cases) */ throw new NotSupportedException("Unexpected currentArgType"); } } Log("\nPLAIN ARGUMENTS:"); Log(string.Join("\n", arguments.ToArray())); return arguments;// as they are local variable for now (and not private parser field), we dont need to: new List<string>(arguments); }
/// <summary> /// Creates a new CommandLineArgument instance /// </summary> /// <param name="name">The name of the argument</param> /// <param name="type">The argument type</param> /// <param name="shortDescription">The arguments short description</param> /// <param name="longDescription">The arguments long description</param> /// <param name="defaultValue">The default value of the argumen</param> /// <param name="aliases">A list of aliases for the command</param> /// <param name="values">A list of valid values for the command</param> public CommandLineArgument(string name, ArgumentType type, string shortDescription, string longDescription, string defaultValue, string[] aliases, string[] values) : this(name, type, shortDescription, longDescription, defaultValue) { m_aliases = aliases; m_validValues = values; }
public ArgumentInstance(object value) { Constraint = Is.Anything(); Type = ArgumentType.ArgumentOut; ReturnValue = value; }
/// <summary> /// Allows control of command line parsing. /// </summary> /// <param name="type"> Specifies the error checking to be done on the argument. </param> public LocalizedArgumentAttribute(ArgumentType type) : base(type) { }
public ArgumentInfo(ArgumentType argKind, string argName) { ContractUtils.Requires((argKind == ArgumentType.Named) ^ (argName == null), "kind"); kind = argKind; name = argName; }
public ArgumentInstance(AbstractConstraint constraint) { Constraint = constraint; Type = ArgumentType.ArgumentIn; ReturnValue = null; }
// ---------------------------------------------------------------------- protected Argument( ArgumentType argumentType, string name, object defaultValue ) { this.name = name; this.argumentType = argumentType; this.defaultValue = defaultValue; } // Argument
/// <summary> /// Creates a new CommandLineArgument instance /// </summary> /// <param name="name">The name of the argument</param> /// <param name="type">The argument type</param> /// <param name="shortDescription">The arguments short description</param> /// <param name="longDescription">The arguments long description</param> public CommandLineArgument(string name, ArgumentType type, string shortDescription, string longDescription) : this(name, type) { m_shortDescription = shortDescription; m_longDescription = longDescription; }
public ClassifiedArgument(ArgumentType argumentType, CommandParameterInfo parameterInfo, string value) { this.ArgumentType = argumentType; this.ParameterInfo = parameterInfo; this.Value = value; }
public Argument(ArgumentAttribute attribute, FieldInfo field, ErrorReporter reporter) { _longName = CommandLineParser.LongName(attribute, field); _explicitShortName = CommandLineParser.ExplicitShortName(attribute); _shortName = CommandLineParser.ShortName(attribute, field); _hasHelpText = CommandLineParser.HasHelpText(attribute); _helpText = CommandLineParser.HelpText(attribute, field); _defaultValue = CommandLineParser.DefaultValue(attribute, field); _elementType = ElementType(field); _flags = Flags(attribute, field); _field = field; _seenValue = false; _reporter = reporter; _isDefault = attribute is DefaultArgumentAttribute; if (IsCollection) { _collectionValues = new ArrayList(); } Debug.Assert(!string.IsNullOrEmpty(_longName)); Debug.Assert(!_isDefault || !ExplicitShortName); Debug.Assert(!IsCollection || AllowMultiple, "Collection arguments must have allow multiple"); Debug.Assert(!Unique || IsCollection, "Unique only applicable to collection arguments"); Debug.Assert(IsValidElementType(Type) || IsCollectionType(Type)); Debug.Assert((IsCollection && IsValidElementType(_elementType)) || (!IsCollection && _elementType == null)); Debug.Assert(!(IsRequired && HasDefaultValue), "Required arguments cannot have default value"); Debug.Assert(!HasDefaultValue || (_defaultValue.GetType() == field.FieldType), "Type of default value must match field type"); }
/// <summary> /// Allows control of command line parsing. /// </summary> /// <param name="type"> Specifies the error checking to be done on the argument. </param> public ArgumentAttribute(ArgumentType type) { _type = type; }
public ProcessArgumentEventArgs( ArgumentType type, string value ) : this(type, value, "") { }
public ProcessArgumentEventArgs( ArgumentType type, string value, string data ) { this.type = type; this.value = value; this.data = data; }
public ArgumentInfo(string argName) { kind = ArgumentType.Named; name = argName; }
/// <summary> /// Creates a new CommandLineArgument instance /// </summary> /// <param name="name">The name of the argument</param> /// <param name="type">The argument type</param> /// <param name="shortDescription">The arguments short description</param> /// <param name="longDescription">The arguments long description</param> /// <param name="defaultValue">The default value of the argumen</param> /// <param name="aliases">A list of aliases for the command</param> /// <param name="values">A list of valid values for the command</param> /// <param name="deprecationMessage">A message indicating the reason for deprecation and any change suggestions</param> public CommandLineArgument(string name, ArgumentType type, string shortDescription, string longDescription, string defaultValue, string[] aliases, string[] values, string deprecationMessage) : this(name, type, shortDescription, longDescription, defaultValue, aliases, values) { m_deprecated = true; m_deprecationMessage = deprecationMessage; }
/// <summary> /// Creates a new CommandLineArgument instance /// </summary> /// <param name="name">The name of the argument</param> /// <param name="type">The argument type</param> public CommandLineArgument(string name, ArgumentType type) : this(name) { m_type = type; }
/// <summary> /// Allows control of command line parsing. /// </summary> /// <param name="type"> Specifies the error checking to be done on the argument. </param> public ArgumentAttribute(ArgumentType type) { this.type = type; }
/// <summary> /// Creates a new CommandLineArgument instance /// </summary> /// <param name="name">The name of the argument</param> /// <param name="type">The argument type</param> /// <param name="shortDescription">The arguments short description</param> /// <param name="longDescription">The arguments long description</param> /// <param name="defaultValue">The default value of the argumen</param> public CommandLineArgument(string name, ArgumentType type, string shortDescription, string longDescription, string defaultValue) : this(name, type, shortDescription, longDescription) { m_defaultValue = defaultValue; }
// ---------------------------------------------------------------------- public NamedValueArgument( ArgumentType argumentType, string name, object defaultValue ) : base(argumentType | ArgumentType.ContainsValue | ArgumentType.HasName, name, defaultValue) { }
public ArgumentInstance(AbstractConstraint constraint, object value) { Constraint = constraint; Type = ArgumentType.ArgumentRef; ReturnValue = value; }
private static Expression GetArgumentExpression(CallSignature signature, ArgumentType kind, ref int unusedCount, DynamicMetaObject/*!*/[]/*!*/ args) { int index = signature.IndexOf(kind); if (index != -1) { unusedCount--; return args[index].Expression; } return AstUtils.Constant(null); }
public Variable(string name, ArgumentType type) { this.name = name; this.type = type; }
public ArgumentInfo(ArgumentType argKind) { kind = argKind; name = null; }
/// <summary> /// Indicates that this argument is the default argument. /// </summary> /// <param name="type"> Specifies the error checking to be done on the argument. </param> public DefaultArgumentAttribute(ArgumentType type) : base(type) { }
// ---------------------------------------------------------------------- public ValueArgument( ArgumentType argumentType ) : base(argumentType | ArgumentType.ContainsValue, null, null) { }