public static void AddRelatedUnitSourceAttribute(this IAttributable attributable, ITypeNameResolver resolver, RelatedUnitSourceUsage flag, int sortOrder) { var argument = resolver.GetEnumValueCode(flag); var csAttribute = new CsAttribute(nameof(RelatedUnitSourceAttribute)) .WithArgumentCode(argument); if (flag != RelatedUnitSourceUsage.DoNotUse) { csAttribute.WithArgument(sortOrder); } attributable.WithAttribute(csAttribute); }
private static string GetStringValue(string chooseLongNameVariableName, OptionsCollectionValue option, ITypeNameResolver resolver) { var longVersion = option.LongOptionWithMinus; var shortVersion = option.ShortOptionWithMinus; if (string.IsNullOrEmpty(longVersion)) { return(shortVersion.CsEncode()); } if (string.IsNullOrEmpty(shortVersion)) { return(longVersion.CsEncode()); } var conditions = chooseLongNameVariableName + " == " + resolver.GetEnumValueCode(OptionPreference.Long); return(string.Format("{0} ? {1} : {2}", conditions, longVersion.CsEncode(), shortVersion.CsEncode())); }