Example #1
0
        internal static System.Type GetBaseType(PropertyInfo property, object owner, IServiceProvider serviceProvider)
        {
            if (owner == null)
            {
                throw new ArgumentNullException("owner");
            }
            if (serviceProvider == null)
            {
                throw new ArgumentNullException("serviceProvider");
            }
            if (property == null)
            {
                return(null);
            }
            IDynamicPropertyTypeProvider provider = owner as IDynamicPropertyTypeProvider;

            if (provider != null)
            {
                System.Type propertyType = provider.GetPropertyType(serviceProvider, property.Name);
                if (propertyType != null)
                {
                    return(propertyType);
                }
            }
            return(property.PropertyType);
        }
        internal static Type GetBaseType(IServiceProvider serviceProvider, PropertyValidationContext validationContext)
        {
            Type propertyType = null;

            if (validationContext.Property is PropertyInfo)
            {
                return(Helpers.GetBaseType(validationContext.Property as PropertyInfo, validationContext.PropertyOwner, serviceProvider));
            }
            if (validationContext.Property is DependencyProperty)
            {
                DependencyProperty property = validationContext.Property as DependencyProperty;
                if (property == null)
                {
                    return(propertyType);
                }
                if (propertyType == null)
                {
                    IDynamicPropertyTypeProvider propertyOwner = validationContext.PropertyOwner as IDynamicPropertyTypeProvider;
                    if (propertyOwner != null)
                    {
                        propertyType = propertyOwner.GetPropertyType(serviceProvider, property.Name);
                    }
                }
                if (propertyType == null)
                {
                    propertyType = property.PropertyType;
                }
            }
            return(propertyType);
        }
        internal static Type GetBaseType(PropertyDescriptor property, object owner, IServiceProvider serviceProvider)
        {
            Type propertyType = null;

            owner.GetType();
            if (owner != null)
            {
                IDynamicPropertyTypeProvider provider = owner as IDynamicPropertyTypeProvider;
                if (provider != null)
                {
                    propertyType = provider.GetPropertyType(serviceProvider, property.Name);
                }
            }
            if (propertyType == null)
            {
                propertyType = property.PropertyType;
            }
            return(propertyType);
        }