Example #1
0
        public static IElementFactory FromXamlElement(XamlElement element, Type targetType)
        {
            Type elementType = element.GetElementType();

            if (element.Values.Any() && ContentPropertyAttribute.GetPropertyName(elementType).IsNullOrEmpty() && !ElementCollectionContentInitailizer.IsCollectionType(elementType))
            {
                return(FromElementFactory(FromXamlElementContent(element), targetType, element.Namespaces, element.SourceUri));
            }

            IElementInitializer elementInitializer = new ElementInitializer(element);
            IElementFactory     elementFactory     = new ElementFactory(elementType, elementInitializer);

            return(FromElementFactory(elementFactory, targetType, element.Namespaces, element.SourceUri));
        }
Example #2
0
        public static IElementFactory FromXamlElement(XamlElement element, Type targetType)
        {
            Type elementType = element.GetElementType();

            if (elementType.GetDefaultConstructor() == null)
            {
                return(FromElementFactory(FromXamlElementContent(element), targetType, element.Namespaces));
            }

            IElementInitializer elementInitializer = new ElementInitializer(element);
            IElementFactory     elementFactory     = new ElementFactory(elementType, elementInitializer);

            return(FromElementFactory(elementFactory, targetType, element.Namespaces));
        }
Example #3
0
        public static void Load(object target, XamlElement resource)
        {
            IElementInitializer initializer = new ElementInitializer(resource);

            initializer.InitializeElement(target, new InitializeContext());
        }
Example #4
0
        public static IElementFactory FromXamlElement(XamlElement element, Type targetType)
        {
            Type elementType = element.GetElementType();

            if (elementType.GetDefaultConstructor() == null)
            {
                return FromElementFactory(FromXamlElementContent(element), targetType, element.Namespaces);
            }

            IElementInitializer elementInitializer = new ElementInitializer(element);
            IElementFactory elementFactory = new ElementFactory(elementType, elementInitializer);

            return FromElementFactory(elementFactory, targetType, element.Namespaces);
        }
Example #5
0
 public static void Load(object target, XamlElement resource)
 {
     IElementInitializer initializer = new ElementInitializer(resource);
     initializer.InitializeElement(target, new InitializeContext());
 }