예제 #1
0
 private void ParseCssStyle(string cssStyles)
 {
     string[] array = cssStyles.Split(new char[1]
     {
         ';'
     }, StringSplitOptions.RemoveEmptyEntries);
     m_parsedCssStyleValues = new Dictionary <string, string>(array.Length, StringEqualityComparer.Instance);
     foreach (string text in array)
     {
         string text2 = string.Empty;
         string html  = string.Empty;
         int    num   = text.IndexOf(':');
         if (num == -1)
         {
             text2 = text.Trim();
         }
         else if (num > 0)
         {
             text2 = text.Substring(0, num).Trim();
             if (num + 1 < text.Length)
             {
                 html = text.Substring(num + 1).Trim();
             }
         }
         if (!string.IsNullOrEmpty(text2))
         {
             m_parsedCssStyleValues[text2.ToLowerInvariant()] = HtmlEntityResolver.ResolveEntities(html).ToLowerInvariant();
         }
     }
 }
예제 #2
0
 private void ParseAttributes()
 {
     if (m_attributesAsString != null)
     {
         MatchCollection matchCollection = m_AttributeRegEx.Matches(m_attributesAsString.Trim());
         if (matchCollection.Count > 0)
         {
             m_parsedAttributes = new Dictionary <string, string>(matchCollection.Count, StringEqualityComparer.Instance);
             for (int i = 0; i < matchCollection.Count; i++)
             {
                 Match  match = matchCollection[i];
                 string text  = null;
                 string html  = null;
                 System.Text.RegularExpressions.Group group = match.Groups["name"];
                 if (group.Length <= 0)
                 {
                     continue;
                 }
                 text  = group.Value;
                 group = match.Groups["quotedvalue"];
                 if (group.Length > 0)
                 {
                     html = group.Value;
                 }
                 else
                 {
                     group = match.Groups["singlequotedvalue"];
                     if (group.Length > 0)
                     {
                         html = group.Value;
                     }
                     else
                     {
                         group = match.Groups["value"];
                         if (group.Length > 0)
                         {
                             html = group.Value;
                         }
                     }
                 }
                 m_parsedAttributes[text.ToLowerInvariant()] = HtmlEntityResolver.ResolveEntities(html);
             }
         }
     }
     m_attributesAsString = null;
 }