public OptionDetails(MemberInfo memberInfo, OptionAttribute option, Options optionBundle)
{
ShortForm = ("" + option.ShortForm).Trim();
if (option.LongForm == null)
LongForm = string.Empty;
else
LongForm = (option.LongForm == string.Empty) ? memberInfo.Name : option.LongForm;
AlternateForm = option.AlternateForm;
ShortDescription = ExtractParamName(option.ShortDescription);
Occurs = 0;
OptionBundle = optionBundle;
BooleanOption = false;
MemberInfo = memberInfo;
NeedsParameter = false;
Values = null;
MaxOccurs = 1;
VBCStyleBoolean = option.VBCStyleBoolean;
SecondLevelHelp = option.SecondLevelHelp;
Hidden = false; // TODO: check other attributes
ParameterType = TypeOfMember(memberInfo);
if (ParameterType != null)
{
if (ParameterType.FullName != "System.Boolean")
{
if (LongForm.IndexOf(':') >= 0)
throw new InvalidOperationException(
"Options with an embedded colon (':') in their visible name must be boolean!!! [" +
MemberInfo.ToString() + " isn't]");
NeedsParameter = true;
if (option.MaxOccurs != 1)
{
if (ParameterType.IsArray)
{
Values = new ArrayList();
MaxOccurs = option.MaxOccurs;
}
else
{
if (MemberInfo is MethodInfo || MemberInfo is PropertyInfo)
MaxOccurs = option.MaxOccurs;
else
throw new InvalidOperationException("MaxOccurs set to non default value (" + option.MaxOccurs + ") for a [" +
MemberInfo.ToString() + "] option");
}
}
}
else
{
BooleanOption = true;
if (option.MaxOccurs != 1)
{
if (MemberInfo is MethodInfo || MemberInfo is PropertyInfo)
MaxOccurs = option.MaxOccurs;
else
throw new InvalidOperationException("MaxOccurs set to non default value (" + option.MaxOccurs + ") for a [" +
MemberInfo.ToString() + "] option");
}
}
}
}