|
|||||||||||||||||||||||||
|
|||||||||||||||||||||||||
|
Announcements
Want a new Job?
Chapters
Services
Feature Zones
|
IntroductionI am working on an ERP that is dealing with datasets a lot, and every time I need to know the contents of the dataset during debugging I try to make a quick watch but it has caused me headaches so I decided to make my own dataset quick watch. How does it work?I wrote my code using C#. I started by creating an Extensibility Projects from VS.NET's New Project menu. The wizard shows up and now the main idea behind this addin is how to pass an object from the VS.NET debug mode to the add-in. I did a lot of search but I did not find anything. The only way to know what is going in the debug mode is to use How did I insert my button in the context menu?The wizard adds the created button ( // add the command to the right click context menu
// note that when I insert the command it's inserted disabled
// "(int)vsCommandStatus.vsCommandStatusUnsupported +
// (int)vsCommandStatus.vsCommandStatusInvisible"
Command command = commands.AddNamedCommand ( addInInstance, DSWatchNode ,
DataSet Quick Watch, DataSet Quick Watch, true, 60, ref contextGUIDS,
(int)vsCommandStatus.vsCommandStatusUnsupported +
(int)vsCommandStatus.vsCommandStatusInvisible );
CommandBar commandBar = (CommandBar)commandBars[Code Window];
CommandBarControl commandBarControl = command.AddControl(commandBar, 1); I have found a great article talking about addin and context menu in code project written by Erick Sgarbi called strongly typed collection and it was very useful
How to know if the selected test is a dataset?After capturing the selected text i can use it as an expression in the string fileExtintion;
TextSelection _TextSelection;
_TextSelection = (TextSelection) applicationObject.ActiveDocument.Selection;
str = _TextSelection.Text;
fileExtintion=applicationObject.ActiveDocument.FullName.Substring(
applicationObject.ActiveDocument.FullName.Length-2 ) ;
switch(fileExtintion.ToLower() )
{
case "cs":
isDataSetExpression="(System.Data.DataSet)"+str+".Tables";
getXmlExpression="((System.Data.DataSet)"+str+").GetXml()";
break;
case"vb":
isDataSetExpression="ctype("+ str +",System.Data.DataSet).Tables";
getXmlExpression="ctype("+ str +",System.Data.DataSet).GetXml()";
break;
}
//cast the selcted text to dataset
expr = debugger.GetExpression(isDataSetExpression,true,500);
if (expr.Value.IndexOf("error:")>-1)
{
System.Windows.Forms.MessageBox.Show("This is not a DataSet!");
return;
}
If the if (expr.Value.IndexOf(error:)>-1)
{
System.Windows.Forms.MessageBox.Show(this is not DataSet!!);
return;
}
How to get the content of the dataset?I could not get the object from the debugging project so I have to know the selected dataset XML contents by evaluating Using the codeRun the add-in setup file and after installing the add-in you will be able to watch any dataset by selecting it in the debug mode and choosing "DataSet Quick Watch" from right-click menu.
|
||||||||||||||||||||||||