Click or drag to resize

IExtensibilityEventArgs Interface

Use interfaces deriving from this interface to declare custom ice.NET extensibility events.

Namespace:  PDTec.IceNet.Core.Runtime.Extensibility
Assembly:  PDTec.IceNet.Core (in PDTec.IceNet.Core.dll) Version: 7.2.0.0 (7.2.7583.15464)
Syntax
C#
public interface IExtensibilityEvent<Args>

Type Parameters

Args
The custom event data type.

The IExtensibilityEventArgs type exposes the following members.

Methods
  NameDescription
Public methodExecute
Top
Examples

This example explains how to define and trigger ice.NET extensibility events. We define a IPackageImportedEvent event triggered by an application function to provide the possibility to implement some additional functionality after the actual import.

First we declare the PackageImportedEventArgs class to represent the event data.

C#
public class PackageImportedEventArgs
{
    public IDatabaseRepository Repository
    {
        get;
        internal set;
    }

    public IPackage ImportedPackage
    {
        get;
        internal set;
    }

    public StringBuilder EventMessages
    {
        get;
        internal set;
    }
}

Next we declare the event interface itself:

C#
public interface IPackageImportedEvent : IExtensibilityEvent<PackageImportedEventArgs>
{
}

The following code shows how to trigger the event inside the implementation of an application. Afterwards the application accesses the event implementation data. If no event implementation has been registered, the TriggerEvent method returns null instead of the event arguments instance.

C#
PackageImportedEventArgs pEventArgs = ExtensibilityManager.TriggerEvent<IPackageImportedEvent, PackageImportedEventArgs>(() => new PackageImportedEventArgs
{
    Repository        = Repository;
    ImportedPackage = pPackage;
    EventMessages    = new StringBuilder();
});

if (pEventArgs != null)
{
    Console.WriteLine(pEventArgs.EventMessages.ToString();
}
Examples

This example explains how to implement and register ice.NET extensibility events.

The following code shows how to implement an event handler. The EventImpl attribute connects the implementation class to the event interface.

C#
[ExtensibilityEventImpl(Interface=typeof(IPackageImportedEvent))]
public class PackageImportedEventImpl : IPackageImportedEvent
{
    public void Execute(PackageImportedEventArgs e)
    {
        string packageName = e.Package.Name;

        if (string.IsNullOrEmpty(e.Package.Description))
        {
            e.Package.Description = "This is a newly imported package.";
        }

        e.EventMessages.AppendLine("Imported package [" + e.Package.Name + "].");
    }
}

The following code shows how to register the event implementation assembly.

C#
<ice.net>
    <extensibility>
        <implementationAssembly assemblyName="MyCorp.MyApp.BusinessLogic"/>
    </extensibility>            
</ice.net>
See Also