Exemplo n.º 1
0
        public OptionInfo(BaseOptionAttribute attribute, PropertyInfo property, CultureInfo parsingCulture)
        {
            if (attribute == null)
            {
                throw new ArgumentNullException("attribute", SR.ArgumentNullException_AttributeCannotBeNull);
            }

            if (property == null)
            {
                throw new ArgumentNullException("property", SR.ArgumentNullException_PropertyCannotBeNull);
            }

            this.required = attribute.Required;
            this.shortName = attribute.ShortName;
            this.longName = attribute.LongName;
            this.mutuallyExclusiveSet = attribute.MutuallyExclusiveSet;
            this.defaultValue = attribute.DefaultValue;
            this.hasDefaultValue = attribute.HasDefaultValue;
            this.attribute = attribute;
            this.property = property;
            this.parsingCulture = parsingCulture;
            this.propertyWriter = new PropertyWriter(this.property, this.parsingCulture);
        }
Exemplo n.º 2
0
        public bool MapValueItem(string item)
        {
            if (this.IsValueOptionDefined &&
                this.valueOptionIndex < this.valueOptionAttributeList.Count)
            {
                var valueOption = this.valueOptionAttributeList[this.valueOptionIndex++];
                var propertyWriter = new PropertyWriter(valueOption.Left, this.parsingCulture);
                return ReflectionUtil.IsNullableType(propertyWriter.Property.PropertyType) ?
                    propertyWriter.WriteNullable(item, this.target) :
                    propertyWriter.WriteScalar(item, this.target);
            }

            return this.IsValueListDefined && this.AddValueItem(item);
        }