static bool NeedAssignment(CommandLineManagerAttribute managerAttribute, CommandLineOptionGroupAttribute groupAttribute, CommandLineOptionAttribute optionAttriubte)
        {
            if (optionAttriubte.RequireExplicitAssignmentAssigned)
            {
                return(optionAttriubte.RequireExplicitAssignment);
            }
            else if (groupAttribute != null && groupAttribute.RequireExplicitAssignmentAssigned)
            {
                return(groupAttribute.RequireExplicitAssignment);
            }
            else if (managerAttribute != null && managerAttribute.RequireExplicitAssignmentAssigned)
            {
                return(managerAttribute.RequireExplicitAssignment);
            }

            return(false);
        }
Example #2
0
        static void CopyCommandLineOptionAttributeOfProperty(PropertyBuilder propertyBuilder, CommandLineOptionAttribute attribute)
        {
            Type typeOfCommandLineOptionAttribute = typeof(CommandLineOptionAttribute);
            var  classCtorInfo = typeOfCommandLineOptionAttribute.GetConstructor(new Type[] { });

            var propertyInfoArrayOfAttribute = GetNamedPropertyInfoArray(attribute);
            var valuesOfproperties           = propertyInfoArrayOfAttribute.Select(item => item.GetValue(attribute, null)).ToArray();

            CustomAttributeBuilder customAttributeBuilder = new CustomAttributeBuilder(classCtorInfo, new object[] { }, propertyInfoArrayOfAttribute, valuesOfproperties);

            propertyBuilder.SetCustomAttribute(customAttributeBuilder);
        }