LoadLanguageContext() private méthode

Must not be called under a lock as it can potentially call a user code.
The language context's implementation failed to instantiate.
private LoadLanguageContext ( Microsoft.Scripting.Runtime.ScriptDomainManager domainManager, bool &alreadyLoaded ) : LanguageContext
domainManager Microsoft.Scripting.Runtime.ScriptDomainManager
alreadyLoaded bool
Résultat LanguageContext
Exemple #1
0
        private LanguageContext LoadLanguageContext(ScriptDomainManager manager, LanguageConfiguration config)
        {
            var language = config.LoadLanguageContext(manager, out bool alreadyLoaded);

            if (!alreadyLoaded)
            {
                // Checks whether a single language is not registered under two different AQTNs.
                // We can only do it now because there is no way how to ensure that two AQTNs don't refer to the same type w/o loading the type.
                // The check takes place after config.LoadLanguageContext is called to avoid calling user code while holding a lock.
                lock (_loadedProviderTypes) {
                    Type type = language.GetType();
                    if (_loadedProviderTypes.TryGetValue(type, out LanguageConfiguration existingConfig))
                    {
                        throw new InvalidOperationException(
                                  $"Language implemented by type '{config.ProviderName}' has already been loaded using name '{existingConfig.ProviderName}'");
                    }

                    _loadedProviderTypes.Add(type, config);
                }
            }
            return(language);
        }
        private LanguageContext LoadLanguageContext(ScriptDomainManager manager, LanguageConfiguration config) {
            bool alreadyLoaded;
            var language = config.LoadLanguageContext(manager, out alreadyLoaded);

            if (!alreadyLoaded) {
                // Checks whether a single language is not registered under two different AQTNs.
                // We can only do it now because there is no way how to ensure that two AQTNs don't refer to the same type w/o loading the type.
                // The check takes place after config.LoadLanguageContext is called to avoid calling user code while holding a lock.
                lock (_loadedProviderTypes) {
                    LanguageConfiguration existingConfig;
                    Type type = language.GetType();
                    if (_loadedProviderTypes.TryGetValue(type, out existingConfig)) {
                        throw new InvalidOperationException(String.Format("Language implemented by type '{0}' has already been loaded using name '{1}'",
                            config.ProviderName, existingConfig.ProviderName));
                    }

                    _loadedProviderTypes.Add(type, config);
                }
            }
            return language;
        }