/// <summary> /// This callback gets called whenever a module gets registered. It adds the metadata reader /// for the new module to the available scopes. The lock in ExecutionEnvironmentImplementation ensures /// that this function may never be called concurrently so that we can assume that two threads /// never update the reader and scope list at the same time. /// </summary> /// <param name="moduleHandle">Module handle to register</param> private void RegisterModule(IntPtr moduleHandle) { MetadataReader newReader = _executionEnvironment.GetMetadataReaderForModule(moduleHandle); if (newReader == null) { return; } // Build new reader list LowLevelListWithIList <MetadataReader> readers = new LowLevelListWithIList <MetadataReader>(_readers.Count + 1); foreach (MetadataReader oldReader in _readers) { readers.Add(oldReader); } readers.Add(newReader); LowLevelDictionaryWithIEnumerable <string, ScopeDefinitionGroup> scopeGroups = new LowLevelDictionaryWithIEnumerable <string, ScopeDefinitionGroup>(); foreach (KeyValuePair <string, ScopeDefinitionGroup> oldGroup in _scopeGroups) { scopeGroups.Add(oldGroup.Key, oldGroup.Value); } AddScopesFromReaderToGroups(scopeGroups, newReader); // Update reader and scope list _readers = readers; _scopeGroups = scopeGroups; }
public unsafe ExecutionEnvironmentImplementation() { _moduleToMetadataReader = new LowLevelDictionaryWithIEnumerable <IntPtr, MetadataReader>(); // Metadata reader must be creater first as other callbacks might need it AddModuleRegistrationCallback(CreateMetadataReader); AddModuleRegistrationCallback(ModuleList.RegisterModule); }
public unsafe ExecutionEnvironmentImplementation() { _moduleToMetadataReader = new LowLevelDictionaryWithIEnumerable<IntPtr, MetadataReader>(); // Metadata reader must be creater first as other callbacks might need it AddModuleRegistrationCallback(CreateMetadataReader); AddModuleRegistrationCallback(ModuleList.RegisterModule); }
private ExecutionContext(ExecutionContext other) { m_localValues = new LowLevelDictionaryWithIEnumerable <IAsyncLocal, object>(); foreach (KeyValuePair <IAsyncLocal, object> kvp in other.m_localValues) { m_localValues.Add(kvp.Key, kvp.Value); } m_localChangeNotifications = new LowLevelListWithIList <IAsyncLocal>(other.m_localChangeNotifications); }
private ExecutionContext(ExecutionContext other) { m_localValues = new LowLevelDictionaryWithIEnumerable<IAsyncLocal, object>(); foreach (KeyValuePair<IAsyncLocal, object> kvp in other.m_localValues) { m_localValues.Add(kvp.Key, kvp.Value); } m_localChangeNotifications = new LowLevelListWithIList<IAsyncLocal>(other.m_localChangeNotifications); }
private static void AddScopesFromReaderToGroups(LowLevelDictionaryWithIEnumerable <RuntimeAssemblyName, ScopeDefinitionGroup> groups, MetadataReader reader) { foreach (ScopeDefinitionHandle scopeDefinitionHandle in reader.ScopeDefinitions) { RuntimeAssemblyName defName = scopeDefinitionHandle.ToRuntimeAssemblyName(reader); ScopeDefinitionGroup scopeDefinitionGroup; if (groups.TryGetValue(defName, out scopeDefinitionGroup)) { scopeDefinitionGroup.AddOverflowScope(new QScopeDefinition(reader, scopeDefinitionHandle)); } else { scopeDefinitionGroup = new ScopeDefinitionGroup(new QScopeDefinition(reader, scopeDefinitionHandle)); groups.Add(defName, scopeDefinitionGroup); } } }
private void AddScopesFromReaderToGroups(LowLevelDictionaryWithIEnumerable <string, ScopeDefinitionGroup> groups, MetadataReader reader) { foreach (ScopeDefinitionHandle scopeDefinitionHandle in reader.ScopeDefinitions) { AssemblyName defName = this.CreateAssemblyNameFromMetadata(reader, scopeDefinitionHandle); string defFullName = defName.FullName; ScopeDefinitionGroup scopeDefinitionGroup; if (groups.TryGetValue(defFullName, out scopeDefinitionGroup)) { scopeDefinitionGroup.AddOverflowScope(new QScopeDefinition(reader, scopeDefinitionHandle)); } else { scopeDefinitionGroup = new ScopeDefinitionGroup(new QScopeDefinition(reader, scopeDefinitionHandle)); groups.Add(defFullName, scopeDefinitionGroup); } } }
private ExecutionContext() { m_localValues = new LowLevelDictionaryWithIEnumerable <IAsyncLocal, object>(); m_localChangeNotifications = new LowLevelListWithIList <IAsyncLocal>(); }
/// <summary> /// This callback gets called whenever a module gets registered. It adds the metadata reader /// for the new module to the available scopes. The lock in ExecutionEnvironmentImplementation ensures /// that this function may never be called concurrently so that we can assume that two threads /// never update the reader and scope list at the same time. /// </summary> /// <param name="moduleInfo">Module to register</param> private void RegisterModule(ModuleInfo moduleInfo) { if (moduleInfo.MetadataReader == null) { return; } LowLevelDictionaryWithIEnumerable <AssemblyNameKey, ScopeDefinitionGroup> scopeGroups = new LowLevelDictionaryWithIEnumerable <AssemblyNameKey, ScopeDefinitionGroup>(); foreach (KeyValuePair <AssemblyNameKey, ScopeDefinitionGroup> oldGroup in _scopeGroups) { scopeGroups.Add(oldGroup.Key, oldGroup.Value); } AddScopesFromReaderToGroups(scopeGroups, moduleInfo.MetadataReader); // Update reader and scope list KeyValuePair <AssemblyNameKey, ScopeDefinitionGroup>[] scopeGroupsArray = new KeyValuePair <AssemblyNameKey, ScopeDefinitionGroup> [scopeGroups.Count]; int i = 0; foreach (KeyValuePair <AssemblyNameKey, ScopeDefinitionGroup> data in scopeGroups) { scopeGroupsArray[i] = data; i++; } _scopeGroups = scopeGroupsArray; }
public AssemblyBinderImplementation(ExecutionEnvironmentImplementation executionEnvironment) { _executionEnvironment = executionEnvironment; _readers = new LowLevelListWithIList<MetadataReader>(); _scopeGroups = new LowLevelDictionaryWithIEnumerable<string, ScopeDefinitionGroup>(); }
private void AddScopesFromReaderToGroups(LowLevelDictionaryWithIEnumerable<string, ScopeDefinitionGroup> groups, MetadataReader reader) { foreach (ScopeDefinitionHandle scopeDefinitionHandle in reader.ScopeDefinitions) { AssemblyName defName = this.CreateAssemblyNameFromMetadata(reader, scopeDefinitionHandle); string defFullName = defName.FullName; ScopeDefinitionGroup scopeDefinitionGroup; if (groups.TryGetValue(defFullName, out scopeDefinitionGroup)) { scopeDefinitionGroup.AddOverflowScope(new QScopeDefinition(reader, scopeDefinitionHandle)); } else { scopeDefinitionGroup = new ScopeDefinitionGroup(new QScopeDefinition(reader, scopeDefinitionHandle)); groups.Add(defFullName, scopeDefinitionGroup); } } }
/// <summary> /// This callback gets called whenever a module gets registered. It adds the metadata reader /// for the new module to the available scopes. The lock in ExecutionEnvironmentImplementation ensures /// that this function may never be called concurrently so that we can assume that two threads /// never update the reader and scope list at the same time. /// </summary> /// <param name="moduleHandle">Module handle to register</param> private void RegisterModule(IntPtr moduleHandle) { MetadataReader newReader = _executionEnvironment.GetMetadataReaderForModule(moduleHandle); if (newReader == null) { return; } // Build new reader list LowLevelListWithIList<MetadataReader> readers = new LowLevelListWithIList<MetadataReader>(_readers.Count + 1); foreach (MetadataReader oldReader in _readers) { readers.Add(oldReader); } readers.Add(newReader); LowLevelDictionaryWithIEnumerable<string, ScopeDefinitionGroup> scopeGroups = new LowLevelDictionaryWithIEnumerable<string, ScopeDefinitionGroup>(); foreach (KeyValuePair<string, ScopeDefinitionGroup> oldGroup in _scopeGroups) { scopeGroups.Add(oldGroup.Key, oldGroup.Value); } AddScopesFromReaderToGroups(scopeGroups, newReader); // Update reader and scope list _readers = readers; _scopeGroups = scopeGroups; }
public AssemblyBinderImplementation(ExecutionEnvironmentImplementation executionEnvironment) { _executionEnvironment = executionEnvironment; _readers = new LowLevelListWithIList <MetadataReader>(); _scopeGroups = new LowLevelDictionaryWithIEnumerable <string, ScopeDefinitionGroup>(); }
private ExecutionContext() { m_localValues = new LowLevelDictionaryWithIEnumerable<IAsyncLocal, object>(); m_localChangeNotifications = new LowLevelListWithIList<IAsyncLocal>(); }