CreateCopy() public method

public CreateCopy ( ) : HostExecutionContext
return HostExecutionContext
コード例 #1
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);
        }
コード例 #2
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);
        }
コード例 #3
0
 private static HostExecutionContext CreateCopyHelper(HostExecutionContext hostExecutionContext)
 {
     return (hostExecutionContext != null) ? hostExecutionContext.CreateCopy() : null;
 }
コード例 #4
0
 private static HostExecutionContext CreateCopyHelper(HostExecutionContext hostExecutionContext) {
     // creating a copy of a null context should just itself return null
     return (hostExecutionContext != null) ? hostExecutionContext.CreateCopy() : null;
 }