Wednesday, October 03, 2007
Apparently this will help get the hits up

Technorati Profile
10/3/2007 4:07 PM Romance Daylight Time  #    Disclaimer  |  Comments [0]  |  Trackback
 Tuesday, October 02, 2007
Funny I just noticed that the dasblog textbox has an insertcode button and you can even enter VB.Net code.

Everyday I become a little smarter. Soon I will be concurring the world ;-).

10/2/2007 3:42 PM Romance Daylight Time  #    Disclaimer  |  Comments [0]  |  Trackback
Today I found this little piece of code

Public Class SingletonProvider(Of itemtype As {New})
    Public Sub New()
    End Sub


    Public Shared ReadOnly Property Instance() As itemtype

        Get
            Return SingletonCreator.instance
        End Get

    End Property
    Class SingletonCreator
        Shared Sub New()
        End Sub

        Public Shared ReadOnly instance As itemtype = New itemtype()
    End Class
End Class

From this site.

I find this very usefull code since it will allow me to create singleton forms. Making Forms singleton is nearly impossible as we all know because of the designer and VS. So we have to work around that a bit (yeah I know it's bad when you have to work around the IDE to get something done). And that's where this piece of code comes in handy.

10/2/2007 3:39 PM Romance Daylight Time  #    Disclaimer  |  Comments [0]  |  Trackback
 Sunday, September 30, 2007
Today I worked on making a Weathercontrol for windowsForms. I based it very loosely on this article but I made it more MVCish and layered. I'm still working on the comments and test but here it is so far.




The file can be found here

You will need to register here.

Find the settings file that contains the settings (hey I'm not going to tell you everything) and change them appropriately. Meaning add you Licensekey, partnerId and LocationId.

I will try and improve it in the next couple of days. Stay tuned.

Oh yeah, feel free to use it.



9/30/2007 6:22 PM Romance Daylight Time  #    Disclaimer  |  Comments [0]  |  Trackback
 Saturday, September 29, 2007
Lately I have been having a bit of trouble with settings files. There was a time where I thought they would be just the thing that you needed for configuration but now I 'm not so sure anymore. Anyway first I will show what settings files are since I think not many people use them. BTW I'm talking about settings files that are used in Visual studio and I think that's they went a bit overboard on them.

So here is how you create them. Just right click your project and then click add and new item.




You could change the name ofcourse but be a good programmer and be lazy ;-) .

And this is how it looks after you click Add.





I added 2 settings FormText as String with the scope of User and LabelText with the scope of Application. The scope thing is important since Application scoped settings can only be changed in the designer (Well that was the intention anyway) and User scoped settings can be changed by the "User". Meaning at runtime.

So there you have it the settings file in short.In the next part I will explain how they can be used (even simpler) and what files VS created to make this work.


9/29/2007 12:47 PM Romance Daylight Time  #    Disclaimer  |  Comments [0]  |  Trackback
 Friday, September 28, 2007
So know that we got our class up and running (unit test and all) we want to connect it to a database. At first this class will look like a DTO but it could be more. So don't let yourself be fooled.

First of all I needed to change the properties to make them virtual (C#) or better overridable (VB.Net). Why? Because I didn't know better and I did what it told me to do. But now I understand. It needs this for its lazy loading. That way it can make a sub class of your class and it just needs to overload the properties. At the mean while it also overloads the compareto method which was un unwanted side effect for me. It overloads it so that it starts sorting on the Id field.

Now for the mapping.
NHibernate like Hibernate uses mapping files to map the properties to columns in the database. But some nice guy also provided us with attributes to make it eassier to make the mapping files or make no mapping files at all.

So the attributes you see are from that.

I used nHibernate 1.2.1 for this

Enjoy

Imports NHibernate
Imports NHibernate.Mapping.Attributes

Namespace Model
''' <summary>
'''
''' </summary>
''' <remarks></remarks>
<CLSCompliant(True)> _
<NHibernate.Mapping.Attributes.JoinedSubclass(0, table:="tbl_Person", lazy:=False)> _
Public Class Person2
Implements IComparable

#Region " Private members "
''' <summary>
''' A local variable called _id of type Guid
''' </summary>
''' <remarks>Has Property Id</remarks>
Private _id As Guid
''' <summary>
''' A local variable called _firstName of type String
''' </summary>
''' <remarks>Has Property FirstName</remarks>
Private _firstName As String
''' <summary>
''' A local variable called _lastName of type String
''' </summary>
''' <remarks>Has Property LastName</remarks>
Private _lastName As String
#End Region

#Region " Constructors "
''' <summary>
''' Default empty constructor
''' </summary>
''' <remarks></remarks>
Public Sub New()
'TODO : Implement default constructor
End Sub

''' <summary>
''' Constructor with all the fields
''' </summary>
''' <param name="Id">DataType = Guid</param>
''' <param name="FirstName">DataType = String</param>
''' <param name="LastName">DataType = String</param>
''' <remarks></remarks>
Public Sub New(ByVal Id As Guid, ByVal FirstName As String, ByVal LastName As String)
Me.Id = Id
Me.FirstName = FirstName
Me.LastName = LastName
End Sub
#End Region

#Region " Public properties "
''' <summary>
''' This is the Id property.
''' </summary>
''' <value>Guid</value>
''' <returns>Guid</returns>
''' <remarks></remarks>
<NHibernate.Mapping.Attributes.Id(0, typetype:=GetType(Guid), Name:="Id") _
, NHibernate.Mapping.Attributes.Generator(1, Class:="guid.comb")> _
<NHibernate.Mapping.Attributes.Key()> _
Public Overridable Property Id() As Guid
Get
Return _id
End Get
Set(ByVal Value As Guid)
_id = Value
End Set
End Property

''' <summary>
''' This is the FirstName property.
''' </summary>
''' <value>String</value>
''' <returns>String</returns>
''' <remarks></remarks>
<NHibernate.Mapping.Attributes.Property()> _
Public Overridable Property FirstName() As String
Get
Return _firstName
End Get
Set(ByVal Value As String)
_firstName = Value
End Set
End Property

''' <summary>
''' This is the LastName property.
''' </summary>
''' <value>String</value>
''' <returns>String</returns>
''' <remarks></remarks>
<NHibernate.Mapping.Attributes.Property()> _
Public Overridable Property LastName() As String
Get
Return _lastName
End Get
Set(ByVal Value As String)
_lastName = Value
End Set
End Property
#End Region

#Region " Overrides ToString "
''' <summary>
''' Overridden ToString method for this class
''' </summary>
''' <returns>String</returns>
''' <remarks>The String value of this class represented by the ToStrings of all it's private members</remarks>
Public Overrides Function ToString() As String
Dim ReturnString As New System.Text.StringBuilder()
ReturnString.Append("[Id: " & _id.ToString() & "]")
ReturnString.Append(" - [FirstName: " & _firstName.ToString() & "]")
ReturnString.Append(" - [LastName: " & _lastName.ToString() & "]")
Return ReturnString.ToString()
End Function
#End Region

#Region " Overrides Equals "
''' <summary>
''' Overridden Equals method for this class
''' </summary>
''' <returns>Boolean</returns>
''' <remarks>The Boolean value indictaing if this is equal to the other class</remarks>
Public Overrides Function Equals(ByVal obj As Object) As Boolean
If obj.GetType Is Me.GetType Then
Return Me._id.Equals(CType(obj, Person2)._id)
Else
Return False
End If
End Function
#End Region

#Region " Overrides CompareTo "
''' <summary>
''' Overridden CompareTo method for this class
''' </summary>
''' <returns>Integer</returns>
''' <remarks></remarks>
Public Function CompareTo(ByVal obj As Object) As Integer Implements System.IComparable.CompareTo
If obj.GetType Is Me.GetType Then
Return Me._id.CompareTo(CType(obj, Person2)._id)
Else
Return -1
End If
End Function
#End Region
End Class
End Namespace

9/28/2007 3:30 PM Romance Daylight Time  #    Disclaimer  |  Comments [0]  |  Trackback
Today I decided to change mailserver. up untill now I had been using my companies SMTP server to send all the notifcation mails. But I decided that it was time for some more control so I installed hMailServer.

Since all my notification are internal installing an emailserver just for this seemed more appropriate and now it even seemed easy. And I no longer hold all the other users up when everything goes wrong at the same time.

You have to know that I have 4 programs sending me mail every day. Namely Backu exec. to tell me that the backup went ok or not. Finalbuilder to tell me the build was ok or not. SQlserver with a story or two and the UPS that seem to loose connection once in a while.

At least it makes me feel important.


9/28/2007 2:09 PM Romance Daylight Time  #    Disclaimer  |  Comments [0]  |  Trackback
For the last few days I have been testing this.
And believe me it's wonderfull. Its' a lot eassier then making MSBuild or nAnt files and I believe it is even more versatile.

It is especially usefull if you have no real person in the team that is resmonsible for the builds.

Finalbuilder is ideal for all you .Net building works.

Now let's build.

However it not free.

9/28/2007 2:00 PM Romance Daylight Time  #    Disclaimer  |  Comments [0]  |  Trackback
 Sunday, September 09, 2007
Process explorer

Get it while it's hot.


9/9/2007 2:20 PM Romance Daylight Time  #    Disclaimer  |  Comments [0]  |  Trackback
 Monday, September 03, 2007
In the beginning of this year (april) I started using nHibernate. Having some experience in Hibernate (Java) I knew what to expect. So without RTFM or not enough anyway I started implementing it. And I used the attribute framework that came with it (version 1.2 beta 3) at the time. The learning curve was a bit high and over the next few posts you will understand why.

First of all I will start with a simple example which works well. In the beginning I couldn't find any good example in VB.Net using the attributes all were in C#.

nHibernate can be downloaded here

So this is what a normal class would look like in the Chrissie1 universe. Nothing special a person with a firstname and lastname. And you will notice that I already added an Id In a perfect world I wouldn't need an Id since firstname and lastname togther would make for a perfect id, but since the perfect world only exists on TV I add it since the beginning. I can always add comparers/constraints later. In the next post I will change it to suit the needs of nHibernate. But for now enjoy it's beauty.
Namespace Model
''' <summary>
''' A normal person
''' </summary>
''' <remarks>For testing purposes</remarks>
Public Class Person
Implements IComparable

#Region " Private members "
''' <summary>
''' A local variable called _id of type String
''' </summary>
''' <remarks>Has Property Id</remarks>
Private _id As Guid
''' <summary>
''' A local variable called _firstName of type String
''' </summary>
''' <remarks>Has Property FirstName</remarks>
Private _firstName As String
''' <summary>
''' A local variable called _lastName of type String
''' </summary>
''' <remarks>Has Property LastName</remarks>
Private _lastName As String
#End Region

#Region " Constructors "
''' <summary>
''' Default empty constructor
''' </summary>
''' <remarks></remarks>
Public Sub New()
Me.New(Guid.NewGuid, "", "")
End Sub

''' <summary>
''' Constructor with all the fields
''' </summary>
''' <param name="Id">DataType = String</param>
''' <param name="FirstName">DataType = String</param>
''' <param name="LastName">DataType = String</param>
''' <remarks></remarks>
Public Sub New(ByVal Id As Guid, ByVal FirstName As String, ByVal LastName As String)
Me.Id = Id
Me.FirstName = FirstName
Me.LastName = LastName
End Sub
#End Region

#Region " Public properties "
''' <summary>
''' This is the Id property.
''' </summary>
''' <value>Guid</value>
''' <returns>Guid</returns>
''' <remarks></remarks>
Public Property Id() As Guid
Get
Return _id
End Get
Set(ByVal Value As Guid)
_id = Value
End Set
End Property

''' <summary>
''' This is the FirstName property.
''' </summary>
''' <value>String</value>
''' <returns>String</returns>
''' <remarks></remarks>
Public Property FirstName() As String
Get
Return _firstName
End Get
Set(ByVal Value As String)
_firstName = Value
End Set
End Property

''' <summary>
''' This is the LastName property.
''' </summary>
''' <value>String</value>
''' <returns>String</returns>
''' <remarks></remarks>
Public Property LastName() As String
Get
Return _lastName
End Get
Set(ByVal Value As String)
_lastName = Value
End Set
End Property
#End Region

#Region " Overrides ToString "
''' <summary>
''' Overridden ToString method for this class
''' </summary>
''' <returns>String</returns>
''' <remarks>The String value of this class represented by the ToStrings of all it's private members</remarks>
Public Overrides Function ToString() As String
Dim ReturnString As New System.Text.StringBuilder()
ReturnString.Append("[Id: " & _id.ToString() & "]")
ReturnString.Append(" - [FirstName: " & _firstName.ToString() & "]")
ReturnString.Append(" - [LastName: " & _lastName.ToString() & "]")
Return ReturnString.ToString()
End Function
#End Region

#Region " Overrides Equals "
''' <summary>
''' Overridden Equals method for this class
''' </summary>
''' <returns>Boolean</returns>
''' <remarks>The Boolean value indictaing if this is equal to the other class</remarks>
Public Overrides Function Equals(ByVal obj As Object) As Boolean
If obj.GetType Is Me.GetType Then
Return Me._id.Equals(CType(obj, Person)._id)
Else
Return False
End If
End Function
#End Region

#Region " Overrides CompareTo "
''' <summary>
''' Overridden CompareTo method for this class
''' </summary>
''' <returns>Integer</returns>
''' <remarks></remarks>
Public Function CompareTo(ByVal obj As Object) As Integer Implements System.IComparable.CompareTo
If obj.GetType Is Me.GetType Then
Return Me._id.CompareTo(CType(obj, Person)._id)
Else
Return -1
End If
End Function
#End Region

End Class
End Namespace

9/3/2007 12:38 PM Romance Daylight Time  #    Disclaimer  |  Comments [0]  |  Trackback