Home > PropertyTree > Welcome to the Machine – Introducing PropertyTree

Welcome to the Machine – Introducing PropertyTree

In this first post I will introduce you to PropertyTree, a data structure that I developed to handle the problem of adding custom fields to a record in a database and that has also proven very useful for client/server communication, validation and filling a whole host of other needs.

The Problem

It all started when I began developing a Business Process Modeling framework to replace the old Workflow framework that is the platform for all applications developed by the company I currently work for.

One of the features of the current framework is the ability to store arbitrary bits of information for a given Activity Instance in a SQL Server database. To do this, for each Activity Instance record in the activity_instance table, one or more data items are stored in a separate activity_instance_items table. This proves to be a problem when you need to retrieve the data items because you have to pivot the data to produce a package with all the required data bits.

The other problem is that the data is stored as a string in a varchar(8000) so on retrieval the programmer needs to cast the string into the original data type and the only way of knowing the appropriate data type is to inspect the data records directly or treat them all as string, something that happens quite a lot.

The Solution

As I designed the new framework I figured that a better way would be to store all the data items of an Activity Instance directly in it’s record in a XML field. That would keep all data items together with there respective instance in the same table. Also, since we are using XML, now we have the ability to store items hierarchically along with meta-data to describe each item.

And So PropertyTree Was Born

A PropertyTree allows you to store data items kind of like the old PropertyBag of early Visual Basic (pre .Net) or the Session-State Store in ASP.Net.

Data items are stored as a collection of nodes from a root node and each node itself can have a collection of nodes allowing for a tree like structure to be formed.

Each node has meta-data to indicate, among other things, the data type of it’s stored data, formatting information and validation rules. You can also add your own meta-data items through custom attributes.

A PropertyTree also exposes events for changes in values of properties and attributes as well as when validating value assignments and for handling validation errors.


This is a list of features that are exposed by the PropertyTree:

  • Hierarchical collection of data items (PropertyNodes).
  • PropertyNodes contain strongly-typed values.
  • PropertyNodes can have meta-data in the form of attributes.
  • Validation information can be defined for a PropertyNode like for example:
    • Minimum value
    • Maximum value
    • Minimum and maximum length
    • A regular expression mask of allowed characters
    • A list of allowed values
  • These validation rules can be applied to a single PropertyNode or in Types that can be reused on any number of nodes.
  • An output format for a PropertyNode can be defined.
  • Events are raised for:
    • After a change in PropertyNode value (PropertyChanged event)
    • After a change in an attribute of a PropertyNode (PropertyAttributeChanged event)
    • When non-existing PropertyNode is referenced (PropertyNotFound event)
    • A hook to allow custom validation to be performed (ValidateValue event)
    • When a value assigned to a PropertyNode has caused a validation error (ValidationException event)
  • A PropertyTree can be used on a client of a web app using a JavaScript implementation that has also been created.


What’s Next?

In future posts I’ll dive deeper into each of these features starting with how to create an instance of a PropertyTree and add nodes with validation.

Digg This
Categories: PropertyTree Tags:
  1. No comments yet.
  1. December 4, 2009 at 5:47 PM

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: