Untitled

Random thoughts about everything and nothing

Archive for March 2006

Features missing in VSTS – Part One

leave a comment »

Dear Easter Bungie,

What I would like for easter (and not as an egg):

– a simple compare directories in source explorer
– and once your at it…add open with…context menu too
– detach workspaces from pc + user
– maybe include connection to source safe

Written by Michael

March 30, 2006 at 9:17 pm

Posted in VSTS

Searching the MSDN blogs

leave a comment »

We can now search through the MSDN blogs using the MSDN lab search….

Written by Michael

March 30, 2006 at 9:14 pm

Posted in Link, MSDN

Silly formatter

leave a comment »

Why use padleft, when you can use formatters?!!!

private void button1_Click(object sender, System.EventArgs e)
{
string a = "aaa";
textBox1.Text = String.Format(new SillyFormat(), "{0:Z10}", a) ;
}
private void Dummy_Load(object sender, System.EventArgs e)
{

}
public class SillyFormat : IFormatProvider, ICustomFormatter
{

public object GetFormat (Type service)

{
if (service == typeof (ICustomFormatter))
{
return this;
}
else
{
return null;
}
}

public string Format (string format, object arg, IFormatProvider provider)
{
if (arg == null)
{
throw new ArgumentNullException("Please provide argument to format.");
}
if (format != null && arg is string)
{
string s = format.Trim().ToLower();
string ret = (string) arg;
if (s.StartsWith("z"))
{
format = format.Trim (new char [] {'Z'});
int pos = Convert.ToInt32( format ) - ret.Length;
if ( pos > 0 )
{
ArrayList items = ArrayList.Repeat("0", Convert.ToInt32( format ) - ret.Length);
items.Add(ret);
string[] strings = (string[]) items.ToArray(typeof(String));
ret = String.Join("",strings);
}
}
return ret;
}
else if (arg is IFormattable)
{
return ((IFormattable)arg).ToString(format, provider);
}
else
{
return arg.ToString();
}

}
}

Written by Michael

March 30, 2006 at 9:11 pm

Posted in .NET, CodeSnippet

Macros – Visual Studio 2003

leave a comment »

Been going through my existing VS.NET 2003 macros the other day… Close all active documents:

Sub CloseAllDocuments()
Try
If DTE.ActiveDocument.Collection.Count > 0 Then
DTE.ActiveDocument.Collection.CloseAll()
End If
Catch
‘Lazy catch, we do nothing
End Try
End Sub

Or just use “>Edit.CloseAll” in the immediate window.

To collapse all projects in the solution explorer:

Sub CollapseAll()
Dim UIHSolutionExplorer As UIHierarchy
UIHSolutionExplorer = DTE.Windows.Item( _
Constants.vsext_wk_SProjectWindow).Object() If (UIHSolutionExplorer.UIHierarchyItems.Count = 0) Then
MsgBox(“Nothing to collapse. You must have an open solution.”)
Return
End If

Dim UIHSolutionRootNode As UIHierarchyItem
UIHSolutionRootNode = UIHSolutionExplorer.UIHierarchyItems.Item(1)

Dim UIHItem As UIHierarchyItem
For Each UIHItem In UIHSolutionRootNode.UIHierarchyItems
UIHItem.UIHierarchyItems.Expanded = False
Next

UIHSolutionRootNode.Select(vsUISelectionType.vsUISelectionTypeSelect)
End Sub

Written by Michael

March 19, 2006 at 12:21 am

Posted in VSX

Comparing folders in Team Foundation Source Control

leave a comment »

1. go to VS2005 command prompt
2. tf diff path1 path2 /recursive /noprompt

Written by Michael

March 17, 2006 at 3:55 pm

Posted in VSTS

ExpressionBuilder

leave a comment »

While fooling around with my Web.config I stumbled on a nice feature in ASP.NET (2.0): ExpressionBuilder classes.

Basically, these classes let you set control properties through *ahem* expressions.

When the page is parsed, the declarative expressions will be used to retrieve the actual value(s). This done through the ExpressionBuilder class.

The framework ships with three expression builder classes, each accessing different resource settings:

  • AppSettingsExpressionBuilder, allows access to the connection strings stored in section of the configuration file;
  • ConnectionStringsExpressionBuilder, allows access to the application settings stored in section of the configuration file;
  • ResourceExpressionBuilder, allows access to localized resources, typically stored in .resx files located in the App_GlobalResources and App_LocalResources folders.

To actually set these expressions, we don’t need to write it out in the property, but we can use Property Inspector > Data > Expressions.

Now the really nice part is yet to come, we can create our own ExpressionBuilders (both design/run-time support). A good place to start is here and ofcourse your local MSDN documentation.

Written by Michael

March 5, 2006 at 10:51 pm

Posted in .NET, Article

Quote of the day

leave a comment »

Nice quote…

“The secret to being a successful programmer is to never act surprised when it works.”
(Bob Dickson)

Written by Michael

March 5, 2006 at 8:33 pm

Posted in Fun