Advanced programming


From .NET you know the principle of event programming and the declaration of events with the event-keyword. Unfortunately, this works only in the same Applicationdomain and not network wide. The iPlus framework provides the concept of "event points" for network-transparent event programming:

 


In the chapter Client-/Service-Points the principle of consumer and service in connection with Points was explained.

Events are based on the same design pattern and are only an advanced implementation (blue dashed frame):

 

IACPointEvent<T> inherits from two interfaces:

  1. IACPointNet<T, W> - A network-capable IACPoint<W> that is able to transfer its ConnectionList property over the network.
  2. IACPointNetService<T, W>, that represents a "service point". A service point provides a service for its ConnectionList entries in the abstract sense. This interface is also the basis for providing asynchronous methods.

The ACPointEvent class implements IACPointEvent<T>.  ACPointEvent-instances allow components to provide events that can be subscribed to across the network. The event subscriptions are entered in the ConnectionList. Consumers (components from the same or a remote application domain) cannot populate the ConnectionList directly, but need the IACPointEventSubscr interface:

IACPointEventSubscr<T> inherits from two interfaces:

  1. IACPointNet<T, W> - A network-capable IACPoint<W> that is able to transfer its ConnectionList property over the network.
  2. IACPointNetClient, which represents a "client point". In the abstract sense, a client point represents a consumer who uses service points. This interface is also the basis for calling asynchronous methods.

The ACPointEventSubscr class implements IACPointEventSubscr<T>.

 

Workflows

Workflows, which are loaded during runtime, are event-driven. They use two special Implementations of IACPointEvent<T> und IACPointEventSubscr<T> - The ACPointEvent- and PWPointIn class (a derivation of PWPointEventSubscr).


The special thing about event points is that when an event occurs, callback methods are called at the client component. These callback methods have the following signature:

public delegate void ACPointNetEventDelegate(IACPointNetBase sender, ACEventArgs e, IACObject wrapObject);

A client component must provide such a delegate method and pass it for subscribing the event by calling one of the Subscribe methods that provides the IACPointEventSubscr<T> interface:

ACPointEventSubscrWrap<T> SubscribeEvent(IACObject atACComponent, string eventName, ACPointNetEventDelegate AsyncCallbackDelegate);

ACPointEventSubscrWrap<T> SubscribeEvent(IACObject atACComponent, string eventName, string asyncCallbackDelegateName);

bool SubscribeAllEvents(IACComponent atACComponent, ACPointNetEventDelegate AsyncCallbackDelegate);

 

To unsubscribe an event, the delegate does not have to be passed:

bool UnSubscribeEvent(IACComponent atACComponent, string eventName);

bool UnSubscribeAllEvents(IACComponent atACComponent);

bool UnSubscribeAllEvents(IACComponent atACComponent);

bool UnSubscribeAllEvents();

ACPointEvent-points must be labeled with the ACPropertyEventPoint attribute class, as shown in the following example code:

 

To raise an event to notify all Subscribers, the Raise() method must be called. The Raise method expects to pass a parameter of type ACEventArgs. ACEventArgs is a list of type ACValue. ACEventArgs are similar to the ResultValueList in virtual methods. The ACEventArgs templates are stored in a local dictionary, ACEventArgs>, and registered in the static constructor. Before the event is triggered, the ACEventArgs.GetVirtualEventArgs() method clones the parameter list, then the parameters has to be filled and finally passed to the Raise() method.


Subscription points for events (ACPointEventSubscr) must be labeled with the ACPropertyEventPointSubscr attribute class, as shown in the following example code: