public OptionList(Options optionBundle) { if (optionBundle == null) { throw new ArgumentNullException("optionBundle"); } Type optionsType = optionBundle.GetType(); this.optionBundle = optionBundle; this.parsingMode = optionBundle.ParsingMode; this.breakSingleDashManyLettersIntoManyOptions = optionBundle.BreakSingleDashManyLettersIntoManyOptions; this.endOptionProcessingWithDoubleDash = optionBundle.EndOptionProcessingWithDoubleDash; this.ReportError = optionBundle.ReportError; ExtractEntryAssemblyInfo(optionsType); foreach (MemberInfo mi in optionsType.GetMembers()) { object[] attribs = mi.GetCustomAttributes(typeof(KillOptionAttribute), true); if (attribs == null || attribs.Length == 0) { attribs = mi.GetCustomAttributes(typeof(OptionAttribute), true); if (attribs != null && attribs.Length > 0) { OptionDetails option = new OptionDetails(mi, (OptionAttribute)attribs[0], optionBundle); list.Add(option); HasSecondLevelHelp = HasSecondLevelHelp || option.SecondLevelHelp; } else if (mi.DeclaringType == mi.ReflectedType) // not inherited { attribs = mi.GetCustomAttributes(typeof(ArgumentProcessorAttribute), true); if (attribs != null && attribs.Length > 0) { AddArgumentProcessor(mi); } } } } if (argumentProcessor == null) // try to find an inherited one { foreach (MemberInfo mi in optionsType.GetMembers()) { if (mi.DeclaringType != mi.ReflectedType) // inherited { object[] attribs = mi.GetCustomAttributes(typeof(ArgumentProcessorAttribute), true); if (attribs != null && attribs.Length > 0) { AddArgumentProcessor(mi); } } } } }
private void Initialize(Options optionBundle) { if (optionBundle == null) { throw new ArgumentNullException("optionBundle"); } this.entry = Assembly.GetEntryAssembly(); this.appExeName = this.entry.GetName().Name; this.appVersion = this.entry.GetName().Version.ToString(); this.optionBundle = optionBundle; this.parsingMode = optionBundle.ParsingMode; this.breakSingleDashManyLettersIntoManyOptions = optionBundle.BreakSingleDashManyLettersIntoManyOptions; this.endOptionProcessingWithDoubleDash = optionBundle.EndOptionProcessingWithDoubleDash; this.GetAssemblyAttributeValue(typeof(AssemblyTitleAttribute), "Title", ref this.appTitle); this.GetAssemblyAttributeValue(typeof(AssemblyCopyrightAttribute), "Copyright", ref this.appCopyright); this.GetAssemblyAttributeValue(typeof(AssemblyDescriptionAttribute), "Description", ref this.appDescription); this.GetAssemblyAttributeValue(typeof(AboutAttribute), ref this.appAboutDetails); this.GetAssemblyAttributeValue(typeof(UsageComplementAttribute), ref this.appUsageComplement); this.appAuthors = this.GetAssemblyAttributeStrings(typeof(AuthorAttribute)); if (this.appAuthors.Length == 0) { this.appAuthors = new string[] { "Add one or more [assembly: Mono.GetOptions.Author(\"Here goes the author name\")] to your assembly" }; } MemberInfo[] infoArray1 = optionBundle.GetType().GetMembers(); for (int num1 = 0; num1 < infoArray1.Length; num1++) { MemberInfo info1 = infoArray1[num1]; object[] objArray1 = info1.GetCustomAttributes(typeof(OptionAttribute), true); if ((objArray1 != null) && (objArray1.Length > 0)) { OptionDetails details1 = new OptionDetails(info1, (OptionAttribute)objArray1[0], optionBundle); this.list.Add(details1); this.HasSecondLevelHelp = this.HasSecondLevelHelp || details1.SecondLevelHelp; } else { objArray1 = info1.GetCustomAttributes(typeof(ArgumentProcessorAttribute), true); if ((objArray1 != null) && (objArray1.Length > 0)) { this.AddArgumentProcessor(info1); } } } }
public OptionList(Options optionBundle) { if (optionBundle == null) throw new ArgumentNullException("optionBundle"); Type optionsType = optionBundle.GetType(); this.optionBundle = optionBundle; parsingMode = optionBundle.ParsingMode; breakSingleDashManyLettersIntoManyOptions = optionBundle.BreakSingleDashManyLettersIntoManyOptions; endOptionProcessingWithDoubleDash = optionBundle.EndOptionProcessingWithDoubleDash; ReportError = optionBundle.ReportError; ExtractEntryAssemblyInfo(optionsType); foreach(MemberInfo mi in optionsType.GetMembers()) { object[] attribs = mi.GetCustomAttributes(typeof(KillOptionAttribute), true); if (attribs == null || attribs.Length == 0) { attribs = mi.GetCustomAttributes(typeof(OptionAttribute), true); if (attribs != null && attribs.Length > 0) { OptionDetails option = new OptionDetails(mi, (OptionAttribute) attribs[0], optionBundle); list.Add(option); HasSecondLevelHelp = HasSecondLevelHelp || option.SecondLevelHelp; } else if (mi.DeclaringType == mi.ReflectedType) { // not inherited attribs = mi.GetCustomAttributes(typeof(ArgumentProcessorAttribute), true); if (attribs != null && attribs.Length > 0) AddArgumentProcessor(mi); } } } if (argumentProcessor == null) // try to find an inherited one foreach(MemberInfo mi in optionsType.GetMembers()) if (mi.DeclaringType != mi.ReflectedType) { // inherited object[] attribs = mi.GetCustomAttributes(typeof(ArgumentProcessorAttribute), true); if (attribs != null && attribs.Length > 0) AddArgumentProcessor(mi); } }
private void Initialize(Options optionBundle) { if (optionBundle == null) { throw new ArgumentNullException("optionBundle"); } this.entry = Assembly.GetEntryAssembly(); this.appExeName = this.entry.GetName().Name; this.appVersion = this.entry.GetName().Version.ToString(); this.optionBundle = optionBundle; this.parsingMode = optionBundle.ParsingMode; this.breakSingleDashManyLettersIntoManyOptions = optionBundle.BreakSingleDashManyLettersIntoManyOptions; this.endOptionProcessingWithDoubleDash = optionBundle.EndOptionProcessingWithDoubleDash; this.GetAssemblyAttributeValue(typeof(AssemblyTitleAttribute), "Title", ref this.appTitle); this.GetAssemblyAttributeValue(typeof(AssemblyCopyrightAttribute), "Copyright", ref this.appCopyright); this.GetAssemblyAttributeValue(typeof(AssemblyDescriptionAttribute), "Description", ref this.appDescription); this.GetAssemblyAttributeValue(typeof(AboutAttribute), ref this.appAboutDetails); this.GetAssemblyAttributeValue(typeof(UsageComplementAttribute), ref this.appUsageComplement); this.appAuthors = this.GetAssemblyAttributeStrings(typeof(AuthorAttribute)); if (this.appAuthors.Length == 0) { this.appAuthors = new string[] { "Add one or more [assembly: Mono.GetOptions.Author(\"Here goes the author name\")] to your assembly" } ; } MemberInfo[] infoArray1 = optionBundle.GetType().GetMembers(); for (int num1 = 0; num1 < infoArray1.Length; num1++) { MemberInfo info1 = infoArray1[num1]; object[] objArray1 = info1.GetCustomAttributes(typeof(OptionAttribute), true); if ((objArray1 != null) && (objArray1.Length > 0)) { OptionDetails details1 = new OptionDetails(info1, (OptionAttribute) objArray1[0], optionBundle); this.list.Add(details1); this.HasSecondLevelHelp = this.HasSecondLevelHelp || details1.SecondLevelHelp; } else { objArray1 = info1.GetCustomAttributes(typeof(ArgumentProcessorAttribute), true); if ((objArray1 != null) && (objArray1.Length > 0)) { this.AddArgumentProcessor(info1); } } } }