[System.Security.SecuritySafeCritical] // overrides public transparent member public Object Clone() { LogicalCallContext lc = new LogicalCallContext(); if (m_RemotingData != null) { lc.m_RemotingData = (CallContextRemotingData)m_RemotingData.Clone(); } if (m_SecurityData != null) { lc.m_SecurityData = (CallContextSecurityData)m_SecurityData.Clone(); } if (m_HostContext != null) { lc.m_HostContext = m_HostContext; } lc.m_IsCorrelationMgr = m_IsCorrelationMgr; if (HasUserData) { IDictionaryEnumerator de = m_Datastore.GetEnumerator(); if (!m_IsCorrelationMgr) { while (de.MoveNext()) { lc.Datastore[(String)de.Key] = de.Value; } } else { while (de.MoveNext()) { String key = (String)de.Key; // Deep clone "System.Diagnostics.Trace.CorrelationManagerSlot" if (key.Equals(s_CorrelationMgrSlotName)) { lc.Datastore[key] = ((ICloneable)de.Value).Clone(); } else { lc.Datastore[key] = de.Value; } } } } return(lc); }
// ICloneable::Clone // Used to create a (somewhat lame) deep copy of the call context // when an async call starts // FUTURE: This needs to be revisited ... ideally the call // context data should be deep-copied for each Async call ... may be // by providing the user with the option through new parameters to // BeginInvoke & EndInvoke /// <include file='doc\CallContext.uex' path='docs/doc[@for="LogicalCallContext.Clone"]/*' /> public Object Clone() { LogicalCallContext lc = new LogicalCallContext(); if (m_RemotingData != null) { lc.m_RemotingData = (CallContextRemotingData)m_RemotingData.Clone(); } if (m_SecurityData != null) { lc.m_SecurityData = (CallContextSecurityData)m_SecurityData.Clone(); } if (HasUserData) { IDictionaryEnumerator de = m_Datastore.GetEnumerator(); while (de.MoveNext()) { lc.Datastore[(String)de.Key] = de.Value; } } return(lc); }