internal static ExecutionContext Capture(ref StackCrawlMark stackMark) { if (IsFlowSuppressed()) { return(null); } ExecutionContext executionContextNoCreate = System.Threading.Thread.CurrentThread.GetExecutionContextNoCreate(); ExecutionContext context2 = new ExecutionContext { isNewCapture = true, SecurityContext = System.Security.SecurityContext.Capture(executionContextNoCreate, ref stackMark) }; if (context2.SecurityContext != null) { context2.SecurityContext.ExecutionContext = context2; } context2._hostExecutionContext = HostExecutionContextManager.CaptureHostExecutionContext(); if (executionContextNoCreate != null) { context2._syncContext = (executionContextNoCreate._syncContext == null) ? null : executionContextNoCreate._syncContext.CreateCopy(); if (executionContextNoCreate._logicalCallContext != null) { System.Runtime.Remoting.Messaging.LogicalCallContext logicalCallContext = executionContextNoCreate.LogicalCallContext; context2.LogicalCallContext = (System.Runtime.Remoting.Messaging.LogicalCallContext)logicalCallContext.Clone(); } } return(context2); }
internal static ExecutionContext Capture(ref StackCrawlMark stackMark, ExecutionContext.CaptureOptions options) { ExecutionContext.Reader executionContextReader = Thread.CurrentThread.GetExecutionContextReader(); if (executionContextReader.IsFlowSuppressed) { return((ExecutionContext)null); } SecurityContext securityContext = SecurityContext.Capture(executionContextReader, ref stackMark); HostExecutionContext executionContext1 = HostExecutionContextManager.CaptureHostExecutionContext(); SynchronizationContext synchronizationContext = (SynchronizationContext)null; LogicalCallContext logicalCallContext = (LogicalCallContext)null; if (!executionContextReader.IsNull) { if ((options & ExecutionContext.CaptureOptions.IgnoreSyncCtx) == ExecutionContext.CaptureOptions.None) { synchronizationContext = executionContextReader.SynchronizationContext == null ? (SynchronizationContext)null : executionContextReader.SynchronizationContext.CreateCopy(); } if (executionContextReader.LogicalCallContext.HasInfo) { logicalCallContext = executionContextReader.LogicalCallContext.Clone(); } } Dictionary <IAsyncLocal, object> dictionary = (Dictionary <IAsyncLocal, object>)null; List <IAsyncLocal> asyncLocalList = (List <IAsyncLocal>)null; if (!executionContextReader.IsNull) { dictionary = executionContextReader.DangerousGetRawExecutionContext()._localValues; asyncLocalList = executionContextReader.DangerousGetRawExecutionContext()._localChangeNotifications; } if ((options & ExecutionContext.CaptureOptions.OptimizeDefaultCase) != ExecutionContext.CaptureOptions.None && securityContext == null && (executionContext1 == null && synchronizationContext == null) && ((logicalCallContext == null || !logicalCallContext.HasInfo) && (dictionary == null && asyncLocalList == null))) { return(ExecutionContext.s_dummyDefaultEC); } ExecutionContext executionContext2 = new ExecutionContext(); executionContext2.SecurityContext = securityContext; if (executionContext2.SecurityContext != null) { executionContext2.SecurityContext.ExecutionContext = executionContext2; } executionContext2._hostExecutionContext = executionContext1; executionContext2._syncContext = synchronizationContext; executionContext2.LogicalCallContext = logicalCallContext; executionContext2._localValues = dictionary; executionContext2._localChangeNotifications = asyncLocalList; executionContext2.isNewCapture = true; return(executionContext2); }
internal static ExecutionContext Capture(ref StackCrawlMark stackMark, ExecutionContext.CaptureOptions options) { ExecutionContext.Reader executionContextReader = Thread.CurrentThread.GetExecutionContextReader(); if (executionContextReader.IsFlowSuppressed) { return(null); } SecurityContext securityContext = SecurityContext.Capture(executionContextReader, ref stackMark); HostExecutionContext hostExecutionContext = HostExecutionContextManager.CaptureHostExecutionContext(); SynchronizationContext synchronizationContext = null; LogicalCallContext logicalCallContext = null; if (!executionContextReader.IsNull) { if ((options & ExecutionContext.CaptureOptions.IgnoreSyncCtx) == ExecutionContext.CaptureOptions.None) { synchronizationContext = ((executionContextReader.SynchronizationContext == null) ? null : executionContextReader.SynchronizationContext.CreateCopy()); } if (executionContextReader.LogicalCallContext.HasInfo) { logicalCallContext = executionContextReader.LogicalCallContext.Clone(); } } IAsyncLocalValueMap asyncLocalValueMap = null; IAsyncLocal[] array = null; if (!executionContextReader.IsNull) { asyncLocalValueMap = executionContextReader.DangerousGetRawExecutionContext()._localValues; array = executionContextReader.DangerousGetRawExecutionContext()._localChangeNotifications; } if ((options & ExecutionContext.CaptureOptions.OptimizeDefaultCase) != ExecutionContext.CaptureOptions.None && securityContext == null && hostExecutionContext == null && synchronizationContext == null && (logicalCallContext == null || !logicalCallContext.HasInfo) && asyncLocalValueMap == null && array == null) { return(ExecutionContext.s_dummyDefaultEC); } ExecutionContext executionContext = new ExecutionContext(); executionContext.SecurityContext = securityContext; if (executionContext.SecurityContext != null) { executionContext.SecurityContext.ExecutionContext = executionContext; } executionContext._hostExecutionContext = hostExecutionContext; executionContext._syncContext = synchronizationContext; executionContext.LogicalCallContext = logicalCallContext; executionContext._localValues = asyncLocalValueMap; executionContext._localChangeNotifications = array; executionContext.isNewCapture = true; return(executionContext); }
internal static ExecutionContext Capture(ref StackCrawlMark stackMark, CaptureOptions options) { if (IsFlowSuppressed()) { return(null); } bool flag = CaptureOptions.None != (options & CaptureOptions.IgnoreSyncCtx); bool flag2 = CaptureOptions.None != (options & CaptureOptions.OptimizeDefaultCase); ExecutionContext executionContextNoCreate = System.Threading.Thread.CurrentThread.GetExecutionContextNoCreate(); System.Security.SecurityContext context2 = System.Security.SecurityContext.Capture(executionContextNoCreate, ref stackMark); System.Threading.HostExecutionContext context3 = HostExecutionContextManager.CaptureHostExecutionContext(); System.Threading.SynchronizationContext context4 = null; if ((executionContextNoCreate != null) && !flag) { context4 = (executionContextNoCreate._syncContext == null) ? null : executionContextNoCreate._syncContext.CreateCopy(); } System.Runtime.Remoting.Messaging.LogicalCallContext context5 = null; if (((executionContextNoCreate != null) && (executionContextNoCreate._logicalCallContext != null)) && executionContextNoCreate.LogicalCallContext.HasInfo) { context5 = (System.Runtime.Remoting.Messaging.LogicalCallContext)executionContextNoCreate.LogicalCallContext.Clone(); } if (((flag2 && (context2 == null)) && ((context3 == null) && (context4 == null))) && ((context5 == null) || !context5.HasInfo)) { return(s_dummyDefaultEC); } ExecutionContext context6 = new ExecutionContext { SecurityContext = context2 }; if (context6.SecurityContext != null) { context6.SecurityContext.ExecutionContext = context6; } context6._hostExecutionContext = context3; context6._syncContext = context4; context6.LogicalCallContext = context5; context6.isNewCapture = true; return(context6); }
// internal helper to capture the current execution context using a passed in stack mark static internal ExecutionContext Capture(ref StackCrawlMark stackMark) { // check to see if Flow is suppressed if (IsFlowSuppressed()) { return(null); } ExecutionContext ecCurrent = Thread.CurrentThread.GetExecutionContextNoCreate(); ExecutionContext ecNew = new ExecutionContext(); ecNew.isNewCapture = true; // capture the security context ecNew.SecurityContext = SecurityContext.Capture(ecCurrent, ref stackMark); if (ecNew.SecurityContext != null) { ecNew.SecurityContext.ExecutionContext = ecNew; } // capture the host execution context ecNew._hostExecutionContext = HostExecutionContextManager.CaptureHostExecutionContext(); if (ecCurrent != null) { // capture the sync context ecNew._syncContext = (ecCurrent._syncContext == null) ? null : ecCurrent._syncContext.CreateCopy(); // copy over the Logical Call Context if (ecCurrent._logicalCallContext != null) { LogicalCallContext lc = (LogicalCallContext)ecCurrent.LogicalCallContext; ecNew.LogicalCallContext = (LogicalCallContext)lc.Clone(); } } return(ecNew); }
[System.Security.SecurityCritical] // auto-generated static internal ExecutionContext Capture(ref StackCrawlMark stackMark, CaptureOptions options) { ExecutionContext.Reader ecCurrent = Thread.CurrentThread.GetExecutionContextReader(); // check to see if Flow is suppressed if (ecCurrent.IsFlowSuppressed) { return(null); } // // Attempt to capture context. There may be nothing to capture... // #if FEATURE_IMPERSONATION || FEATURE_COMPRESSEDSTACK // capture the security context SecurityContext secCtxNew = SecurityContext.Capture(ecCurrent, ref stackMark); #endif // #if FEATURE_IMPERSONATION || FEATURE_COMPRESSEDSTACK #if FEATURE_CAS_POLICY // capture the host execution context HostExecutionContext hostCtxNew = HostExecutionContextManager.CaptureHostExecutionContext(); #endif // FEATURE_CAS_POLICY #if FEATURE_SYNCHRONIZATIONCONTEXT SynchronizationContext syncCtxNew = null; #endif LogicalCallContext logCtxNew = null; if (!ecCurrent.IsNull) { #if FEATURE_SYNCHRONIZATIONCONTEXT // capture the [....] context if (0 == (options & CaptureOptions.IgnoreSyncCtx)) { syncCtxNew = (ecCurrent.SynchronizationContext == null) ? null : ecCurrent.SynchronizationContext.CreateCopy(); } #endif // #if FEATURE_SYNCHRONIZATIONCONTEXT // copy over the Logical Call Context if (ecCurrent.LogicalCallContext.HasInfo) { logCtxNew = ecCurrent.LogicalCallContext.Clone(); } } // // If we didn't get anything but defaults, and we're allowed to return the // dummy default EC, don't bother allocating a new context. // if (0 != (options & CaptureOptions.OptimizeDefaultCase) && #if FEATURE_IMPERSONATION || FEATURE_COMPRESSEDSTACK secCtxNew == null && #endif #if FEATURE_CAS_POLICY hostCtxNew == null && #endif // FEATURE_CAS_POLICY #if FEATURE_SYNCHRONIZATIONCONTEXT syncCtxNew == null && #endif // #if FEATURE_SYNCHRONIZATIONCONTEXT (logCtxNew == null || !logCtxNew.HasInfo)) { return(s_dummyDefaultEC); } // // Allocate the new context, and fill it in. // ExecutionContext ecNew = new ExecutionContext(); #if FEATURE_IMPERSONATION || FEATURE_COMPRESSEDSTACK ecNew.SecurityContext = secCtxNew; if (ecNew.SecurityContext != null) { ecNew.SecurityContext.ExecutionContext = ecNew; } #endif #if FEATURE_CAS_POLICY ecNew._hostExecutionContext = hostCtxNew; #endif // FEATURE_CAS_POLICY #if FEATURE_SYNCHRONIZATIONCONTEXT ecNew._syncContext = syncCtxNew; #endif // #if FEATURE_SYNCHRONIZATIONCONTEXT ecNew.LogicalCallContext = logCtxNew; ecNew.isNewCapture = true; return(ecNew); }