static void CopyCommandLineManagerAttribute(TypeBuilder typeBuilder, CommandLineManagerAttribute attribute) { Type type = typeof(CommandLineManagerAttribute); var classCtorInfo = type.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); typeBuilder.SetCustomAttribute(customAttributeBuilder); }
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); }