Esempio n. 1
0
        public ContentResult GetContent(Type type, long id)
        {
            var xpath = ContentProvider.GetXpath(type, id);

            if (xpath == null)
            {
                return(ThrowsOnNotFound
                    ? (ContentResult)null
                    : throw new XpathNotFoundException(type, id));
            }

            var contentNode = Context.SelectSingleNode(xpath);
            var contentText = contentNode.InnerText;

            if (!ContentProvider.CanParse(type))
            {
                return(new ContentResult(contentText));
            }

            return(new ContentResult(ContentProvider.Parse(type, contentText)));
        }
Esempio n. 2
0
        public ContentResult <T> GetContent <T>(long id)
        {
            var xpath = ContentProvider.GetXpath <T>(id);

            if (xpath == null)
            {
                return(ThrowsOnNotFound
                    ? (ContentResult <T>)null
                    : throw new XpathNotFoundException <T>(id));
            }

            var contentNode = Context.SelectSingleNode(xpath);
            var contentText = contentNode.InnerText;

            if (!ContentProvider.CanParse <T>())
            {
                return(new ContentResult <T>(contentText));
            }

            return(new ContentResult <T>(ContentProvider.Parse <T>(contentText)));
        }