/// <summary>Attempts to get cached data for the given location.</summary>
        public CachedContent GetCached(Dom.Location location, bool create)
        {
            // Get the cache domain data (never null):
            DomainData domain = GetDomain(location);

            if (domain.Content == null)
            {
                if (create)
                {
                    // Create the content set:
                    domain.Content = new CachedContentSet(domain);
                }
                else
                {
                    return(null);
                }
            }

            // Get the entry:
            string path = GetRelative(location);

            CachedContent e;

            if (!domain.Content.Entries.TryGetValue(path, out e) && create)
            {
                // Create the entry:
                e = new CachedContent(domain.Content, path);

                // Add it:
                domain.Content.Add(path, e);
            }

            return(e);
        }
Beispiel #2
0
        /// <summary>Collects all available documents from the main UI and any WorldUI's.</summary>
        public static List <DocumentEntry> GetDocuments(bool refresh)
        {
            if (AllDocuments_ != null && !refresh)
            {
                return(AllDocuments_);
            }

            List <DocumentEntry> results = new List <DocumentEntry>();

            AllDocuments_ = results;

            // First, search UI.document:
            Search(UI.document, "Main UI", results);

            // Search every WorldUI:
            WorldUI current = UI.LastWorldUI;

            while (current != null)
            {
                // Search it too:
                Search(current.document, current.Name, results);

                current = current.UIBefore;
            }

            // Cache names:
            AllDocumentNames_ = new string[results.Count];

            for (int i = 0; i < results.Count; i++)
            {
                results[i].Index = i;

                string name = results[i].Name;

                if (string.IsNullOrEmpty(name))
                {
                    // Using doc.location:
                    Dom.Location loc = results[i].Document.location;

                    if (loc == null)
                    {
                        name = "about:blank";
                    }
                    else
                    {
                        name = loc.absolute;
                    }
                }

                name = ListableName(name);

                // Set into names:
                AllDocumentNames_[i] = name;
            }

            return(results);
        }
 /// <summary>Gets the relative path for the given location.</summary>
 public virtual string GetRelative(Dom.Location location)
 {
     return(location.relative);
 }
 /// <summary>Gets the domain data for the given location.</summary>
 public virtual DomainData GetDomain(Dom.Location location)
 {
     return(Cache.GetDomain(location.host));
 }
 /// <summary>Attempts to get cached data for the given location. Used to enable caching (off by default).</summary>
 public virtual CachedContent GetCached(Dom.Location location)
 {
     return(null);
 }
 /// <summary>Attempts to get cached data for the given location.</summary>
 public override CachedContent GetCached(Dom.Location location)
 {
     // Standard cached data:
     return(GetCached(location, false));
 }