// This ctor is only used by subclasses which make their own determination about no persist or not
 protected BookmarkWorkItem(BookmarkCallbackWrapper callbackWrapper, Bookmark bookmark, object value)
     : base(callbackWrapper.ActivityInstance)
 {
     this.callbackWrapper = callbackWrapper;
     this.bookmark        = bookmark;
     this.state           = value;
 }
Exemplo n.º 2
0
        public BookmarkResumptionResult TryGenerateWorkItem(ActivityExecutor executor, bool isExternal, ref Bookmark bookmark, object value, ActivityInstance isolationInstance, out ActivityExecutionWorkItem workItem)
        {
            Bookmark internalBookmark = null;
            BookmarkCallbackWrapper callbackWrapper = null;

            if (!this.TryGetBookmarkFromInternalList(bookmark, out internalBookmark, out callbackWrapper))
            {
                workItem = null;
                return(BookmarkResumptionResult.NotFound);
            }

            bookmark = internalBookmark;
            if (!ActivityUtilities.IsInScope(callbackWrapper.ActivityInstance, isolationInstance))
            {
                workItem = null;

                // We know about the bookmark, but we can't resume it yet
                return(BookmarkResumptionResult.NotReady);
            }

            workItem = callbackWrapper.CreateWorkItem(executor, isExternal, bookmark, value);

            if (!BookmarkOptionsHelper.SupportsMultipleResumes(callbackWrapper.Options))
            {
                // cleanup bookmark on resumption unless the user opts into multi-resume
                Remove(bookmark, callbackWrapper);
            }

            return(BookmarkResumptionResult.Success);
        }
 // This ctor is only used by subclasses which make their own determination about no persist or not
 protected BookmarkWorkItem(BookmarkCallbackWrapper callbackWrapper, Bookmark bookmark, object value)
     : base(callbackWrapper.ActivityInstance)
 {
     this.callbackWrapper = callbackWrapper;
     this.bookmark = bookmark;
     this.state = value;
 }
 public BookmarkWorkItem(ActivityExecutor executor, bool isExternal, BookmarkCallbackWrapper callbackWrapper, Bookmark bookmark, object value) : this(callbackWrapper, bookmark, value)
 {
     if (isExternal)
     {
         executor.EnterNoPersist();
         base.ExitNoPersistRequired = true;
     }
 }
 public BookmarkWorkItem(ActivityExecutor executor, bool isExternal, BookmarkCallbackWrapper callbackWrapper, Bookmark bookmark, object value)
     : this(callbackWrapper, bookmark, value)
 {
     if (isExternal)
     {
         executor.EnterNoPersist();
         this.ExitNoPersistRequired = true;
     }
 }
 private void AddBookmark(Bookmark bookmark, BookmarkCallback callback, System.Activities.ActivityInstance owningInstance, BookmarkOptions options)
 {
     if (this.bookmarks == null)
     {
         this.bookmarks = new Dictionary<Bookmark, BookmarkCallbackWrapper>(Bookmark.Comparer);
     }
     bookmark.Scope = this.scope;
     BookmarkCallbackWrapper wrapper = new BookmarkCallbackWrapper(callback, owningInstance, options) {
         Bookmark = bookmark
     };
     this.bookmarks.Add(bookmark, wrapper);
     owningInstance.AddBookmark(bookmark, options);
     if (TD.CreateBookmarkIsEnabled())
     {
         TD.CreateBookmark(owningInstance.Activity.GetType().ToString(), owningInstance.Activity.DisplayName, owningInstance.Id, ActivityUtilities.GetTraceString(bookmark), ActivityUtilities.GetTraceString(bookmark.Scope));
     }
 }
Exemplo n.º 7
0
        private void AddBookmark(Bookmark bookmark, BookmarkCallback callback, System.Activities.ActivityInstance owningInstance, BookmarkOptions options)
        {
            if (this.bookmarks == null)
            {
                this.bookmarks = new Dictionary <Bookmark, BookmarkCallbackWrapper>(Bookmark.Comparer);
            }
            bookmark.Scope = this.scope;
            BookmarkCallbackWrapper wrapper = new BookmarkCallbackWrapper(callback, owningInstance, options)
            {
                Bookmark = bookmark
            };

            this.bookmarks.Add(bookmark, wrapper);
            owningInstance.AddBookmark(bookmark, options);
            if (TD.CreateBookmarkIsEnabled())
            {
                TD.CreateBookmark(owningInstance.Activity.GetType().ToString(), owningInstance.Activity.DisplayName, owningInstance.Id, ActivityUtilities.GetTraceString(bookmark), ActivityUtilities.GetTraceString(bookmark.Scope));
            }
        }
