Beispiel #1
0
 private void ReadSpanContent(LiftMultiText text, string lang, LiftSpan span, XmlNode node)
 {
     Debug.Assert(node.Name == "span");
     foreach (XmlNode xn in node.ChildNodes)
     {
         if (xn.Name == "span")
         {
             var spanLang = Utilities.GetOptionalAttributeString(xn, "lang");
             if (spanLang == lang)
             {
                 spanLang = null;
             }
             var spanInner = new LiftSpan(text.LengthOfAlternative(lang),
                                          xn.InnerText.Length,
                                          spanLang,
                                          Utilities.GetOptionalAttributeString(xn, "class"),
                                          Utilities.GetOptionalAttributeString(xn, "href"));
             span.Spans.Add(spanInner);
             ReadSpanContent(text, lang, spanInner, xn);
         }
         else
         {
             text.AddOrAppend(lang, xn.InnerText, "");
         }
     }
 }
Beispiel #2
0
        /// <summary>This must be overridden for tests to pass.</summary>
        public override bool Equals(object obj)
        {
            LiftSpan that = obj as LiftSpan;

            if (that == null)
            {
                return(false);
            }
            if (_index != that._index)
            {
                return(false);
            }
            if (_length != that._length)
            {
                return(false);
            }
            if (_lang != that._lang)
            {
                return(false);
            }
            if (_class != that._class)
            {
                return(false);
            }
            if (_linkurl != that._linkurl)
            {
                return(false);
            }
            return(true);
        }
Beispiel #3
0
        /// <summary>
        /// Add another span to the given alternative, creating the alternative if needed.
        /// </summary>
        public LiftSpan AddSpan(string key, string lang, string style, string href, int length)
        {
            LiftString alternative;

            if (!TryGetValue(key, out alternative))
            {
                alternative = new LiftString();
                this[key]   = alternative;
            }
            int start = alternative.Text.Length;

            if (lang == key)
            {
                lang = null;
            }
            var span = new LiftSpan(start, length, lang, style, href);

            alternative.Spans.Add(span);
            return(span);
        }