Sage.ResourceManagement.SageResourceResolver.GetEntity C# (CSharp) Method

GetEntity() public method

public GetEntity ( UrlResolver parent, SageContext context, string resourceUri ) : EntityResult
parent UrlResolver
context SageContext
resourceUri string
return EntityResult
        public EntityResult GetEntity(UrlResolver parent, SageContext context, string resourceUri)
        {
            string resourceName = this.GetResourceName(resourceUri);
                XmlReaderSettings settings = CacheableXmlDocument.CreateReaderSettings(parent);

            CacheableXmlDocument resourceDoc;

            // first check if we have a registered provider for the specified resour name
            if (providers.ContainsKey(resourceName))
            {
                XmlProvider provider = providers[resourceName];
                log.DebugFormat("Found a specific resource provider for {0}: {1}",
                    resourceUri,
                    Util.GetMethodSignature(provider.Method));

                resourceDoc = provider(context, resourceUri);
            }
            else
            {
                string sourcePath = context.Path.Expand(resourceName);
                if (sourcePath == null || !File.Exists(sourcePath))
                    throw new FileNotFoundException(string.Format("The specified resource '{0}' doesn't exist.", resourceUri));

                resourceDoc = context.Resources.LoadXml(sourcePath);
            }

            XmlReader reader = XmlReader.Create(new StringReader(resourceDoc.OuterXml), settings, resourceUri);
            return new EntityResult { Entity = reader, Dependencies = resourceDoc.Dependencies };
        }