Ejemplo n.º 1
0
 public static IElementInitializer FromXamlAttribute(IPropertyAdapter propertyAdapter, XamlAttribute memberAttribute)
 {
     IElementFactory contentFactory = ElementFactory.FromXamlAttribute(memberAttribute, propertyAdapter.PropertyType);
     return new ElementPropertyMemberInitializer(propertyAdapter, contentFactory);
 }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
 public static IElementInitializer FromXamlAttribute(IEventAdapter eventAdapter, XamlAttribute eventAttribute)
 {
     return new ElementEventMemberInitializer(eventAdapter, GetEventHandlerName(eventAttribute));
 }
Ejemplo n.º 4
0
        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;
        }
Ejemplo n.º 5
0
        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);
        }