コード例 #1
0
 private static string ShortName(ArgumentAttribute attribute, MemberInfo storage)
 {
     if (attribute is DefaultArgumentAttribute)
         return null;
     if (!ExplicitShortName(attribute))
         return LongName(attribute, storage).Substring(0,1);
     return attribute.ShortName;
 }
コード例 #2
0
 private static string HelpText(ArgumentAttribute attribute)
 {
     if (attribute == null)
         return null;
     else
         return attribute.HelpText;
 }
コード例 #3
0
        private static string LongName(ArgumentAttribute attribute, MemberInfo storage)
        {
            return (attribute == null || attribute.DefaultLongName) ? storage.Name : attribute.LongName;

            throw new Exception("Unhandled type");
        }
コード例 #4
0
 private static bool HasHelpText(ArgumentAttribute attribute)
 {
     return (attribute != null && attribute.HasHelpText);
 }
コード例 #5
0
 private static ArgumentType Flags(ArgumentAttribute attribute, MemberInfo member)
 {
     if (attribute != null)
         return attribute.Type;
     else if (IsCollectionType(member.GetType()))
         return ArgumentType.MultipleUnique;
     else
         return ArgumentType.AtMostOnce;
 }
コード例 #6
0
 private static bool ExplicitShortName(ArgumentAttribute attribute)
 {
     return (attribute != null && !attribute.DefaultShortName);
 }
コード例 #7
0
 private static object DefaultValue(ArgumentAttribute attribute)
 {
     return (attribute == null || !attribute.HasDefaultValue) ? null : attribute.DefaultValue;
 }
コード例 #8
0
            public Argument(ArgumentAttribute attribute, MemberInfo storage, ErrorReporter reporter)
            {
                this.longName = Parser.LongName(attribute, storage);
                this.explicitShortName = Parser.ExplicitShortName(attribute);
                this.shortName = Parser.ShortName(attribute, storage);
                this.hasHelpText = Parser.HasHelpText(attribute);
                this.helpText = Parser.HelpText(attribute);
                this.defaultValue = Parser.DefaultValue(attribute);
                this.elementType = ElementType(storage);
                this.flags = Flags(attribute, storage);
                this.member = storage;
                this.seenValue = false;
                this.reporter = reporter;
                this.isDefault = attribute != null && attribute is DefaultArgumentAttribute;

                if (IsCollection)
                {
                    this.collectionValues = new ArrayList();
                }

                Debug.Assert(this.longName != null && this.longName != "");
                Debug.Assert(!this.isDefault || !this.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(!(this.IsRequired && this.HasDefaultValue), "Required arguments cannot have default value");
                Debug.Assert(!this.HasDefaultValue || (this.defaultValue.GetType() == storage.GetType()), "Type of default value must match field type");
            }