Exemple #1
0
        public void Initialize(InstanceContext instanceContext, Message message)
        {
            // Read the context id from the Message.Properties collection.
            // NOTE: This property is made available by our custom channel.
            string contextId =
                (string)message.Properties[DurableInstanceContextUtility.ContextIdProperty];

            InstanceContextExtension extension =
                new InstanceContextExtension(contextId, storageManager);

            instanceContext.Extensions.Add(extension);
        }
Exemple #2
0
        public object InvokeEnd(object instance, out object[] outputs, IAsyncResult asyncResult)
        {
            // Finish invoking the operation using the inner operation
            // invoker.
            object result = innerOperationInvoker.InvokeEnd(instance, out outputs, asyncResult);

            // Save the instance using the storage manager saved in the
            // current InstanceContext.
            InstanceContextExtension extension =
                OperationContext.Current.InstanceContext.Extensions.Find <InstanceContextExtension>();

            extension.StorageManager.SaveInstance(extension.ContextId, instance);
            return(result);
        }
Exemple #3
0
        public object GetInstance(InstanceContext instanceContext, Message message)
        {
            object instance = null;

            InstanceContextExtension extension =
                instanceContext.Extensions.Find <InstanceContextExtension>();

            string          contextId      = extension.ContextId;
            IStorageManager storageManager = extension.StorageManager;

            //Get the instance from the storage manager.
            instance = storageManager.GetInstance(contextId, serviceType);

            // If the storage manager returns null (which means that there is
            // no instance available for the given context id) create a new
            // instance and return it.
            if (instance == null)
            {
                instance = Activator.CreateInstance(serviceType);
            }

            return(instance);
        }