Пример #1
0
 // 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)
 {
     _callbackWrapper = callbackWrapper;
     _bookmark        = bookmark;
     _state           = value;
 }
Пример #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);
        }
Пример #3
0
 public BookmarkWorkItem(ActivityExecutor executor, bool isExternal, BookmarkCallbackWrapper callbackWrapper, Bookmark bookmark, object value)
     : this(callbackWrapper, bookmark, value)
 {
     if (isExternal)
     {
         executor.EnterNoPersist();
         this.ExitNoPersistRequired = true;
     }
 }
Пример #4
0
        private void AddBookmark(Bookmark bookmark, BookmarkCallback callback, ActivityInstance owningInstance, BookmarkOptions options)
        {
            if (this.bookmarks == null)
            {
                this.bookmarks = new Dictionary <Bookmark, BookmarkCallbackWrapper>(Bookmark.Comparer);
            }

            bookmark.Scope = this.scope;

            BookmarkCallbackWrapper bookmarkCallbackWrapper = new BookmarkCallbackWrapper(callback, owningInstance, options)
            {
                Bookmark = bookmark
            };

            this.bookmarks.Add(bookmark, bookmarkCallbackWrapper);

            owningInstance.AddBookmark(bookmark, options);

            if (TD.CreateBookmarkIsEnabled())
            {
                TD.CreateBookmark(owningInstance.Activity.GetType().ToString(), owningInstance.Activity.DisplayName, owningInstance.Id, ActivityUtilities.GetTraceString(bookmark), ActivityUtilities.GetTraceString((BookmarkScope)bookmark.Scope));
            }
        }
Пример #5
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);
            }

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

            return(false);
        }
Пример #6
0
 private void Remove(Bookmark bookmark, BookmarkCallbackWrapper callbackWrapper)
 {
     callbackWrapper.ActivityInstance.RemoveBookmark(bookmark, callbackWrapper.Options);
     UpdateExclusiveHandleList(bookmark);
     _bookmarks.Remove(bookmark);
 }