Ejemplo n.º 1
0
 public bool Equals(HtmlTagAttributePair other)
 {
     return string.Equals(TagName, other.TagName, StringComparison.OrdinalIgnoreCase) && string.Equals(AttributeName, other.AttributeName, StringComparison.OrdinalIgnoreCase);
 }
Ejemplo n.º 2
0
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            var value = reader.ReadAsString();
            if (value == null)
            {
                ThrowInvalidFormatException();
            }

            var match = Regex.Match(value, @"^([a-zA-Z0-9]+)\[([a-zA-Z0-9]+)\]$");
            if (!match.Success)
            {
                ThrowInvalidFormatException();
            }

            if (existingValue == null)
            {
                existingValue = new HtmlTagAttributePair();
            }
            var pair = (HtmlTagAttributePair) existingValue;
            pair.TagName = match.Groups[1].Value;
            pair.AttributeName = match.Groups[2].Value;
            return pair;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Renders the begin tag without end char.
        /// </summary>
        private void RenderBeginTagCore(string name)
        {
            writer.Write("<");
            writer.Write(name);

            if (attributes.Count > 0)
            {
                foreach (DictionaryEntry attr in attributes)
                {
                    var attributeName = (string)attr.Key;
                    var attributeValue = (string)attr.Value;

                    // allow to use the attribute transformer
                    var pair = new HtmlTagAttributePair() { TagName = name, AttributeName = attributeName };
                    HtmlAttributeTransformConfiguration transformConfiguration;
                    if (requestContext.Configuration.Markup.HtmlAttributeTransforms.TryGetValue(pair, out transformConfiguration))
                    {
                        // use the transformer
                        var transformer = transformConfiguration.GetInstance();
                        transformer.RenderHtmlAttribute(this, requestContext, attributeName, attributeValue);
                    }
                    else
                    {
                        WriteHtmlAttribute(attributeName, attributeValue);
                    }
                }
            }

            attributes.Clear();
        }