public static IElementInitializer FromXamlAttribute(IPropertyAdapter propertyAdapter, XamlAttribute memberAttribute) { IElementFactory contentFactory = ElementFactory.FromXamlAttribute(memberAttribute, propertyAdapter.PropertyType); return new ElementPropertyMemberInitializer(propertyAdapter, contentFactory); }
public static IElementInitializer FromXamlAttribute(XamlName memberName, XamlAttribute memberAttribute, Type containingType) { IEventAdapter eventAdapter = EventAdapter.CreateAdapter(containingType, memberName); if (eventAdapter != null) { return ElementEventMemberInitializer.FromXamlAttribute(eventAdapter, memberAttribute); } IPropertyAdapter propertyAdapter = PropertyAdapter.CreateAdapter(containingType, memberName); if (propertyAdapter != null) { return ElementPropertyMemberInitializer.FromXamlAttribute(propertyAdapter, memberAttribute); } throw new Granular.Exception("Type \"{0}\" does not contain a member named \"{1}\"", containingType.Name, memberName); }
public static IElementInitializer FromXamlAttribute(IEventAdapter eventAdapter, XamlAttribute eventAttribute) { return new ElementEventMemberInitializer(eventAdapter, GetEventHandlerName(eventAttribute)); }
private static string GetEventHandlerName(XamlAttribute attribute) { if (!(attribute.Value is String)) { throw new Granular.Exception("Attribute \"{0}\" value is not an event handler name", attribute.Name); } return (string)attribute.Value; }
public static IElementFactory FromXamlAttribute(XamlAttribute attribute, Type targetType) { if (attribute.Value is XamlElement) { return FromXamlElement((XamlElement)attribute.Value, targetType); } return FromElementFactory(new ConstantElementFactory(attribute.Value), targetType, attribute.Namespaces); }