To enable an application to become a context participant create a class that implements the IContextParticipant interface. The class implementation is required to be a COM object. As a result the ComVisibleAttribute is required when decalring the class.
C#[ComVisible(true)]T public class ContextParticipant:IContextParticipant { }VB
<ComVisible(True)>_ Public Class ContextParticipant Implements IContextParticipant End Class
IContextManager ContextManager = Utils.COMCreateObject<IContextManager>("CCOW.ContextManager");
After an application has joined a context session, call the IContextData.GetItemNames method and the IContextData.GetItemValues method to get the current context session state.
If an application has suspended its participation in a context session by calling the IContextManager.SuspendParticipation method it can rejoin the session by calling the IContextManager.ResumeParticipation method. If the application has disconnected from the context session by calling the IContextManager.LeaveCommonContext method it will need to call the IContextManager.JoinCommonContext method to rejoin the context session.
When initiating a context change, an application needs to perform the following steps:
Handling a Survey
To handle a survey request an application needs to respond to the IContextParticipant.ContextChangesPending method. It should return the appropriate response string (accept, conditionally _accept) based on the current application state.
Handling Survey Failure
During a context change transaction, the application that instigated the context transaction informs participants that it has completed the context change by calling the ContextManager.EndContextChanges. If any participant applications are unable to make the change, the user will be informed that there is a problem. To complete the changes the instigating application will need to call IContextManger.LeaveCommonContext. This disconnects the instigating application from the context session and prevents spreading the changes to the other session participants.
Participating in a Secure Context System
In order to participate in a context system and securely bind to the ContextManager, an application needs to perform the following steps:
Authentication Repository
The LEADTOOLS CCOW SDK implements the interface IAuthenticationRepository. Users wishing to implement an Authentication Repository need to derive a class from the IAuthenticationRepository interface.
public class AuthenticationRepository:IAuthenticationRepository { }
All context agents (mapping, annotation and action) implement the Leadtools.Ccow.IContextAgent interface. The difference between the context agents is in the implementation of the agent's Leadtools.Ccow.IContextParticipant.ContextChangesPending(System.Int32,System.String@) method.