private void LoadFromSetting() { if (string.IsNullOrEmpty(Settings.Default.CleanupChoices)) { for (int i = 0; i < checkedListBox1.Items.Count; i++) { checkedListBox1.SetItemChecked(i, true); } return; } var choices = Settings.Default.CleanupChoices.Split(','); int value = 0; foreach (var item in choices) { if (int.TryParse(item, out value)) { if (Enum.IsDefined(typeof(CodeCleanerType), value)) { CodeCleanerType enumValue = (CodeCleanerType)Enum.ToObject(typeof(CodeCleanerType), value); var foundItem = checkedListBox1.Items.OfType <CheckBoxItem>().FirstOrDefault(x => x.CleanerType == enumValue); if (foundItem == null) { continue; } checkedListBox1.SetItemChecked(checkedListBox1.Items.IndexOf(foundItem), true); } } } }
public ReadOnlyMainCleanup(CodeCleanerType mainCleanupItemType, CleanerItemUIInfo[] cleanerItemUIInfos, bool isMainObjectSelected = true) { MainCleanupItemType = mainCleanupItemType; CleanerItemUIInfos = cleanerItemUIInfos; IsMainObjectSelected = isMainObjectSelected; }
public void Init(CodeCleanerType mainCleanupItemType) { MainCleanupItemType = mainCleanupItemType; MainCleannerItemAttribute = ExtractCleannerItemAttribute(typeof(CodeCleanerType), mainCleanupItemType).Value; SetUIProps(); }
public static void Run(ProjectItem item, CodeCleanerType command, CleanupOptions cleanupOptions) { if (!ActiveDocument.IsValid(item)) { ErrorNotification.EmailError(Resources.PrivateModifierCleanUpFailed); } else { var instance = CodeCleanerFactory.Create(command, cleanupOptions); new CodeCleaner(instance, item).Run(); } }
public static ICodeCleaner Create(CodeCleanerType type) { switch (type) { case CodeCleanerType.NormalizeWhiteSpaces: return(new WhiteSpaceNormalizer()); case CodeCleanerType.ConvertMembersToExpressionBodied: return(new ConvertMembersToExpressionBodied()); case CodeCleanerType.ConvertFullNameTypesToBuiltInTypes: return(new ConvertFullNameTypesToBuiltInTypes()); case CodeCleanerType.SortClassMembersCommand: return(new SortClassMembers()); case CodeCleanerType.SimplyAsyncCallsCommand: return(new SimplyAsyncCalls()); case CodeCleanerType.SimplifyClassFieldDeclarationsCommand: return(new SimplifyClassFieldDeclarations()); case CodeCleanerType.RemoveAttributeKeyworkCommand: return(new RemoveAttributeKeywork()); case CodeCleanerType.CompactSmallIfElseStatementsCommand: return(new CompactSmallIfElseStatements()); case CodeCleanerType.RemoveExtraThisQualification: return(new RemoveExtraThisQualification()); case CodeCleanerType.CamelCasedLocalVariable: return(new CamelCasedLocalVariable()); case CodeCleanerType.CamelCasedFields: return(new CamelCasedFields()); case CodeCleanerType.CamelCasedConstFields: return(new CamelCasedConstFields()); case CodeCleanerType.PrivateAccessModifier: return(new PrivateModifierRemover()); case CodeCleanerType.OrganizeUsingDirectives: return(new UsingDirectiveOrganizer()); default: return(null); // TODO } }
public static void Run(ProjectItem item, CodeCleanerType command) { if (!ActiveDocument.IsValid(item)) { ErrorNotification.EmailError(Resources.PrivateModifierCleanUpFailed); } else { var invoker = new CleanerActionInvoker(item); switch (command) { case CodeCleanerType.All: invoker.InvokeAll(); break; default: invoker.Invoke(command); break; } } }
public ReadOnlyMainCleanup(CodeCleanerType mainCleanupItemType, bool isMainObjectSelected = true) { MainCleanupItemType = mainCleanupItemType; IsMainObjectSelected = isMainObjectSelected; }
public static ICodeCleaner Create(CodeCleanerType type, CleanupOptions cleanupOptions, bool isReportOnly = false) { switch (type) { case CodeCleanerType.NormalizeWhiteSpaces: return(new WhiteSpaceNormalizer() { Options = cleanupOptions.WhiteSpaceNormalizer, IsReportOnlyMode = isReportOnly }); case CodeCleanerType.ConvertMembersToExpressionBodied: return(new ConvertMembersToExpressionBodied() { Options = cleanupOptions.ConvertMembersToExpressionBodied, IsReportOnlyMode = isReportOnly }); case CodeCleanerType.ConvertFullNameTypesToBuiltInTypes: return(new ConvertFullNameTypesToBuiltInTypes() { IsReportOnlyMode = isReportOnly }); case CodeCleanerType.SortClassMembers: return(new SortClassMembers() { IsReportOnlyMode = isReportOnly });; case CodeCleanerType.SimplyAsyncCalls: return(new SimplyAsyncCalls() { Options = cleanupOptions.SimplyAsyncCall, IsReportOnlyMode = isReportOnly }); case CodeCleanerType.SimplifyClassFieldDeclarations: return(new SimplifyClassFieldDeclarations() { Options = cleanupOptions.SimplifyClassFieldDeclarations, IsReportOnlyMode = isReportOnly }); case CodeCleanerType.RemoveAttributeKeywork: return(new RemoveAttributeKeywork() { IsReportOnlyMode = isReportOnly }); case CodeCleanerType.CompactSmallIfElseStatements: return(new CompactSmallIfElseStatements() { IsReportOnlyMode = isReportOnly }); case CodeCleanerType.RemoveExtraThisQualification: return(new RemoveExtraThisQualification() { Options = cleanupOptions.RemoveExtraThisQualification, IsReportOnlyMode = isReportOnly }); case CodeCleanerType.CamelCasedMethodVariable: return(new CamelCasedLocalVariable() { Options = cleanupOptions.CamelCasedLocalVariable, IsReportOnlyMode = isReportOnly }); case CodeCleanerType.CamelCasedFields: return(new CamelCasedFields() { Options = cleanupOptions.CamelCasedFields, IsReportOnlyMode = isReportOnly }); case CodeCleanerType.PrivateAccessModifier: return(new PrivateModifierRemover() { IsReportOnlyMode = isReportOnly }); case CodeCleanerType.OrganizeUsingDirectives: return(new UsingDirectiveOrganizer() { Options = cleanupOptions.PrivateModifierRemover, IsReportOnlyMode = isReportOnly }); case CodeCleanerType.SimplifyVariableDeclarations: return(new SimplifyVariableDeclarations() { IsReportOnlyMode = isReportOnly }); case CodeCleanerType.ConvertPropertiesToAutoProperties: return(new ConvertPropertiesToAutoProperties() { IsReportOnlyMode = isReportOnly }); case CodeCleanerType.ConvertMsharpUIMethods: return(new MSharpUICleaner() { IsReportOnlyMode = isReportOnly }); case CodeCleanerType.ConvertMsharpModelMethods: return(new MSharpModelCleaner() { IsReportOnlyMode = isReportOnly }); case CodeCleanerType.ConvertMsharpGeneralMethods: return(new MSharpGeneralCleaner() { IsReportOnlyMode = isReportOnly }); case CodeCleanerType.ConvertZebbleGeneralMethods: return(new ZebbleCleaner() { IsReportOnlyMode = isReportOnly }); case CodeCleanerType.UpgradeCSharpSyntax: return(new CSharpSyntaxUpgrade() { IsReportOnlyMode = isReportOnly }); default: return(null); // TODO } }
protected ExtendedBaseCodeCleanupCommand(OleMenuCommandService menu, uint commandId, CodeCleanerType cleanerType) : base(menu, commandId) { CleanerType = cleanerType; }
private void NewCheckbox(CodeCleanerType cleanerType, string title) { checkedListBox1.Items.Add(new CheckBoxItem { Name = title, CleanerType = cleanerType }); }
public void Invoke(CodeCleanerType cleanerType) { var instance = CodeCleanerFactory.Create(cleanerType); new CodeCleaner(instance, Item).Run(); }