If you have read my very first post on this new blog you will know that I am now running dasBlog, and publishing through Windows Live Writer. It is such an effortless thing to do using such an powerful tool. Well I have always seen for example on Scott Hanselman's site the nice decoration of script examples, and I really should have just asked I suppose, "Where did you get that plugin from lol." Either way I think I found it, well if it is not the same it is still ok because this one I have found certainly does the trick.
For anyone else wanting to use it BTW, the project is on CodePlex at this URL :
http://www.codeplex.com/wlwSyntaxHighlighter
Since I am publishing some of my posts onto two blogs now, It is only functioning on my personal blog at http://www.andrewrea.co.uk, but I will be adding this to my asp.net blog as soon as I figure out how. I am sure there is a way of including a JS File inside the template. There will be I am sure.
The little bit of code below, "the test," is just a little analysis of a URI. It is not long since I discovered that the URI actually yields a string array called segments which very kindly deals with splitting up the url for you, at least the part after the domain and host type thing anyway. All the same tis handy.
[STAThread]
static void Main(string[] args)
{
StringBuilder sb1 = new StringBuilder();
Uri u1 = new Uri("http://www.formula1.com/Folder1/Folder2/Folder3/default.aspx?SampleQueryString=12");
foreach (PropertyInfo pi in typeof(Uri).GetProperties())
{
sb1.AppendLine(pi.Name + ":" + pi.GetValue(u1, null));
}
foreach (string s in u1.Segments)
{
sb1.AppendLine(String.Format("Segment : {0}", s));
}
Clipboard.SetDataObject(sb1.ToString(), true);
Console.ReadLine();
}
The output.
/*
AbsolutePath:/Folder1/Folder2/Folder3/default.aspx
AbsoluteUri:http://www.formula1.com/Folder1/Folder2/Folder3/default.aspx?SampleQueryString=12
Authority:www.formula1.com
Host:www.formula1.com
HostNameType:Dns
IsDefaultPort:True
IsFile:False
IsLoopback:False
IsUnc:False
LocalPath:/Folder1/Folder2/Folder3/default.aspx
PathAndQuery:/Folder1/Folder2/Folder3/default.aspx?SampleQueryString=12
Port:80
Query:?SampleQueryString=12
Fragment:
Scheme:http
OriginalString:http://www.formula1.com/Folder1/Folder2/Folder3/default.aspx?SampleQueryString=12
DnsSafeHost:www.formula1.com
IsAbsoluteUri:True
Segments:System.String[]
UserEscaped:False
UserInfo:
Segment : /
Segment : Folder1/
Segment : Folder2/
Segment : Folder3/
Segment : default.aspx
*/
Another thing which I have been using of late is Reflector too. This allows me to see the actual .NET source code for all of the assemblies e.g. System.Web, amazingly handy tool this one and FREE.
http://www.red-gate.com/products/reflector/
Of late I have had to make various Web Controls and Composite Controls and I wanted to get a real feel for the base class for which I am inheriting from so I could really get the most out of it. Anyway have a go and disassemble away. One thing you may wonder is what happens when you do not wish your code to be susceptible to such a tool, well what you can do is follow the process of Obfuscation.
http://msdn.microsoft.com/en-gb/magazine/cc164058.aspx
Cheers,
Andrew