Exemplo n.º 1
0
        internal void InitializeBookmarkScope(NativeActivityContext context, InstanceKey instanceKey)
        {
            Fx.Assert(context != null, "executionContext cannot be null");
            Fx.Assert(instanceKey != null, "instanceKey cannot be null");

            if (context.GetExtension <SendReceiveExtension>() != null)
            {
                if (this.InstanceKey != null && this.InstanceKey.Value != instanceKey.Value)
                {
                    throw FxTrace.Exception.AsError(
                              new InvalidOperationException(SR.CorrelationHandleInUse(this.InstanceKey.Value, instanceKey.Value)));
                }
                this.InstanceKey = instanceKey;
            }
            else
            {
                if (this.Scope == null)
                {
                    this.bookmarkScopeHandle.CreateBookmarkScope(context, instanceKey.Value);
                    this.Scope = this.bookmarkScopeHandle.BookmarkScope;
                }
                else
                {
                    if (this.Scope.IsInitialized)
                    {
                        if (this.Scope.Id != instanceKey.Value)
                        {
                            throw FxTrace.Exception.AsError(
                                      new InvalidOperationException(SR.CorrelationHandleInUse(this.Scope.Id, instanceKey.Value)));
                        }
                    }
                    else
                    {
                        this.Scope.Initialize(context, instanceKey.Value);
                    }
                }
            }
        }