Пример #1
0
        public ExecutionContext CreateCopy()
        {
            if (!isNewCapture)
            {
                throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_CannotCopyUsedContext"));
            }
            ExecutionContext ec = new ExecutionContext();

            ec.isNewCapture = true;
            ec._syncContext = _syncContext == null ? null : _syncContext.CreateCopy();
            // capture the host execution context
            ec._hostExecutionContext = _hostExecutionContext == null ? null : _hostExecutionContext.CreateCopy();
            if (_securityContext != null)
            {
                ec._securityContext = _securityContext.CreateCopy();
                ec._securityContext.ExecutionContext = ec;
            }
            if (this._logicalCallContext != null)
            {
                LogicalCallContext lc = (LogicalCallContext)this.LogicalCallContext;
                ec.LogicalCallContext = (LogicalCallContext)lc.Clone();
            }
            if (this._illogicalCallContext != null)
            {
                IllogicalCallContext ilcc = (IllogicalCallContext)this.IllogicalCallContext;
                ec.IllogicalCallContext = (IllogicalCallContext)ilcc.Clone();
            }

            return(ec);
        }
Пример #2
0
        public ExecutionContext CreateCopy()
        {
            if (!isNewCapture)
            {
                throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_CannotCopyUsedContext"));
            }
            ExecutionContext ec = new ExecutionContext();

            ec.isNewCapture = true;
#if FEATURE_SYNCHRONIZATIONCONTEXT
            ec._syncContext = _syncContext == null ? null : _syncContext.CreateCopy();
#endif // #if FEATURE_SYNCHRONIZATIONCONTEXT
#if FEATURE_CAS_POLICY
            // capture the host execution context
            ec._hostExecutionContext = _hostExecutionContext == null ? null : _hostExecutionContext.CreateCopy();
#endif // FEATURE_CAS_POLICY
#if FEATURE_IMPERSONATION || FEATURE_COMPRESSEDSTACK
            if (_securityContext != null)
            {
                ec._securityContext = _securityContext.CreateCopy();
                ec._securityContext.ExecutionContext = ec;
            }
#endif // #if FEATURE_IMPERSONATION || FEATURE_COMPRESSEDSTACK

            if (this._logicalCallContext != null)
            {
                ec.LogicalCallContext = (LogicalCallContext)this.LogicalCallContext.Clone();
            }

            Contract.Assert(this._illogicalCallContext == null);

            return(ec);
        }
 public static SynchronizationContext CloneSynchronizationContext(SynchronizationContext context)
 {
     if (context is WFDefaultSynchronizationContext)
     {
         return defaultContext;
     }
     return context.CreateCopy();
 }
 public static SynchronizationContext CloneSynchronizationContext(SynchronizationContext context)
 {
     Fx.Assert(context != null, "null context parameter");
     WFDefaultSynchronizationContext wfDefaultContext = context as WFDefaultSynchronizationContext;
     if (wfDefaultContext != null)
     {
         Fx.Assert(SynchronizationContextHelper.defaultContext != null, "We must have set the static member by now!");
         return SynchronizationContextHelper.defaultContext;
     }
     else
     {
         return context.CreateCopy();
     }
 }