示例#1
0
        public LocaleContent LocaleContent(string lang)
        {
            var content = ConfigDocument.SelectSingleNode("//w:content[lang(\"" + lang + "\")]", nsmgr);

            if (content != null)
            {
                var locContent = new LocaleContent
                {
                    Dir      = content.Attributes["ltr"] != null ? content.Attributes["ltr"].Value : "ltr",
                    Type     = content.Attributes["type"] != null ? content.Attributes["type"].Value : "text/html",
                    Url      = content.Attributes["src"] != null ? content.Attributes["src"].Value : "",
                    Encoding = content.Attributes["encoding"] != null ? content.Attributes["encoding"].Value : "utf-8",
                    Text     = content.InnerText
                };

                if (!string.IsNullOrEmpty(locContent.Url))
                {
                    ResolveUri(locContent.Url, lang: lang);
                }

                return(locContent);
            }

            return(new LocaleContent
            {
                Type = this.ContentType,
                Url = !string.IsNullOrEmpty(this.ContentUrl) ? ResolveUri(this.ContentUrl) : "",
                Encoding = this.Encoding,
                Text = this.ContentText,
                Dir = this.ContentDirection
            });
        }
示例#2
0
        public LocaleContent LocaleContent(string lang)
        {
            var content = ConfigDocument.SelectSingleNode("//w:content[lang(\"" + lang + "\")]", nsmgr);
            if (content != null)
            {
                var locContent = new LocaleContent
                {
                    Dir = content.Attributes["ltr"] != null ? content.Attributes["ltr"].Value : "ltr",
                    Type = content.Attributes["type"] != null ? content.Attributes["type"].Value : "text/html",
                    Url = content.Attributes["src"] != null ? content.Attributes["src"].Value : "",
                    Encoding = content.Attributes["encoding"] != null ? content.Attributes["encoding"].Value : "utf-8",
                    Text = content.InnerText
                };

                if (!string.IsNullOrEmpty(locContent.Url))
                    ResolveUri(locContent.Url, lang: lang);

                return locContent;
            }

            return new LocaleContent
            {
                Type = this.ContentType,
                Url = !string.IsNullOrEmpty(this.ContentUrl) ? ResolveUri(this.ContentUrl) : "",
                Encoding = this.Encoding,
                Text = this.ContentText,
                Dir = this.ContentDirection
            };
        }