internal BookmarkScope CreateAndRegisterScope(Guid scopeId, BookmarkScopeHandle scopeHandle) { if (this.bookmarkManagers == null) { this.bookmarkManagers = new Dictionary <BookmarkScope, BookmarkManager>(); } BookmarkScope key = null; if (scopeId == Guid.Empty) { key = new BookmarkScope(this.GetNextTemporaryId()); this.bookmarkManagers.Add(key, new BookmarkManager(key, scopeHandle)); if (TD.CreateBookmarkScopeIsEnabled()) { TD.CreateBookmarkScope(ActivityUtilities.GetTraceString(key)); } if (this.uninitializedScopes == null) { this.uninitializedScopes = new List <BookmarkScope>(); } this.uninitializedScopes.Add(key); return(key); } foreach (BookmarkScope scope2 in this.bookmarkManagers.Keys) { if (scope2.Id.Equals(scopeId)) { key = scope2; break; } } if (key == null) { key = new BookmarkScope(scopeId); this.bookmarkManagers.Add(key, new BookmarkManager(key, scopeHandle)); if (TD.CreateBookmarkScopeIsEnabled()) { TD.CreateBookmarkScope(string.Format(CultureInfo.InvariantCulture, "Id: {0}", new object[] { ActivityUtilities.GetTraceString(key) })); } } this.CreateAssociatedKey(key); return(key); }
public override void TraceStarting() { if (TD.StartBookmarkWorkItemIsEnabled()) { TD.StartBookmarkWorkItem(this.ActivityInstance.Activity.GetType().ToString(), this.ActivityInstance.Activity.DisplayName, this.ActivityInstance.Id, ActivityUtilities.GetTraceString(this.bookmark), ActivityUtilities.GetTraceString(this.bookmark.Scope)); } }
internal BookmarkScope CreateAndRegisterScope(Guid scopeId, BookmarkScopeHandle scopeHandle) { if (_bookmarkManagers == null) { _bookmarkManagers = new Dictionary <BookmarkScope, BookmarkManager>(); } BookmarkScope scope = null; if (scopeId == Guid.Empty) { // // This is the very first activity which started the sub-instance // scope = new BookmarkScope(GetNextTemporaryId()); _bookmarkManagers.Add(scope, new BookmarkManager(scope, scopeHandle)); if (TD.CreateBookmarkScopeIsEnabled()) { TD.CreateBookmarkScope(ActivityUtilities.GetTraceString(scope)); } if (_uninitializedScopes == null) { _uninitializedScopes = new List <BookmarkScope>(); } _uninitializedScopes.Add(scope); } else { // // Try to find one in the existing sub-instances // foreach (BookmarkScope eachScope in _bookmarkManagers.Keys) { if (eachScope.Id.Equals(scopeId)) { scope = eachScope; break; } } // // We did not find one, e.g. the first receive will get the correlation id from the // correlation channel // if (scope == null) { scope = new BookmarkScope(scopeId); _bookmarkManagers.Add(scope, new BookmarkManager(scope, scopeHandle)); if (TD.CreateBookmarkScopeIsEnabled()) { TD.CreateBookmarkScope(string.Format(CultureInfo.InvariantCulture, "Id: {0}", ActivityUtilities.GetTraceString(scope))); } } CreateAssociatedKey(scope); } return(scope); }
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)); } }
public override void TraceScheduled() { if (TD.ScheduleBookmarkWorkItemIsEnabled()) { TD.ScheduleBookmarkWorkItem(this.ActivityInstance.Activity.GetType().ToString(), this.ActivityInstance.Activity.DisplayName, this.ActivityInstance.Id, ActivityUtilities.GetTraceString(Bookmark.AsyncOperationCompletionBookmark), ActivityUtilities.GetTraceString(Bookmark.AsyncOperationCompletionBookmark.Scope)); } }