Click or drag to resize

ExtensibilityEventImplAttribute Class

Inheritance Hierarchy
SystemObject
  SystemAttribute
    PDTec.IceNet.Core.Runtime.ExtensibilityExtensibilityEventImplAttribute

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 class ExtensibilityEventImplAttribute : Attribute

The ExtensibilityEventImplAttribute type exposes the following members.

Constructors
  NameDescription
Public methodExtensibilityEventImplAttribute
Initializes a new instance of the ExtensibilityEventImplAttribute class
Top
Properties
  NameDescription
Public propertyInterface
Gets or sets the CLR type of the Business Object interface that should be tied to the ice.NET object type identified by the ObjTypeName property.
Public propertyTypeId
When implemented in a derived class, gets a unique identifier for this Attribute.
(Inherited from Attribute.)
Top
Methods
  NameDescription
Public methodEquals
Returns a value that indicates whether this instance is equal to a specified object.
(Inherited from Attribute.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Returns the hash code for this instance.
(Inherited from Attribute.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodIsDefaultAttribute
When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class.
(Inherited from Attribute.)
Public methodMatch
When overridden in a derived class, returns a value that indicates whether this instance equals a specified object.
(Inherited from Attribute.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
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