Exemple #1
0
        private void BookmarkResumptionCallback(NativeActivityContext context, Bookmark bookmark, object value)
        {
            NoPersistHandle noPersistHandle = this.NoPersistHandle.Get(context);

            noPersistHandle.Exit(context);
            System.IAsyncResult result = value as System.IAsyncResult;
            this.EndExecute(context, result);
        }
        protected override void Execute(NativeActivityContext context)
        {
            string          bookmarkName           = BookmarkName.Get(context);
            NoPersistHandle noPersistHandleToEnter = noPersistHandle.Get(context);

            noPersistHandleToEnter.Enter(context);
            Bookmark bookmark = context.CreateBookmark(bookmarkName,
                                                       (NativeActivityContext _callbackContext, Bookmark _bookmark, object _state) =>
            {
                NoPersistHandle noPersistHandleToExit = noPersistHandle.Get(_callbackContext);
                noPersistHandleToExit.Exit(_callbackContext);
            });

            this.bookmark.Set(context, bookmark);
        }
Exemple #3
0
        protected override void Execute(NativeActivityContext context)
        {
            NoPersistHandle noPersistHandle = this.NoPersistHandle.Get(context);

            noPersistHandle.Enter(context);
            Bookmark bookmark = context.CreateBookmark(new BookmarkCallback(this.BookmarkResumptionCallback));

            this.Bookmark.Set(context, bookmark);
            BookmarkResumptionHelper helper = context.GetExtension <BookmarkResumptionHelper>();

            System.Action <System.IAsyncResult> state = delegate(System.IAsyncResult result)
            {
                helper.ResumeBookmark(bookmark, result);
            };
            System.IAsyncResult asyncResult = this.BeginExecute(context, new System.AsyncCallback(this.AsyncCompletionCallback), state);
            if (asyncResult.CompletedSynchronously)
            {
                noPersistHandle.Exit(context);
                context.RemoveBookmark(bookmark);
                this.EndExecute(context, asyncResult);
            }
        }
        protected override void Execute(NativeActivityContext context)
        {
            Message inMessage = null;

            try
            {
                inMessage = this.Message.Get(context);
                object[] outObjects;
                if (this.parameters == null || this.parameters.Count == 0)
                {
                    outObjects = Constants.EmptyArray;
                }
                else
                {
                    outObjects = new object[this.parameters.Count];
                }

                // The formatter would be null if there is no parameters to Deserialize in message contracts
                if (this.Formatter != null)
                {
                    this.Formatter.DeserializeRequest(inMessage, outObjects);
                }
                else
                {
                    Fx.Assert(this.parameters == null, "There shouldn't be any parameters to be deserialized");
                }

                if (this.parameters != null)
                {
                    for (int i = 0; i < this.parameters.Count; i++)
                    {
                        OutArgument outArgument = this.parameters[i];
                        Fx.Assert(outArgument != null, "Parameter cannot be null");

                        object obj = outObjects[i];
                        if (obj == null)
                        {
                            obj = ProxyOperationRuntime.GetDefaultParameterValue(outArgument.ArgumentType);
                        }

                        outArgument.Set(context, obj);
                    }
                }
            }
            finally
            {
                if (this.CloseMessage && inMessage != null)
                {
                    inMessage.Close();
                }

                this.Message.Set(context, null);

                bool useNoPersistHandle = UseNoPersistHandle(context);
                if (useNoPersistHandle)
                {
                    NoPersistHandle handle = (this.NoPersistHandle == null) ? null : this.NoPersistHandle.Get(context);
                    if (handle != null)
                    {
                        handle.Exit(context);
                    }
                }
            }
        }