public static IClassRuleCheck GetRuleCheck(DTE2 applicationObject, string ruleName, string extension) { IClassRuleCheck classRuleCheck = null; switch (ruleName) { case "BaseClassRule": classRuleCheck = new BaseClassRuleCheck(applicationObject, extension); break; case "CommentOnClassRule": classRuleCheck = new CommentOnClassRuleCheck(applicationObject, extension); break; default: MessageBox.Show(string.Format("{0}¹æÔò²»´æÔÚ.", ruleName)); break; } return(classRuleCheck); }
/// <summary>Implements the Exec method of the IDTCommandTarget interface. This is called when the command is invoked.</summary> /// <param term='commandName'>The name of the command to execute.</param> /// <param term='executeOption'>Describes how the command should be run.</param> /// <param term='varIn'>Parameters passed from the caller to the command handler.</param> /// <param term='varOut'>Parameters passed from the command handler to the caller.</param> /// <param term='handled'>Informs the caller if the command was handled or not.</param> /// <seealso class='Exec' /> public void Exec(string commandName, vsCommandExecOption executeOption, ref object varIn, ref object varOut, ref bool handled) { handled = false; if (executeOption == vsCommandExecOption.vsCommandExecOptionDoDefault) { //TODO:commandName命名由来:FullClassName("SuperStar.Connect") + ? if (commandName == "SuperStar.Connect.SuperStar") { SelectRuleForm frmSelectRule = new SelectRuleForm(); if (frmSelectRule.ShowDialog() == System.Windows.Forms.DialogResult.OK) { string ruleName = frmSelectRule.RuleName; string extension = frmSelectRule.Extension; IClassRuleCheck classRuleCheck = RuleCheckFactory.GetRuleCheck(_applicationObject, ruleName, extension); classRuleCheck.Checking(); } handled = true; return; } } }