コード例 #1
0
        public void ParameterlessConstructorDefaults()
        {
            var namedAttribute = new NamedArgumentAttribute();
            namedAttribute.Flags.Should().Be(ArgumentFlags.AtMostOnce);

            var positionalAttribute = new PositionalArgumentAttribute();
            positionalAttribute.Flags.Should().Be(ArgumentFlags.AtMostOnce);
        }
コード例 #2
0
        public void ParameterlessConstructorDefaults()
        {
            var namedAttribute = new NamedArgumentAttribute();

            namedAttribute.Flags.Should().Be(ArgumentFlags.Optional);

            var positionalAttribute = new PositionalArgumentAttribute();

            positionalAttribute.Flags.Should().Be(ArgumentFlags.Optional);
        }
コード例 #3
0
ファイル: Binder.cs プロジェクト: rebus-org/GoCommando
        void BindPositional(object commando, PropertyInfo property, List<CommandLineParameter> parameters, PositionalArgumentAttribute attribute, BindingContext context)
        {
            var parameter = parameters
                .Where(p => p is PositionalCommandLineParameter)
                .Cast<PositionalCommandLineParameter>()
                .SingleOrDefault(p => p.Index == context.Position);

            if (parameter == null)
            {
                context.Report.PropertiesNotBound.Add(property);
                context.Report.RequiredPropertiesNotBound.Add(property);

                if (!attribute.Required) return;

                throw Ex("Could not find parameter matching required positional parameter at index {0}", context.Position);
            }

            property.SetValue(commando, Mutate(parameter, property), null);

            context.Report.PropertiesBound.Add(property);
            context.IncrementPosition();
        }
コード例 #4
0
ファイル: Binder.cs プロジェクト: modulexcite/GoCommando
        void BindPositional(object commando, PropertyInfo property, List <CommandLineParameter> parameters, PositionalArgumentAttribute attribute, BindingContext context)
        {
            var parameter = parameters
                            .Where(p => p is PositionalCommandLineParameter)
                            .Cast <PositionalCommandLineParameter>()
                            .SingleOrDefault(p => p.Index == context.Position);

            if (parameter == null)
            {
                context.Report.PropertiesNotBound.Add(property);
                context.Report.RequiredPropertiesNotBound.Add(property);

                if (!attribute.Required)
                {
                    return;
                }

                throw Ex("Could not find parameter matching required positional parameter at index {0}", context.Position);
            }

            property.SetValue(commando, Mutate(parameter, property), null);

            context.Report.PropertiesBound.Add(property);
            context.IncrementPosition();
        }