public static void ResolveOptions(CCommand command, Type commandType) { FieldInfo[] fields = commandType.GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); for (int i = 0; i < fields.Length; ++i) { FieldInfo info = fields[i]; object[] attributes = info.GetCustomAttributes(typeof(CCommandOptionAttribute), true); if (attributes.Length == 1) { CCommandOptionAttribute attr = (CCommandOptionAttribute)attributes[0]; string name = attr.Name != null ? attr.Name : info.Name; Option option = new Option(info, name, attr.Description); if (attr.Values != null) { option.Values = ParseValues(attr.Values, info.FieldType); } option.ShortName = attr.ShortName; option.IsRequired = attr.Required; option.DefaultValue = GetDefaultValue(command, info); command.AddOption(option); } } }