|
|||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||
|
Announcements
Want a new Job?
Chapters
Services
Feature Zones
|
Mole for Visual Studio ReleasedAll versions of Mole have been replaced by Mole For Visual Studio. Please refer to this article Mole For Visual Studio. This article is here for informational purposes. The downloads have been removed. Please download and use Mole For Visual Studio. Thank you!IntroductionThis is the third article in the Mole WPF Visual Studio Visualizer series. This article covers a new and exciting feature - Black Ops. Black Ops enables Mole to return non-public members of objects that are selected in the visual or logical trees. Additionally, non-public members can also be returned during a drilling operation. Previous Mole ArticlesThis article focuses on the new features added to Mole II. If you have not read the below articles, please read them to fully understand Visual Studio Visualizers and Mole. Read Mole v1 Code Project Article. Read Mole II v2 Code Project Article. Mole's Home Page and ManualRead Mole's Manual and visit Mole's Home Page. Mole's EmailPlease send your comments and feedback to molefeedback@yahoo.com. Team MoleMole was authored by Karl Shifflett, Josh Smith and Andrew Smith. Karl wrote this article which is why "I" appears in the article and I make references to myself. BackgroundI have been amazed at the response that Mole & Mole II have received. One such response came from a super developer and great guy from the Raleigh, NC area, Rob Zelt. He wrote this blog post on Mole II. In this posting, he wondered if Mole would work with Silverlight applications. I did the research and as of Silverlight 1.1, visualizers are not supported. I do not know if they will be in Silverlight 2.0 scheduled to be released Q1 2008. If visualizers will not be supported in Silverlight 2.0, I have come up with two alternate methods to provide Silverlight developers Mole functionality and will write the program shortly after the release of Silverlight 2.0. I would welcome suggestions from Silverlight developers for this product. Please leave comments at the bottom of this article or on my blog. During my investigation of Silverlight and Mole, many new ideas started to surface. One of them was viewing and drilling into private and protected members. Currently Mole views public objects and properties. So we can thank Rob Zelt for asking me this question which lead to this code being authored and Mole getting Black Ops capabilities. Where did this Black Ops business come from? Well, I was going to call it, "Mole! Show me your privates!" (private members right). Actually Mole took a left turn and ended up on the set of 24 and hung around Jack Bauer too long. Just keeping it fun! Black Ops is used in this article but in the program UI we have chosen to follow .NET nomenclature and call the private and protected members fields, since that is what is being displayed. Again, just keeping it fun. (Truth be told, Josh talked me out of it.) As you know, you can easily change anything about Mole with very little effort, colors, labels, displayed data, etc. Mole Black OpsFirst off, two columns have been renamed. Property Name has been renamed to Name and Property Type has been renamed to Type. The reason for this is that the Black Ops items can now be properties or fields. In the above image, a Fields (Black Ops) Section
Below the Search Black Ops CollapsedThe Fields section has been collapsed. Black Ops DataSome would ask, why show In the above image, I have selected a The real reason I wanted this feature was to be able to view Private and Protected DataFor Each obj As System.Reflection.FieldInfo In _
target.GetType.GetFields(BindingFlags.NonPublic Or _
BindingFlags.Instance)
Dim bolIsDepencencyProperty As Boolean = False
'note the default value is set to null
Dim strValue As String = STRING_NULL
Dim strValueSource As String = String.Empty
Dim bolIsDrillable As Boolean = False
Try
Dim objValue As Object = obj.GetValue(target)
If objValue IsNot Nothing Then
strValue = objValue.ToString
bolIsDrillable = _
IsDrillableTest(obj.ReflectedType, objValue)
End If
Catch ex As Exception
'just ignoring the exception
End Try
objList.Add(New TreeElementProperty(bolIsDepencencyProperty, _
bolIsDrillable, _
String.Format(STRING_BLACK_OPS_INDICATOR_FORMAT, obj.Attributes.ToString), _
obj.Name, obj.FieldType.Name, strValue, strValueSource))
Next
Viewing Because of the way Mole is designed, adding this feature was very simple. I inserted the above code at the end of the The You can also see that Mole is string based. Look at what the UI is passed in the above Since the UI for Mole and the data source for Mole are in two separate processes, the UI does not have any references to the data it displays. It is this utterly simplistic design that allows Mole to be easily extended. It is the responsibility of the Mole's data source to maintain references to objects that Mole is viewing so that those objects can be drilled into when the user desires. CloseUnless there is a bug, this might be the last installment of Mole until the Silverlight version in Q1 2008. Karl needs to get back to work on a multi-player WPF game he has been working on. The game should be released in stores Q2 2008. Hope this article can help someone learn a little more about Visual Studio Visualizers For WPF. History
|
||||||||||||||||||||||||||||||