public static void RegisterDom(ProjectDom dom, string uri)
 {
     dom.Uri         = uri;
     databases [uri] = dom;
     dom.UpdateReferences();
     OnDomRegistered(new ProjectDomEventArgs(dom));
 }
        public static ProjectDom GetFileDom(FilePath file)
        {
            if (file.IsNull)
            {
                file = Path.GetTempFileName();
            }

            file = file.CanonicalPath;

            lock (singleDatabases)
            {
                SingleFileCacheEntry entry;
                if (singleDatabases.TryGetValue(file, out entry))
                {
                    entry.AccessTime = DateTime.Now;
                    return(entry.Database);
                }
                else
                {
                    if (singleDatabases.Count >= MAX_SINGLEDB_CACHE_SIZE)
                    {
                        DateTime tim      = DateTime.MaxValue;
                        string   toDelete = null;
                        foreach (KeyValuePair <FilePath, SingleFileCacheEntry> pce in singleDatabases)
                        {
                            DateTime ptim = pce.Value.AccessTime;
                            if (ptim < tim)
                            {
                                tim      = ptim;
                                toDelete = pce.Key;
                            }
                        }
                        singleDatabases.Remove(toDelete);
                    }


                    ProjectDom db = ParserDatabase.LoadSingleFileDom(file);
                    db.Uri = "File:" + file;
                    db.UpdateReferences();
                    entry                  = new SingleFileCacheEntry();
                    entry.Database         = db;
                    entry.AccessTime       = DateTime.Now;
                    singleDatabases [file] = entry;
                    db.ReferenceCount      = 1;
                    return(db);
                }
            }
        }
        public static void Load(WorkspaceItem item)
        {
            if (IncLoadCount(item) != 1)
            {
                return;
            }

            lock (databases) {
                if (item is Workspace)
                {
                    Workspace ws = (Workspace)item;
                    foreach (WorkspaceItem it in ws.Items)
                    {
                        Load(it);
                    }
                    ws.ItemAdded   += OnWorkspaceItemAdded;
                    ws.ItemRemoved += OnWorkspaceItemRemoved;
                }
                else if (item is Solution)
                {
                    Solution solution = (Solution)item;
                    foreach (Project project in solution.GetAllProjects())
                    {
                        Load(project);
                    }
                    // Refresh the references of all projects. This is necessary because
                    // some project may have been loaded before the projects their reference,
                    // in which case those references are not properly registered.
                    foreach (Project project in solution.GetAllProjects())
                    {
                        ProjectDom dom = GetProjectDom(project);
                        // referenced by main project - prevents the removal if a project is referenced one time inside the solution
                        // and the project that references it is reloaded.
                        dom.ReferenceCount++;
                        if (dom != null)
                        {
                            dom.UpdateReferences();
                        }
                    }
                    solution.SolutionItemAdded   += OnSolutionItemAdded;
                    solution.SolutionItemRemoved += OnSolutionItemRemoved;
                }
            }
        }
		public static void RegisterDom (ProjectDom dom, string uri)
		{
			dom.Uri = uri;
			databases [uri] = dom;
			dom.UpdateReferences ();
			OnDomRegistered (new ProjectDomEventArgs (dom));
		}
		public static void RegisterDom (ProjectDom dom, string uri)
		{
			dom.Uri = uri;
			databases [uri] = dom;
			dom.UpdateReferences ();
		}
 public static void RegisterDom(ProjectDom dom, string uri)
 {
     dom.Uri         = uri;
     databases [uri] = dom;
     dom.UpdateReferences();
 }