Data dictionary plugins can be used to customize the data dictionary at runtime, such as programmatically adding custom fields that exist in the end-user's database to your project's data dictionary, or to determine what version the database is so versioned objects are used correctly.

A data dictionary plugin implements the IStonefieldQueryDataDictionaryPlugin interface in Interfaces.dll and uses the StonefieldQueryDataDictionaryPlugin attribute. Your plugin needs references to the Collections, Enums, Interfaces, PluginManager, and System.ComponentModel.Composition assemblies (the first four are Stonefield Query assemblies and the latter is a .NET assembly). It may also need references to other Stonefield Query assemblies, depending on what the plugin does; these can be found in the SQWeb\bin folder.

Studio can generate the source code for a plugin for you; see the Generating Plugin Source Code topic for details.

IStonefieldQueryDataDictionaryPlugin

Here's the definition of IStonefieldQueryDataDictionaryPlugin:

using System;
using Stonefield.Query.DataDictionary;

namespace Stonefield.Query.Plugins
{
    /// <summary>
    /// The interface that DataDictionary plugins must implement.
    /// </summary>
    public interface IStonefieldQueryDataDictionaryPlugin :
        IStonefieldQueryBasePlugin
    {
        /// <summary>
        /// Called after the data dictionary collections are loaded.
        /// </summary>
        void AfterLoaded();

        /// <summary>
        /// Called before the data dictionary collections are loaded.
        /// </summary>
        void BeforeLoaded();

        /// <summary>
        /// Get the version number for the specified table.
        /// </summary>
        string GetVersion(ITable item);

        /// <summary>
        /// Get the version number for the specified field.
        /// </summary>
        string GetVersion(IField item);

        /// <summary>
        /// Get the version number for the specified join.
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        string GetVersion(IJoin item);

        /// <summary>
        /// A reference to the application's DataDictionary.
        /// </summary>
        IDataDictionary DataDictionary { get; set; }
    }
}

(As with all plugins that derive from IStonefieldQueryBasePlugin, it also has an Application member; see the Plugins topic for information about Application.)

StonefieldQueryDataDictionaryPlugin

The StonefieldQueryDataDictionaryPlugin attribute on the plugin class has the usual set of parameters all plugin attributes do; see the Plugins topic for details. Here's an example:

[StonefieldQueryDataDictionaryPlugin("{815AB23B-403D-418C-A85D-DE8B3B5595FB}",
    "SampleDataDictionaryPlugin",
    PluginSource.Custom, 
    Version = "1.0.0.0", 
    ExecutionPriority = 5)]
public class SampleDataDictionaryPlugin :
    IStonefieldQueryDataDictionaryPlugin

Plugin properties

DataDictionary is a reference to an IDataDictionary object. Although you may think you can access the data dictionary through the DataDictionary member of Application, at the time that BeforeLoaded and AfterLoaded are called, Application.DataDictionary hasn't been set yet and is null. So, to access the data dictionary, use the DataDictionary member of the plugin instead.

Plugin methods

Data dictionary plugins have the following methods:

See Also

Plugins