private string GetTidyParameters(TidyOptions aTidyOptions, TidyChecks aTidyChecks) { string parameters = aTidyOptions.Fix ? $" {ScriptConstants.kTidyFix} ''-*," : $" {ScriptConstants.kTidy} ''-*,"; if (null != aTidyOptions.TidyChecks && 0 < aTidyOptions.TidyChecks.Length) { parameters = $"{parameters}{String.Join(",", aTidyOptions.TidyChecks)}''"; } else { foreach (PropertyInfo prop in aTidyChecks.GetType().GetProperties()) { object[] propAttrs = prop.GetCustomAttributes(false); object clangCheckAttr = propAttrs.FirstOrDefault(attr => typeof(ClangCheckAttribute) == attr.GetType()); object displayNameAttrObj = propAttrs.FirstOrDefault(attr => typeof(DisplayNameAttribute) == attr.GetType()); if (null == clangCheckAttr || null == displayNameAttrObj) { continue; } DisplayNameAttribute displayNameAttr = (DisplayNameAttribute)displayNameAttrObj; var value = prop.GetValue(aTidyChecks, null); if (Boolean.TrueString != value.ToString()) { continue; } parameters = $"{parameters},{displayNameAttr.DisplayName}"; } parameters = $"{parameters}''"; } return(parameters); }
private string GetTidyParameters(TidyOptions aTidyOptions, TidyChecks aTidyChecks, TidyCustomChecks aTidyCustomChecks) { string parameters = string.Empty; if (ComboBoxConstants.kTidyFile == aTidyOptions.UseChecksFrom) { parameters = $"{parameters}{ScriptConstants.kTidyFile}"; mUseTidyFile = true; } else if (ComboBoxConstants.kCustomChecks == aTidyOptions.UseChecksFrom) { if (null != aTidyCustomChecks.TidyChecks && 0 != aTidyCustomChecks.TidyChecks.Length) { parameters = $",{String.Join(",", aTidyCustomChecks.TidyChecks)}"; } } else if (ComboBoxConstants.kPredefinedChecks == aTidyOptions.UseChecksFrom) { foreach (PropertyInfo prop in aTidyChecks.GetType().GetProperties()) { object[] propAttrs = prop.GetCustomAttributes(false); object clangCheckAttr = propAttrs.FirstOrDefault(attr => typeof(ClangCheckAttribute) == attr.GetType()); object displayNameAttrObj = propAttrs.FirstOrDefault(attr => typeof(DisplayNameAttribute) == attr.GetType()); if (null == clangCheckAttr || null == displayNameAttrObj) { continue; } DisplayNameAttribute displayNameAttr = (DisplayNameAttribute)displayNameAttrObj; var value = prop.GetValue(aTidyChecks, null); if (Boolean.TrueString != value.ToString()) { continue; } parameters = $"{parameters},{displayNameAttr.DisplayName}"; } } if (string.Empty != parameters) { parameters = string.Format("{0} ''{1}{2}''", (aTidyOptions.Fix ? ScriptConstants.kTidyFix : ScriptConstants.kTidy), (mUseTidyFile ? "" : "-*"), parameters); } if (!string.IsNullOrWhiteSpace(aTidyOptions.HeaderFilter)) { parameters = string.Format("{0} {1} ''{2}''", parameters, ScriptConstants.kHeaderFilter, ComboBoxConstants.kHeaderFilterMaping.ContainsKey(aTidyOptions.HeaderFilter) ? ComboBoxConstants.kHeaderFilterMaping[aTidyOptions.HeaderFilter] : aTidyOptions.HeaderFilter); } return(parameters); }
private string GetTidyParameters(TidyOptions aTidyOptions, TidyChecks aTidyChecks) { string parameters = string.Empty; if (TidyModeConstants.kTidyFile == aTidyOptions.TidyMode) { return(string.Format("{0} {1}", aTidyOptions.Fix ? ScriptConstants.kTidyFix : ScriptConstants.kTidy, ScriptConstants.kTidyFile)); } else if (TidyModeConstants.kCustomChecks == aTidyOptions.TidyMode) { parameters = $",{String.Join(",", aTidyOptions.TidyChecks)}"; } else { foreach (PropertyInfo prop in aTidyChecks.GetType().GetProperties()) { object[] propAttrs = prop.GetCustomAttributes(false); object clangCheckAttr = propAttrs.FirstOrDefault(attr => typeof(ClangCheckAttribute) == attr.GetType()); object displayNameAttrObj = propAttrs.FirstOrDefault(attr => typeof(DisplayNameAttribute) == attr.GetType()); if (null == clangCheckAttr || null == displayNameAttrObj) { continue; } DisplayNameAttribute displayNameAttr = (DisplayNameAttribute)displayNameAttrObj; var value = prop.GetValue(aTidyChecks, null); if (Boolean.TrueString != value.ToString()) { continue; } parameters = $"{parameters},{displayNameAttr.DisplayName}"; } } if (string.Empty != parameters) { parameters = string.Format("{0} ''-*{1}''", (aTidyOptions.Fix ? ScriptConstants.kTidyFix : ScriptConstants.kTidy), parameters); } return(parameters); }