Example #1
0
        public BookmarkScope InitializeBookmarkScopeWithoutKeyAssociation(BookmarkScope scope, Guid id)
        {
            BookmarkScope item = scope;

            if (scope.IsDefault)
            {
                item = this.defaultScope;
            }
            if ((this.uninitializedScopes == null) || !this.uninitializedScopes.Contains(item))
            {
                throw FxTrace.Exception.AsError(new InvalidOperationException(System.Activities.SR.BookmarkScopeNotRegisteredForInitialize));
            }
            if (this.bookmarkManagers.ContainsKey(new BookmarkScope(id)))
            {
                throw FxTrace.Exception.AsError(new InvalidOperationException(System.Activities.SR.BookmarkScopeWithIdAlreadyExists(id)));
            }
            BookmarkManager manager = this.bookmarkManagers[item];

            this.bookmarkManagers.Remove(item);
            this.uninitializedScopes.Remove(item);
            long temporaryId = item.TemporaryId;

            item.Id = id;
            this.bookmarkManagers.Add(item, manager);
            if (TD.BookmarkScopeInitializedIsEnabled())
            {
                TD.BookmarkScopeInitialized(temporaryId.ToString(CultureInfo.InvariantCulture), item.Id.ToString());
            }
            return(item);
        }
        public BookmarkScope InitializeBookmarkScopeWithoutKeyAssociation(BookmarkScope scope, Guid id)
        {
            Fx.Assert(!scope.IsInitialized, "This should have been checked by the caller.");

            BookmarkScope lookupScope = scope;

            if (scope.IsDefault)
            {
                lookupScope = _defaultScope;
            }

            if (_uninitializedScopes == null || !_uninitializedScopes.Contains(lookupScope))
            {
                throw Microsoft.CoreWf.Internals.FxTrace.Exception.AsError(new InvalidOperationException(SR.BookmarkScopeNotRegisteredForInitialize));
            }

            Fx.Assert(_bookmarkManagers != null, "This is never null if uninitializedScopes is non-null.");

            if (_bookmarkManagers.ContainsKey(new BookmarkScope(id)))
            {
                throw Microsoft.CoreWf.Internals.FxTrace.Exception.AsError(new InvalidOperationException(SR.BookmarkScopeWithIdAlreadyExists(id)));
            }

            BookmarkManager bookmarks = _bookmarkManagers[lookupScope];

            _bookmarkManagers.Remove(lookupScope);
            _uninitializedScopes.Remove(lookupScope);

            long temporaryId = lookupScope.TemporaryId;

            // We initialize and re-add to our dictionary.  We have to
            // re-add because the hash has changed.
            lookupScope.Id = id;
            _bookmarkManagers.Add(lookupScope, bookmarks);

            if (TD.BookmarkScopeInitializedIsEnabled())
            {
                TD.BookmarkScopeInitialized(temporaryId.ToString(CultureInfo.InvariantCulture), lookupScope.Id.ToString());
            }

            return(lookupScope);
        }