Exemplo n.º 8
0
        public BookmarkResumptionResult TryGenerateWorkItem(ActivityExecutor executor, bool isExternal, ref Bookmark bookmark, object value, System.Activities.ActivityInstance isolationInstance, out ActivityExecutionWorkItem workItem)
        {
            Bookmark internalBookmark = null;
            BookmarkCallbackWrapper callbackWrapper = null;

            if (!this.TryGetBookmarkFromInternalList(bookmark, out internalBookmark, out callbackWrapper))
            {
                workItem = null;
                return(BookmarkResumptionResult.NotFound);
            }
            bookmark = internalBookmark;
            if (!ActivityUtilities.IsInScope(callbackWrapper.ActivityInstance, isolationInstance))
            {
                workItem = null;
                return(BookmarkResumptionResult.NotReady);
            }
            workItem = callbackWrapper.CreateWorkItem(executor, isExternal, bookmark, value);
            if (!BookmarkOptionsHelper.SupportsMultipleResumes(callbackWrapper.Options))
            {
                this.Remove(bookmark, callbackWrapper);
            }
            return(BookmarkResumptionResult.Success);
        }
 void Remove(Bookmark bookmark, BookmarkCallbackWrapper callbackWrapper)
 {
     callbackWrapper.ActivityInstance.RemoveBookmark(bookmark, callbackWrapper.Options);
     UpdateExclusiveHandleList(bookmark);
     this.bookmarks.Remove(bookmark);
 }
Exemplo n.º 10
0
        // This method translates from a bookmark that we may have received from the outside world (IE - new Bookmark(someName))
        // to our internal Bookmark object.  This is necessary because we use bookmark objects as the key to our dictionary
        // (hence our ability to resolve an externally created one), but we keep a lot of important information on our internal
        // instance of that bookmark.  We must always perform this translation when doing exclusive handle housekeeping.
        public bool TryGetBookmarkFromInternalList(Bookmark bookmark, out Bookmark internalBookmark, out BookmarkCallbackWrapper callbackWrapper)
        {
            internalBookmark = null;
            callbackWrapper = null;
            if (this.bookmarks == null)
            {
                return false;
            }

            BookmarkCallbackWrapper wrapper;
            if (this.bookmarks.TryGetValue(bookmark, out wrapper))
            {
                internalBookmark = wrapper.Bookmark;
                callbackWrapper = wrapper;
                return true;
            }

            return false;
        }
Exemplo n.º 11
0
 void Remove(Bookmark bookmark, BookmarkCallbackWrapper callbackWrapper)
 {
     callbackWrapper.ActivityInstance.RemoveBookmark(bookmark, callbackWrapper.Options);
     UpdateExclusiveHandleList(bookmark);
     this.bookmarks.Remove(bookmark);
 }
Exemplo n.º 12
0
        // This method translates from a bookmark that we may have received from the outside world (IE - new Bookmark(someName))
        // to our internal Bookmark object.  This is necessary because we use bookmark objects as the key to our dictionary
        // (hence our ability to resolve an externally created one), but we keep a lot of important information on our internal
        // instance of that bookmark.  We must always perform this translation when doing exclusive handle housekeeping.
        public bool TryGetBookmarkFromInternalList(Bookmark bookmark, out Bookmark internalBookmark, out BookmarkCallbackWrapper callbackWrapper)
        {
            internalBookmark = null;
            callbackWrapper  = null;
            if (this.bookmarks == null)
            {
                return(false);
            }

            BookmarkCallbackWrapper wrapper;

            if (this.bookmarks.TryGetValue(bookmark, out wrapper))
            {
                internalBookmark = wrapper.Bookmark;
                callbackWrapper  = wrapper;
                return(true);
            }

            return(false);
        }