Example #1
0
        public Source GetSource(string relativeReference)
        {
            const string method = "GetSource";

            if (relativeReference == null)
            {
                throw new NullParameterException(GetType(), method, "relativeReference");
            }

            var catalogueName = new CatalogueName(relativeReference);

            Namespace ns = (catalogueName.Namespace.Length == 0 ? _searchRoot as Namespace :
                            GetNamespace(catalogueName.Namespace));

            if (ns == null)
            {
                return(null);
            }

            ICatalogueSearch search = GetCatalogueSearch();

            if (search == null)
            {
                // Repository search not available, so load the Sources collection if necessary.

                return(ns.Sources.GetItem(catalogueName.RelativeQualifiedReference, Options.IgnoreCase, true));
            }

            // Search in memory first, without loading the Sources collection.

            Source result = ns.Sources.GetItem(catalogueName.RelativeQualifiedReference, Options.IgnoreCase,
                                               false);

            // If the search failed, but the collection was not loaded then search the repository.

            if (result == null && !ns.Sources.IsLoaded)
            {
                return(search.GetSource(ns, catalogueName.Name, Options.IgnoreCase));
            }
            return(result);
        }
Example #2
0
        public Namespace GetNamespace(string relativeName)
        {
            const string method = "GetNamespace";

            if (relativeName == null)
            {
                throw new NullParameterException(GetType(), method, "relativeName");
            }

            ICatalogueSearch search = GetCatalogueSearch();

            if (search == null)
            {
                // Repository search not available, iterate.

                return(GetNamespaceMandatory(relativeName));
            }

            // Search in memory first, without loading collections.

            INamespaceParent found;
            string           remainingPath;

            if (GetNamespaceOptional(relativeName, out found, out remainingPath))
            {
                return((Namespace)found);
            }

            // If the search failed, but some collections were not loaded then search the repository.

            if (remainingPath != null)
            {
                return(search.GetNamespace(found, remainingPath, Options.IgnoreCase));
            }

            return(null);        // All collections were already loaded, but the namespace was still not found.
        }