
As I mentioned a few articles ago, the VDF has the concept of client properties. On top of that, the VDF gives you the ability to add your own. The main advantage here is that it gives you a column of your very own in the VDF grid. Beyond that, most of the work is up to you. You need to set the value. If you want to persist the data, that’s also up to you.
Perhaps it’s best if I show a quick example. Let’s create a property called “my prop def”, and set values based on a counter that I increment.

Step 1: Define a class the implements IPropertyExtensionProvider.
IPropertyExtensionProvider can do a lot of things. Here I’m using it to supply a client property definition to the VDF. I’m also using it to provide the values to that property when the VDF asks for them.
|
classMyPropertyProvider : IPropertyExtensionProvider { PropertyDefinition m_myPropDef; long m_counter = 1;
public MyPropertyProvider() { m_myPropDef = newPropertyDefinition("myPropDef"); }
publicvoid DecoratePropertyDefinitions(…) { // not needed in this example. }
publicIEnumerable<PropertyDefinition> GetCustomPropertyDefinitions(…) { return m_myPropDef.ToSingleArray(); }
publicvoid PostGetPropertyValues(…) { // not needed in this example. }
publicvoid PreGetPropertyValues( PropertyValues resultValues, {
foreach (var entity in entities) { foreach (var propDef in propDefs.Values) { // ingore other properties if (propDef.SystemName != m_myPropDef.SystemName) continue;
// set the value for our custom property. resultValues.SetValue(newPropertyValue( entity, propDef, m_counter.ToString())); m_counter++; } } }
publicstring[] SupportedEntityClasses { get { returnnull; } } } |
Step 2: Register your provider.
|
MyPropertyProvider myProvider = newMyPropertyProvider(); VDF.Vault.Library.PropertyExtensionRegistration. |
Step 3: Enjoy.
You can now use the column in any of your UI that uses the VDF. Even if a VDF grid doesn’t explicitly set the column, the property shows up in the list when the user goes to customize the columns.
If your app is a Vault Explorer 2014 plug-in, your custom property is not available in the main grid or any of the default tabs. This is because those grids are not true VDF grids. (Fun fact: The file browser on the Attach command does used the VDF grid, so you can see your custom properties there)

Leave a Reply to Doug RedmondCancel reply