public static bool IsEmpty(IAsyncLocalValueMap asyncLocalValueMap) { Debug.Assert(asyncLocalValueMap != null); Debug.Assert(asyncLocalValueMap == Empty || asyncLocalValueMap.GetType() != typeof(EmptyAsyncLocalValueMap)); return(asyncLocalValueMap == Empty); }
public bool HasSameLocalValues(ExecutionContext other) { IAsyncLocalValueMap asyncLocalValueMap = this.IsNull ? null : this.m_ec._localValues; IAsyncLocalValueMap asyncLocalValueMap2 = (other == null) ? null : other._localValues; return(asyncLocalValueMap == asyncLocalValueMap2); }
private ExecutionContext( IAsyncLocalValueMap localValues, IAsyncLocal[] localChangeNotifications, bool isFlowSuppressed) { m_localValues = localValues; m_localChangeNotifications = localChangeNotifications; m_isFlowSuppressed = isFlowSuppressed; }
private ExecutionContext( IAsyncLocalValueMap localValues, IAsyncLocal[] localChangeNotifications, bool isFlowSuppressed) { m_localValues = localValues; m_localChangeNotifications = localChangeNotifications; m_isFlowSuppressed = isFlowSuppressed; }
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 void SetLocalValue(IAsyncLocal local, object newValue, bool needChangeNotifications) { ExecutionContext mutableExecutionContext = Thread.CurrentThread.GetMutableExecutionContext(); object obj = null; bool flag = mutableExecutionContext._localValues != null && mutableExecutionContext._localValues.TryGetValue(local, out obj); if (obj == newValue) { return; } IAsyncLocalValueMap asyncLocalValueMap = mutableExecutionContext._localValues; if (asyncLocalValueMap == null) { asyncLocalValueMap = AsyncLocalValueMap.Create(local, newValue, !needChangeNotifications); } else { asyncLocalValueMap = asyncLocalValueMap.Set(local, newValue, !needChangeNotifications); } mutableExecutionContext._localValues = asyncLocalValueMap; if (needChangeNotifications) { if (!flag) { IAsyncLocal[] array = mutableExecutionContext._localChangeNotifications; if (array == null) { array = new IAsyncLocal[] { local }; } else { int num = array.Length; Array.Resize <IAsyncLocal>(ref array, num + 1); array[num] = local; } mutableExecutionContext._localChangeNotifications = array; } local.OnValueChanged(obj, newValue, false); } }
internal static void SetLocalValue(IAsyncLocal local, object newValue, bool needChangeNotifications) { ExecutionContext current = Thread.CurrentThread.ExecutionContext ?? ExecutionContext.Default; object previousValue; bool hadPreviousValue = current.m_localValues.TryGetValue(local, out previousValue); if (previousValue == newValue) { return; } IAsyncLocalValueMap newValues = current.m_localValues.Set(local, newValue); // // Either copy the change notification array, or create a new one, depending on whether we need to add a new item. // IAsyncLocal[] newChangeNotifications = current.m_localChangeNotifications; if (needChangeNotifications) { if (hadPreviousValue) { Contract.Assert(Array.IndexOf(newChangeNotifications, local) >= 0); } else { int newNotificationIndex = newChangeNotifications.Length; Array.Resize(ref newChangeNotifications, newNotificationIndex + 1); newChangeNotifications[newNotificationIndex] = local; } } Thread.CurrentThread.ExecutionContext = new ExecutionContext(newValues, newChangeNotifications, current.m_isFlowSuppressed); if (needChangeNotifications) { local.OnValueChanged(previousValue, newValue, false); } }
private ExecutionContext() { m_localValues = AsyncLocalValueMap.Empty; m_localChangeNotifications = Array.Empty <IAsyncLocal>(); }
private ExecutionContext() { m_localValues = AsyncLocalValueMap.Empty; m_localChangeNotifications = Array.Empty<IAsyncLocal>(); }
// Token: 0x06003A68 RID: 14952 RVA: 0x000DDAFE File Offset: 0x000DBCFE public static bool IsEmpty(IAsyncLocalValueMap asyncLocalValueMap) { return(asyncLocalValueMap == AsyncLocalValueMap.Empty); }