ExtensibilityEventImplAttribute Class |
Namespace: PDTec.IceNet.Core.Runtime.Extensibility
public class ExtensibilityEventImplAttribute : Attribute
The ExtensibilityEventImplAttribute type exposes the following members.
Name | Description | |
---|---|---|
ExtensibilityEventImplAttribute | Initializes a new instance of the ExtensibilityEventImplAttribute class |
Name | Description | |
---|---|---|
Interface |
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.
| |
TypeId | When implemented in a derived class, gets a unique identifier for this Attribute. (Inherited from Attribute.) |
Name | Description | |
---|---|---|
Equals | Returns a value that indicates whether this instance is equal to a specified object. (Inherited from Attribute.) | |
Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) | |
GetHashCode | Returns the hash code for this instance. (Inherited from Attribute.) | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
IsDefaultAttribute | When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class. (Inherited from Attribute.) | |
Match | When overridden in a derived class, returns a value that indicates whether this instance equals a specified object. (Inherited from Attribute.) | |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
ToString | Returns a string that represents the current object. (Inherited from Object.) |
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.
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:
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.
PackageImportedEventArgs pEventArgs = ExtensibilityManager.TriggerEvent<IPackageImportedEvent, PackageImportedEventArgs>(() => new PackageImportedEventArgs { Repository = Repository; ImportedPackage = pPackage; EventMessages = new StringBuilder(); }); if (pEventArgs != null) { Console.WriteLine(pEventArgs.EventMessages.ToString(); }
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.
[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.
<ice.net>
<extensibility>
<implementationAssembly assemblyName="MyCorp.MyApp.BusinessLogic"/>
</extensibility>
</ice.net>