Exemple #1
0
        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);
        }
 internal BookmarkManager(BookmarkScope scope, BookmarkScopeHandle scopeHandle)
     : this()
 {
     this.scope = scope;
     this.scopeHandle = scopeHandle;
 }
        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);
        }
 protected override void OnInitialize(HandleInitializationContext context)
 {
     this.noPersistHandle     = context.CreateAndInitializeHandle <NoPersistHandle>();
     this.bookmarkScopeHandle = context.CreateAndInitializeHandle <BookmarkScopeHandle>();
 }
        internal BookmarkScope CreateAndRegisterScope(Guid scopeId, BookmarkScopeHandle scopeHandle)
        {
            if (this.bookmarkManagers == null)
            {
                this.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());
                this.bookmarkManagers.Add(scope, new BookmarkManager(scope, scopeHandle));

                if (TD.CreateBookmarkScopeIsEnabled())
                {
                    TD.CreateBookmarkScope(ActivityUtilities.GetTraceString(scope));
                }

                if (this.uninitializedScopes == null)
                {
                    this.uninitializedScopes = new List<BookmarkScope>();
                }

                this.uninitializedScopes.Add(scope);
            }
            else
            {
                //
                // Try to find one in the existing sub-instances
                //
                foreach (BookmarkScope eachScope in this.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);
                    this.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;
        }
Exemple #6
0
 internal BookmarkManager(BookmarkScope scope, BookmarkScopeHandle scopeHandle)
     : this()
 {
     this.scope       = scope;
     this.scopeHandle = scopeHandle;
 }