UccContext Constructor

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

Initializes a new instance of the UccContext Class .

Namespace: Microsoft.Office.Interop.UccApi
Assembly: Microsoft.Office.Interop.UccApi (in microsoft.office.interop.uccapi.dll)

Syntax

'Declaration
Public Sub New
public UccContext ()
public:
UccContext ()
public UccContext ()
public function UccContext ()

Remarks

The constructor takes no arguments. A context is normally created to be used as an argument to a method. An example of this is the CreateParticipant method exposed by the IUccSession interface. In this case, as in all cases of this type, the context argument is not optional but a null value can be passed. The context argument of such methods as CreateParticipant is IUccContext, the primary interface of UccContext. Because an application obtains the default interface of UccContext directly, either an IUccContext or a UccContext may be passed as an argument to these methods.

When a client application must provide unique contextual information about the IUccSessionParticipant created by the CreateParticipant method, a UccContext class or default interface instance must be passed rather than a null value. The resulting IUccSessionParticipant exposes the context provided by CreateParticipant in its Context property.

An application will typically create a new UccContext object when the client is to call any operational method such as Enable, Publish, and Subscribe. These operational method parameter lists include the IUccOperationContext type. This interface exposes a Context property. The Context property must be filled with an instance of the IUccContext interface.

Events raised by operational methods provide the context of the operation in the form of an IUccOperationContext property exposed by one of the dispinterface arguments.

Example

The following example creates a new UccContext class instance filled in the Context property of an IUccOperationContext interface. The IUccOperationContext interface is returned to calling code to be used as an operational context argument to an operational method.

private UccOperationContext createOperationContext(string key, string value)
{
    UccOperationContext oc = new UccOperationContext();
    UccContext c = new UccContextClass();
    c.AddNamedProperty(key, value);
    oc.Initialize(1, c);
    return oc;
}

The following is an event handler for the subscribe operation. The original operation context created for the subscribe operation is exposed by pEventInfo. An operational method may be called with a null operational context. For this reason, it is important to verify the OriginalOperationContext is not null before proceeding.

void _IUccSubscriptionEvents.OnSubscribe(
   UccSubscription pSubscription,
   UccSubscriptionEvent pEventInfo)
{
   if (Object.ReferenceEquals(pSubscription, this.selfSubscription))
   {
      IUccOperationProgressEvent opEvent = pEventInfo.GetOperationInfo(selfPresentity);
      if (opEvent.IsComplete)
      {
         UccOperationContext oc = opEvent.OriginalOperationContext;
         if (oc != null)
         {
            IUccContext c = oc.Context;
            if (c != null && c.IsNamedPropertySet("SubscribeCtx"))
            {
               IUccProperty p = c.get_NamedProperty("SubscribeCtx");
               Console.WriteLine("Subscribe Context: " + p.ToString());
            }
         }
      }
   }
}

Platforms

Development Platforms

Windows XP Professional with Service Pack 2 (SP2), Windows Server 2000 with Service Pack 4, Windows Server 2003, Windows Vista Ultimate Edition, Windows Vista Business Edition, Windows Vista Enterprise Edition

Target Platforms

See Also

Reference

UccContext Class
UccContext Members
Microsoft.Office.Interop.UccApi Namespace