public ScriptLanguageContext(ScriptDomainManager domainManager, IDictionary <string, object> options) : base(domainManager) { _topNamespace = new TopNamespaceTracker(domainManager); _aliasedNamespaceGroups = new Dictionary <string, NamespaceGroupTracker>(); _scriptVisibleNamespaces = new NamespaceGroupTracker("$sxe", _topNamespace); if ((_onAssemblyLoadHandler == null) && (Interlocked.CompareExchange(ref _onAssemblyLoadHandler, OnAssemblyLoaded, null) == null)) { DomainManager.AssemblyLoaded += _onAssemblyLoadHandler; } foreach (var assembly in DomainManager.GetLoadedAssemblyList()) { LoadAssembly(assembly); } LoadAssemblyScriptImports(typeof(ScriptLanguageContext).Assembly); _defaultBinderState = new BinderState(new ScriptBinder(this)); _overloadResolver = new ScriptOverloadResolverFactory(this); EnsureParser(); }
private void LoadAssembly(Assembly assembly) { if (!_topNamespace.LoadAssembly(assembly)) { return; } LoadAssemblyScriptImports(assembly); var aliasAttributes = assembly .GetCustomAttributes(typeof(ScriptNamespaceAliasAttribute), false) .Cast <ScriptNamespaceAliasAttribute>(); foreach (var aliasAttribute in aliasAttributes) { var namespaceTracker = LookupNamespace(aliasAttribute.Namespace); if (namespaceTracker == null) { continue; } lock (_aliasedNamespaceGroups) { NamespaceGroupTracker aliasedNamespaces; if (!_aliasedNamespaceGroups.TryGetValue(aliasAttribute.Alias, out aliasedNamespaces)) { _aliasedNamespaceGroups[aliasAttribute.Alias] = aliasedNamespaces = new NamespaceGroupTracker(aliasAttribute.Alias, _topNamespace); } aliasedNamespaces.IncludeNamespace(namespaceTracker); } } }