Monday, November 5, 2007

Itunes StreamReader

Preperation to take certifications can be quite boring, and Im about to take the ".NET Framework 2.0 Application Developement Foundation".

So I have made an ItunesStreamReader that I use to count the size of all my media files in a nice litle pie chart.

I have try to performance test it by take two itunes Files (3.9mb + 1+9mb = 5.8mb) merge and exstraced all the tracks and putted them into a DropdownList it took 845.1 milli seconds


A simple example of using the ItunesStreamReader could looks like this.

using(ItunesStreamReader its = new ItunesStreamReader ( new ItunesItem.items[] { ItunesItem.items.name, ItunesItem.items.trackNumber } ))
{
while(!its.EndOfStream()) { string name = its.ReadLine(); string number = its.ReadLine(); Console.WriteLine(string.Format("Name {0} Number {1} ", name, number));
}
}


If you want to play with it you can download it here.

Feedback and suggenstions would be great :o)

Saturday, October 27, 2007

The WebNavigator

What is the Web Navigator?!
Well the Web Navigator is a techhnique, or pattern that I was introduced to from a podcast by Craig Shoemaker at http://polymorphicpodcast.com "Download example code"This pattern is a great way of creating Contracts for Your Web Pages, so its much easier to manage navigation throughout your websites.Some of the strength that i like about it, is that it "Encapsulate page locations" , "Makes the code easy to read and maintain" and make contract of a page requirements.

The Code
Lets say that you need to se a profile page, and that page show userinfo by a querystring, the code could look like this.string userName;
// set userName to something... perhaps from the database
WebNavigator.GoTo(WebNavigator.URLFor.Profile(userName));

class WebNavigator
{
public void GoTo(string url)
{
HttpContext.Current.Response.Redirect(url,true);
}
public string Profile(string userName)
{
return string.Format("~/login/default.aspx?userName={0}",userName);
}
}

You could make it more dynamically so you dont have to recompile if the url changes, by store the urls in xml or whatever you like.
In umbraco the method could look like this.

public string Profile(string userName) { return umbraco.library.GetDictionaryItem("ProfileUrl") + "?" + userName);
}

Wednesday, October 10, 2007

VS 2008 certifications

There have ben announced new certifications for vs 2008 - Great!.. Now I know what to do after my MCPD webdeveloper exams.

Exam 70-502: Microsoft .NET Framework 3.5 - Windows Presentation Foundation - 11/09/2007Exam 70-503: Microsoft .NET Framework 3.5 - Windows Communication Foundation - 11/08/2007Exam 70-504: Microsoft .NET Framework 3.5 - Workflow - 11/15/2007Exam 70-561: TS: Microsoft .NET Framework 3.5 - ADO.NET - 1/17/2008Exam 70-562: TS: TS: Microsoft .NET Framework 3.5 - ASP.NET - 1/31/2008

Where did I fount the informations here

Thursday, September 27, 2007

New Feature ChildrenAsTable

Umbraco V3 offers many things! and one og them is you now have the posibillity to get you Nodes as a datatable object.
This is great if you love your Usercontrols, repeaters and databinding :)

Niels Hartvig have written an article about how to use the datatable "ChildrenAsTable"

Its a good article, but there is some confusion when you need to get the properties from a node.

Normally when you need a property you retrieves it with the alias, so I tried to make a simple test.
<asp:repeater id="Repeater1" runat="server"><itemtemplate> <a href="'<%#">'><%# Eval("NodeName")%></a> <%# ((DataRowView)Container.DataItem)["umbNaviHide"]%> </itemtemplate></asp:Repeater>

This gave me an error on the umbracoNaviHide, and I thougt whats was wrong with that?

After some debugging I found out that you needs to use the name of the property instead of the Alias, so it looks like this:

<asp:repeater id="Repeater1" runat="server"><itemtemplate>
<a href="'<%#">'><%#Eval("NodeName")%></a>
<%# ((DataRowView)Container.DataItem)["Hide in navigation"]%>
</itemtemplate>
</asp:Repeater>

And then it just worked :)

/Happy coding
Read Nielses article here
<a href="http://www.umbraco.org/documentation/books/what" target="_blank">http://www.umbraco.org/documentation/books/what's-new-in-v3/new-feature-nodefactory-as-datatable-object</a>

Sunday, September 23, 2007

MSBuild - What a tool

MSbuild is a great tool to do automatied stuff.

Introduction to <a href="http://www.codeproject.com/books/msbuild.asp" target="_blank">MSBuild</a>
I have used it for some time now on my Umbraco projects, and it really saves me alot of time.
In my project I create a MSBuild script that copies my assembly and usercontrols to my local website, every time i buíld my project.
so my debugging steps change from 7 to 5 steps.

1. Build Project
2. Copy assmbly files to bin folder on IIS [now Automated]
3. Copy ascx files to usercontrols folder on IIS [now Automated]
4. Open website in IE
5. Attach my project to w
6. Go to page that has to be debugged.
7. Find and solve problem.
My msBuld script:


<target name="PostBuildEvent">
<createitem include="$(ProjectDir)$(OutputPath)$(AssemblyName).dll">
<output taskparameter="Include" itemname="OutputFiles"></createitem>
<message text="Copying '%(OutputFiles.Filename)%(OutputFiles.Extension)' FooBar bin directory" importance="high">
<copy sourcefiles="@(OutputFiles)" destinationfolder="$(SolutionDir)bin" continueonerror="false" skipunchangedfiles="true">
</target>

Another way to use MSBuild is to have different configuration settings for production and testing environments read about it on <a href="http://weblogs.asp.net/scottgu/archive/2007/09/21/tip-trick-automating-dev-qa-staging-and-production-web-config-settings-with-vs-2005.aspx" target="_blank">Scott Gu's blog</a>

Tuesday, August 21, 2007

Is the boolean really 4 bytes long?

I read for some time ago ".NET FRAMEWORK 2.0 Application Developent Foundation" that the value type Boolean was 4 Bytes.
And I thought hey a boolean is only a byte of value 0 or 1, and thats only 1 byte!

So I Tried to write the size out and endeed it was 4 bytes : Console.WriteLine(System.Runtime.InteropServices.Marshal.SizeOf(typeof (Boolean)));

After that result, I googled for more info. And read that aBoolean value is a pure true or false value in C#
If any have a good explanation please blog it!!...

Tuesday, June 19, 2007

♥ Just married ♥

My best day ever!...
I got married 06-09-2007 and everything was just perfect, the weather, food the live band etc....

It all startet in the chirch, all the benches was full of people we know - Great but nervous :o)
After the chirch we took a cadilac and got our traditionally wedding pictures.

After the wedding dance I had a little surprise for the guys! I knew they would cut of my socks and as a good person I am :) I gave them 3 pairs....



We were dancing to the early morning 04:20 AM, and gladly it was not only me and my wife that was having a blast.