INamespaceScope DoFindOrCreateNamespace(string[] names, int idx) { var exist = _subNamespaces.FirstOrDefault(x => x.Name == names[idx]); if (exist == null) { exist = new NamespaceScopeImpl(Workspace, this, names[idx]); _subNamespaces.Add(exist); Workspace.OnNamespaceCreated(exist); } return(names.Length == ++idx ? exist : exist.DoFindOrCreateNamespace(names, idx)); }
internal void MergeWith(NamespaceScopeImpl other) { Debug.Assert(other != null); _beforeNamespace.MergeWith(other._beforeNamespace); foreach (var u in other._usings) { DoEnsureUsing(u.Key, u.Value.Key, u.Value.Value); } CodePart.MergeWith(other.CodePart); MergeTypes(other); foreach (var oNS in other._subNamespaces) { var my = _subNamespaces.FirstOrDefault(x => x.Name == oNS.Name); if (my == null) { my = new NamespaceScopeImpl(Workspace, this, oNS.Name); _subNamespaces.Add(my); } my.MergeWith(oNS); } }
internal void OnNamespaceCreated(NamespaceScopeImpl n) => NamespaceCreated?.Invoke(n);
public CodeWorkspaceImpl() { _assemblies = new HashSet <Assembly>(); Global = new NamespaceScopeImpl(this, null, String.Empty); }