//[SuppressMessage(FxCop.Category.Design, FxCop.Rule.ConsiderPassingBaseTypesAsParameters, // Justification = "We are restricting the activities that can call this API.")] public void RegisterBookmarkScope(NativeActivityContext context, BookmarkScopeHandle bookmarkScopeHandle) { if (context == null) { throw FxTrace.Exception.ArgumentNull(nameof(context)); } context.ThrowIfDisposed(); if (bookmarkScopeHandle == null) { throw FxTrace.Exception.ArgumentNull(nameof(bookmarkScopeHandle)); } if ((this.ImportantBookmarks != null && this.ImportantBookmarks.Count != 0) || (this.UnimportantBookmarks != null && this.UnimportantBookmarks.Count != 0)) { throw FxTrace.Exception.AsError(new InvalidOperationException(SR.ExclusiveHandleRegisterBookmarkScopeFailed)); } if (this.bookmarkScopesListIsDefault) { this.bookmarkScopesListIsDefault = false; this.bookmarkScopes.Clear(); } this.bookmarkScopes.Add(bookmarkScopeHandle); this.readOnlyBookmarkScopeCollection = null; }
private void PerformDefaultRegistration() { if (_bookmarkScopes == null) { _bookmarkScopes = new List <BookmarkScopeHandle>(); } //First register the default subinstance _bookmarkScopes.Add(BookmarkScopeHandle.Default); // Note that we are starting the LocationEnvironment traversal from the current environment's Parent. We don't // want to include any BookmarkScopeHandles that are at the same scope level as the ExclusiveHandle. The ExclusiveHandle // should only be dependent on BookmarkScopeHandles that are higher in the scope tree. LocationEnvironment current = _owningInstance.Environment; if (current != null) { for (current = current.Parent; current != null; current = current.Parent) { //don't bother continuing if at this level there are no handles if (!current.HasHandles) { continue; } // Look at the contained handles for the environment. List <Handle> handles = current.Handles; if (handles != null) { int count = handles.Count; for (int i = 0; i < count; i++) { BookmarkScopeHandle scopeHandle = handles[i] as BookmarkScopeHandle; if (scopeHandle != null) { _bookmarkScopes.Add(scopeHandle); } } } } } // Also need to look in the Executor for handles that may have been created without an environment. List <Handle> executorHandles = _executor.Handles; if (executorHandles != null) { int count = executorHandles.Count; for (int i = 0; i < count; i++) { BookmarkScopeHandle scopeHandle = executorHandles[i] as BookmarkScopeHandle; if (scopeHandle != null) { _bookmarkScopes.Add(scopeHandle); } } } _bookmarkScopesListIsDefault = true; }