Esempio n. 1
0
        private static CultureString CreateCultureStringFromXElement(XElement root, string attributeCondition)
        {
            CultureString cultureString = new CultureString();

            if (root.Name != XDocName.Annotation)
            {
                return(cultureString);
            }

            attributeCondition = attributeCondition.ToLower();
            foreach (XElement element in root.Elements(XDocName.Documentation))
            {
                XElement textElement = element.Element(XDocName.Tekst);
                if (textElement == null)
                {
                    continue;
                }

                XAttribute type = textElement.Attribute(XDocName.TextType);
                XAttribute lang = textElement.Attribute(XDocName.Lang);

                // Skip creating if one of the elements weren't found, or the type does not match to condition
                if (type == null || lang == null || type.Value.ToLower() != attributeCondition)
                {
                    continue;
                }

                string text = element.Value;

                if (text.StartsWith("<p>"))
                {
                    text = text.Remove(0, 2);
                }

                if (text.EndsWith("<p>"))
                {
                    text = text.Remove(text.Length - 3, text.Length);
                }

                cultureString.Add(text, lang.Value);
            }

            return(cultureString);
        }