Property Handler Decisions and Preparation
Viewed as a data flow component, a property handler has a single file stream input and outputs a one or more properties. Unfortunately, writing one requires making many decisions before you even set eyes on the code. Let's look at a few of these preparations.
First, pick a file type. You'll be writing a property handler for this file type.
Now decide which properties you want to store. Properties generally fall into a few categories. Take a moment to consider which of the following you want to support:
- System defined properties (e.g. System.Author)
- Properties you define for your filetype (e.g. MyCompany.MyApp.MyProperty)
- Properties other people define and want to set on your file (e.g. SomeoneElse.Other.Property, aka "open metadata")
Next, decide where in the file you'll be storing the properties. Hopefully the file's format allows for this already. If it doesn't, you'll have to collaborate with other users of this file format to accomodate these properties. Here are a few storage options:
- Compute the property from other data in the file (e.g. System.Document.WordCount)
- Read the property from a specific location in the file (e.g. the EXIF header in certain image formats)
- Read the property from a dynamic storage structure (e.g. suitable for storing SomeoneElse.Other.Property)
Once you know where to place your properties, you get to decide how to format them in your file. Will you turn them into strings? Or would a binary format be better? Maybe you'll want to store some properties directly in the file format and others into a special dumping ground for open metadata.
Also quite important is choosing which API you will use to write to the file format. Hopefully it supports stream inputs. If it doesn't you'll have to flag your handler as "legacy". Typically you'll end up writing a small layer mapping propert keys and values to whatever the format-specific API uses.
There is one easy decision in this mix. Choose your programming language from the following list: C++, C. Regrettably, shell extensions cannot use the CLR, so you may not use C# or any other .NET language.
As you can see, there are a lot of little decisions you get to make when writing a property handler. There are undoubtedly more that I've missed, but you'll stumble upon those as you prepare your handler. Additionally, there are many little options and flags you can use to tweak the way your property handler works and to accomplish more advanced tasks. I am skipping those for now in favor of presenting them as a list later.