Data Object Base – a WPF compatible data class

The DataObjectBase class is a class that can be used to quickly implement data objects that must support the following requirements:

1) Fully serializable
2) Support property changed notifications
3) Backwards compatibility
4) Error checking
5) Backup & revert

Detailed information

1) Fully serializable

The class is fully serializable and thus can be used in remoting, the System.AddIn namespace (which is implemented via Remoting) and in serialization to disk or any other type of storage.

The object is also clonable, so it is very easy to create a deep-clone copy of the object.

2) Support property changed notifications

The class implements the INotifyPropertyChanged notification. This allows the class to be used in WPF environment, where all the data objects must implement INotifyPropertyChanged in order to let the WPF engine know when a property has changed.

3) Backwards compatibility

The class allows backwards compatibility through the RedirectTypeAttribute. In case that the class cannot deserialize an object correctly, it will switch to "redirect" mode to try and solve any redirected classes.

4) Error checking

The class implements the IDataErrorInfo interface so it can let interested objects know whether it contains errors or not.

5) Backup & revert

The class implements the IEditableObject interface. Therefore, it is very easy to create an initial state when opening the object ina window with a call to the BeginEdit method. When the user wants to save the data, simply call the EndEdit function to remove the backup and continue with the data the user entered. If the changes by the user should be discarded, simply make a call to the CancelEdit method.

Property definitions

Properties are defined in a really easy way (in the same manner that you need to define dependency properties):

/// 
/// Gets or sets the filename property.
/// 
public string FileName
{
	get { return GetValue(FileNameProperty); }
	set { SetValue(FileNameProperty, value); }
}

/// 
/// Register the property so it is known in the class.
/// 
public readonly PropertyData FileNameProperty = RegisterProperty("FileName", typeof(string), string.Empty);

Important license information

The license that is inlcuded in this package (license.html) applies to all source files and executables, except for these files:

* CatenaLogic.dll
* CatenaLogic.Windows.dll

They are included for demo purposes only and may not be used in (non-)commercial applications without a written notice from the author (CatenaLogic).

Example application

The example application shows a simple class (that represents an entry in an ini-file) with validation. Of course, the class is much more powerful than shown in the demo application, but it should give you enough information to get a basic understanding of the class.

dataobjectbase_exampleapp

Important: this article has been updated! A new version is available here!

DataObjectBase.zip (337.36 kb) [Downloads: 111]

kick it on DotNetKicks.com

Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList

WebSVN extension

WebSVN is a great way to view Subversion repositories in a web browser. It supports viewing the source code, blaming, log messages and more. It even supports parent listing so you can view multiple repositories in the same directory in one clear overview.

However, as always, I do the things just a little different than others. My subversion repositories are sorted by company and project. An example:

RepoExample

As you can see, the repositories are divided into logical (at least, I find them logical :)) groups. However, this setup required me to host several different versions of WebSVN:

  • RepoExample (root)
  • companies/company1
  • companies/company2
  • companies/sites

This is because the list parent only lists one directory, not all subdirectories.

To solve this problem, I have written a small extension. The extension really works very simply. You select a root directory (in the example case, RepoExample). Then, the extension will search all subdirectories and check whether the specific directory is a Subversion repository (by checking the directory structure).

It lists all the top directories as groups, and then adds all sub repositories into that group. The result of the extension:

websvn_result

As you can see, it adds a group (directory name except the repository name, such as companies/company_1). Then, all repositories are added after the dot (.).

There is just one downside of this extension: the default authentication files per repository are not recognized. In other words, everyone that is allowed to log in via Apache in the root where WebSVN is located (via webdav modules), is able to see the repository index.

To add this extension to your WebSVN installation, simply perform the following steps described in the readme.

WebSVN extension.zip (4.58 kb) [Downloads: 46]

kick it on DotNetKicks.com 

Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList

Sort Visual Studio 2008 Projects alphabetically inside Solution Folders

It is a known bug that Visual Studio does not sort projects alphabetically when the projects are located inside Solution Folders. Since I am working on pretty large solutions (more than 20 projects for 1 solution), and I like to order the projects via Solution Folders, this is a very irritating bug.

However, I accidently found the solution to this problem. Follow the steps below to sort your projects alphabetically inside Solution Folders.

  1. Right-click on a project and select rename (or simple select a project, wait 1 second, and click it again or press F2)
  2. Don’t change the name, simply select another project

Et voila, your projects are sorted like Visual Studio should do!

kick it on DotNetKicks.com

Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList

Welcome to my blog

Welcome to my first blog entry on this blog.

I start this blog since I sometimes walk into problems where the solution is hard to find. Most people (in this case, developers) use Google (or another searchengine) to find a solution to the problems they walk into.

However, sometimes even Google can't help you out and you have to find out the information yourself. For the problems I solve myself (sometimes with the help of others), this will be a new place where I will blog all problems, and even more important, the solution to these problems.

I hope you will enjoy my blog!

Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList