Thursday, February 19, 2009
Nikhil Kothari a software architect on Microsoft's .NET Developer Platform group has created a free tool called Script# that allows you write C# code that will be compiled into JavaScript. Using Script# you can take advantage of all your existing .NET tools and the power of Visual Studio. According to nikhil's own site Script# is used extensively within Microsoft when building Ajax experiences in Windows Live and Office along with external companies such as Facebook.

The Script# web site is http://projects.nikhilk.net/ScriptSharp, you can download Script# for Visual Studio 2005 or 2008. Along with the plug-ins for Visual Studio there is a very good PDF Readme that contains lots of examples of using Script#.

Nikhi also has a roadmap for Script# two notable additions are planned for 2009 Unit testing support and jQuery support. This is something I'm playing with and I think is worth checking out.

posted on Thursday, February 19, 2009 11:46:27 PM (GMT Standard Time, UTC+00:00)  #    Add Comment | Comments [0]
 Tuesday, February 17, 2009
With the advent of Windows PowerShell automating tasks in windows should now be a sinch for a .NET developer as PowerShell's scripting language is relatively easy to a C# programmer to pickup (trust me I've come down the path). One of the things I have a lot of is MP3 files from my extensive music collection and various podcats that I listen to, so I needed a way to manipulate these tags for example change some details such as adding missing information or even move the files into my music folderr structure.

A library that allowed me to do this easily was TagLib Sharp. It's avaliable from Novell and will work with .NET and Mono.

Because this is a .NET assembly you are free to use it in your C#, Visual Basic .NET. To use the library with any of thse languages simply add the assembly as a reference to your project and add the appropriate using or imports statement to the top of the class file that will use the library. However as PowerShell is my new best friend I'll show you how to use the library with PowerShell.

To use any assembly in your PowerShell script you can use the Assembly class in the System.Reflection namespace. The Assembly classes has the static LoadFile method that allows you to specify a location to load a dll from.

[Reflection.Assembly]::LoadFile("C:\Users\Alan\Code\PowerShell\MyScripts\taglib-sharp-dotnet20.dll")


Once you have imported the assembly as shown above you can begin to use it to modify settings on you media files. For example the line below will create a File object that represents the specified physical media file.

$media = [TagLib.File]::Create( "$filePath" )

Once this has been done you simply access the various tags using $media.Tag.XXX. The script below will set the Title and Track information.

$media.Tag.Title = $matches["title"]
$media.Tag.Track = $trackNum.ToString()

Once you have set the tags to the values you want you save the changes by calling the Save method on the media file object.

$media.Save()

One thing I did notice when using this library was that it failed to set the tags if they previously had no value so to get around this I manually set the tags to a character for sting values and 1 for numberic values suchas year and track number.




posted on Tuesday, February 17, 2009 3:16:51 PM (GMT Standard Time, UTC+00:00)  #    Add Comment | Comments [0]
 Sunday, February 15, 2009
This is one of the books from Manning with the cool covers that I like. This book has been written by Bruce Payette one of the designers of PowerShell. Because of this the book offers in-depth information on many aspects of PowerShell.  The book is split into two sections. Part one focuses on the basics, it covers using PowerShell at the command line and writing and run your own scripts. I read the nine chapters in this section from start to finish and was please to find lots of working and easy to follow code examples which I could play with and easily refer back to as I wrote my own scripts. I found this section greatly enhanced my knowledge of PowerShell in a short space of time, I would put this down to a good balance between verbose text and script examples to experiment with and if you are like me and learn beat by doing this book will suit you. The second section covered more advanced topics such as:
  1. Processing text files and XML
  2. .NET and WinForms
  3. Windows objects: COM and WMI
  4. Security

These were also detailed chapters with good examples however to date I have gotten more use from chapters 10 and 11 this is no fault  with the book it’s more of a reflection on what I’ve been working with recently. Since taking the time to sit down with this book I have become very keen on PowerShell especially having seen and used the scripting tools available on Linux and UNIX.

I found the book well structured and importantly for me it contains lots of script examples. Previously I had tried to learn PowerShell simply from various web sites however lack of discipline kept getting in the way. With the book I was able to discipline myself better and managed to work through this book in just over one week. Now I’m able to write my own scripts and when I’ve needed to I’ve found it very easy to refer back to the book. The back cover says that this is a book for sysadmins and developers, I would agree with this and would recommend this book for people with previous scripting of programming experience if you don’t have these then a more basic beginners book may allow you to make more progress.

The books web site: http://www.manning.com/payette/

posted on Sunday, February 15, 2009 6:18:46 PM (GMT Standard Time, UTC+00:00)  #    Add Comment | Comments [0]
 Thursday, February 12, 2009
If you are writing any scripts for PowerShell I'd recommend looking at PowerGUI Script Editor. It's a free comunity project that has some really nice features you now expect when writting code such as intelli-sense, syntax highlighting and the ability to debug your script.

The overall aim of the project is to create a GUI for Windows PowerShell where you can manipulate objects in PowerShell by pointing and clicking. For example there is bundled functionality to list all process running on the current system invoke actions on these processes such as stopping the process. Personally I just use the script editor to edit my scripts and as I have customized my PowerShell as described in a previous post, it easy for me to then execute these scripts as I need.




posted on Thursday, February 12, 2009 2:26:33 PM (GMT Standard Time, UTC+00:00)  #    Add Comment | Comments [0]
 Wednesday, February 11, 2009
Like alot of people my maths was stronger than my english at High School, probably one of the reason I was attracted to computer programming in the first place. Even today one of my weaker points would be spelling. If you're like me fear not help is at hand from ComponentOne with IntelliSpell.

IntelliSpell is an addon for Visual Studio 2008 or 2005 that will spell check your comments, strings, HTML, XML resources and general text. There is a free community edition and a Professional edition at $79.99 which offers a few more features. You get a comparison of the two editions along with download and purchase links at: http://www.componentone.com/SuperProducts/IntelliSpell/

Once you have installed IntelliSpell the spellchecker is avaliable from Visual Studio's tools menu as shown in the screenshot. With the Professional edition you get the ability to spell check an entier solution at once along with 'as-you-type spell-checking', but with the community edtion you spell check one file at time, still better than we had before. Any spelling mistakes will be shown in the task list.






The task list showing the spelling mistakes in the current document:





The IntelliSpell window that allows you to move from spelling mistake to spelling mistake and correct them as you go.




posted on Wednesday, February 11, 2009 3:12:35 PM (GMT Standard Time, UTC+00:00)  #    Add Comment | Comments [1]