"Task List" feature in Visual Studio 2005
Technorati Tags: Visual Studio 2005
One of the less known features in Visual Studio is the “Task List” window. It helps you maintain a “To Do” list of sorts inside Visual Studio 2005. I, personally wasn’t aware of this feature until sometime last year and found this feature to be very handy at times.
When you select “Comments” from the drop down list on the top, you will see a list of all the places where you have used a ‘TODO: in your code. The “TODO” here acts as an identifier and any comment that starts with ‘TODO: can be seen the list inside the “Task List” window. This list also acts as bookmarks. Double-clicking any item in the list takes you to the file and line where ‘TODO: is found. There are a couple of other identifier that are in Visual Studio 2005 by default. New identifier tags can also be added as required in the “Tools” -> Options” dialog. In the “Options” dialog, select the “Environment -> Task List” option on the left pane. The screen below shows how to add a new identifier.
Now any comment in your code that starts with an ‘REFACTOR: will also be listed in the “Task List” window.
When you select “User Tasks” from the drop down list on the top, the “Task List” window displays a list where new tasks can be added. This a a real simple list where you can add and manage task items that you need to keep track of. When a task is completed, the checkbox on the task item can be checked, which will strike the text in the task. Even though these features may not meet all the requirements for a good “To Do” list, it is handy and can be used in moderation to be useful.
An abstract base class to facilitate persistence in the ESRI framework
There are different ways in which .NET types can be persisted using the ESRI persistence framework. Personally, I use an “sbPersistable” abstract base class to make the persistence easier. The sbPersistable is an utility class that can be inherited by classes that need to persist and rehydrate themselves to a stream. It implements most of the common methods required for persistence and only requires the implementing classes to store and retrieve their properties from its PersistPropertySet property. A sample class that implements and uses sbPersistable to support persistence is shown below. In the example, the implementing class simply overrides the ToPropertySet() and the FromPropertySet() methods to achieve its persistence.
Public Class PersistenceSample
Inherits sbPersistable
Private _name As String
Private _age As Integer
Public Property Name() As String
Get
Return _name
End Get
Set(ByVal value As String)
_name = value
End Set
End Property
Public Property Age() As Integer
Get
Return _age
End Get
Set(ByVal value As Integer)
_age = value
End Set
End Property
Public Overloads Overrides Sub ToPropertySet()
MyBase.ToPropertySet()
PersistPropertySet.SetProperty(“Name”, _name)
PersistPropertySet.SetProperty(“Age”, _age)
End Sub
Public Overloads Overrides Sub FromPropertySet()
MyBase.FromPropertySet()
_name = DirectCast(PersistPropertySet.GetProperty(“Name”), String)
_age = DirectCast(PersistPropertySet.GetProperty(“Age”), Integer)
End Sub
End Class
The class stores all its properties into a “PropertySet” and persists and rehydrates the “PropertySet” as a whole instead of persisting and rehydrating each property individually. The “sbPersistable” class also implements a couple of other interfaces “IsbClassID” and “IsbClassInstanceID” that enable applications using the class to identify and compare objects even after persistence and rehydration. The “sbPersistable” class and other utility classes can be downloaded here.
”’ <summary>
”’ Provides access to members used to persist objects
”’ </summary>
<Guid(“658CE48F-D5D4-4aa5-BC0C-AD542326C69E”)> _
<ProgId(“Common.GIS.sbPersistable”), ClassInterface(ClassInterfaceType.None)> _
Public MustInherit Class sbPersistable
Implements IsbPersistable
Implements IsbClassID
Implements IsbClassInstanceID
Protected _persistPropertySet As IPropertySet = New PropertySet()
Private _classInstanceID As String = Guid.NewGuid().ToString()
Public Sub New()
_classInstanceID = Guid.NewGuid().ToString()
End Sub
#Region “IsbClassID Members”
Public ReadOnly Property ClassID() As String Implements IsbClassID.ClassID
Get
Return Me.GetType().GUID.ToString()
End Get
End Property
#End Region
#Region “IsbClassInstanceID Members”
Public ReadOnly Property ClassInstanceID() As String Implements IsbClassInstanceID.ClassInstanceID
Get
Return _classInstanceID
End Get
End Property
#End Region
#Region “IsbPersistable Members”
Public Property PersistPropertySet() As IPropertySet Implements IsbPersistable.PersistPropertySet
Get
Return _persistPropertySet
End Get
Set(ByVal value As IPropertySet)
_persistPropertySet = value
End Set
End Property
Public Overridable Sub ToPropertySet() Implements IsbPersistable.ToPropertySet
PersistPropertySet.SetProperty(“ClassInstanceID”, ClassInstanceID)
End Sub
Public Overridable Sub FromPropertySet() Implements IsbPersistable.FromPropertySet
_classInstanceID = DirectCast(PersistPropertySet.GetProperty(“ClassInstanceID”), String)
End Sub
#End Region
#Region “IPersistStream Members”
Public Sub GetClassID(ByRef pClassID As Guid) Implements IPersistStream.GetClassID, IPersist.GetClassID
pClassID = Me.GetType().GUID
End Sub
Public Sub GetSizeMax(ByRef pcbSize As ESRI.ArcGIS.esriSystem._ULARGE_INTEGER) Implements IPersistStream.GetSizeMax
pcbSize = New _ULARGE_INTEGER()
pcbSize.QuadPart = CType(Marshal.SizeOf(PersistPropertySet), ULong)
End Sub
Public Sub IsDirty() Implements IPersistStream.IsDirty
End Sub
Public Sub Load(ByVal pstm As ESRI.ArcGIS.esriSystem.IStream) Implements IPersistStream.Load
Try
PersistPropertySet = New PropertySetClass()
TryCast(PersistPropertySet, ESRI.ArcGIS.esriSystem.IPersistStream).Load(pstm)
FromPropertySet()
Catch ex As Exception
Throw New Exception(“An unexpected error occurred while rehydrating object from stream.”, ex)
End Try
End Sub
Public Sub Save(ByVal pstm As ESRI.ArcGIS.esriSystem.IStream, ByVal fClearDirty As Integer) Implements IPersistStream.Save
Try
ToPropertySet()
TryCast(PersistPropertySet, ESRI.ArcGIS.esriSystem.IPersistStream).Save(pstm, fClearDirty)
Catch ex As Exception
Throw New Exception(“An unexpected error occurred while persisting object to stream.”, ex)
End Try
End Sub
#End Region
End Class
Follow Me
Contact me