コード例 #1
0
        private static void AttributeAppend(DomAttribute left,
                                            DomAttribute append)
        {
            var toElement       = left.OwnerElement;
            var appendThunkFrag = append as HxlAttribute.ThunkFragment;

            if (appendThunkFrag == null)
            {
                AttributeAppend(left, append.Value);
            }

            else
            {
                toElement.Attributes.Remove(append.Name);
                Func <dynamic, HxlAttribute, string> thunkLeft;

                var leftThunkFrag = left as HxlAttribute.ThunkFragment;
                if (leftThunkFrag == null)
                {
                    // No need to create a closure on the whole attribute
                    string leftValue = left.Value;
                    thunkLeft = (x, y) => leftValue;
                }
                else
                {
                    thunkLeft = leftThunkFrag._action;
                }

                var attr = HxlAttribute.Combine(left.Name, thunkLeft, appendThunkFrag._action);
                toElement.Append(attr);
            }
        }
コード例 #2
0
        internal static void RenderElementStart(DomElement element, TextWriter w)
        {
            w.Write("<");
            w.Write(element.Name);

            foreach (var entry in element.Attributes)
            {
                if (!HxlAttribute.IsClientAttribute(entry))
                {
                    continue;
                }

                w.Write(" ");
                w.Write(entry.Name);

                if (entry.Value != null)
                {
                    w.Write("=\"");
                    w.Write(entry.Value); // TODO Conditional - HtmlEncoder.Escape(entry.Value, settings.Charset.GetEncoder(), settings.EscapeMode));
                    w.Write("\"");
                }
            }

            if (settings.IsXhtml && (element.ChildNodes.Count == 0 && Utility.IsSelfClosing(element)))
            {
                w.Write(" />");
            }
            else
            {
                w.Write(">");
            }
        }
コード例 #3
0
        // Appends the given value to the attribute which uses a
        // merging semantic like "class"
        private static void AttributeAppend(DomAttribute left,
                                            string appendValue)
        {
            var toElement     = left.OwnerElement;
            var thunkFragment = left as HxlAttribute.ThunkFragment;

            if (thunkFragment != null)
            {
                toElement.RemoveAttribute(left.Name);

                var combo = HxlAttribute.Combine(
                    left.Name,
                    thunkFragment._action,
                    (x, y) => appendValue);
                toElement.Append(combo);
            }

            else if (!string.IsNullOrWhiteSpace(left.Value))
            {
                left.Value += " " + appendValue;
            }

            else
            {
                left.Value = appendValue;
            }
        }
コード例 #4
0
 static string AttributeName(Type type)
 {
     return(FindPrefix(type) + HxlAttribute.GetImplicitName(type));
 }
コード例 #5
0
 protected override IEnumerable <string> GetDefaultProviderNames(Type type)
 {
     return(new [] {
         HxlAttribute.GetImplicitName(type)
     });
 }
コード例 #6
0
 public ValueDomValue(HxlAttribute attribute, PropertyInfo property)
 {
     this._attr = attribute;
     this._pd   = property;
 }
コード例 #7
0
 void IHxlVisitor.Visit(HxlAttribute attribute)
 {
     VisitAttributeFragment(attribute);
 }
コード例 #8
0
 protected virtual void VisitAttributeFragment(HxlAttribute fragment)
 {
     DefaultVisit(fragment);
 }