Exemplo n.º 1
0
        public IPropertyStrategy ForProperty(PropertyInfo property)
        {
            PropertyStrategy strategy;

            return(PropertyStrategies.TryGetValue(KeyFor(property), out strategy)
                ? strategy : DefaultPropertyStrategy);
        }
Exemplo n.º 2
0
        public IConfigurePropertyStrategy <TProperty> Map <TProperty>(Expression <Func <T, TProperty> > property)
        {
            var propertyName = PropertyName(property);

            return(PropertyStrategies.GetOrAdd(propertyName,
                                               new ConfigurePropertyStrategy <TProperty>()) as IConfigurePropertyStrategy <TProperty>);
        }
Exemplo n.º 3
0
        public IPropertyStrategy ForProperty(PropertyInfo property)
        {
            if (PropertyStrategies.TryGetValue(KeyFor(property), out var strategy))
            {
                return(strategy);
            }

            var defaultValueAttribute = property.GetCustomAttributes <DefaultValueAttribute>(true).SingleOrDefault();

            if (defaultValueAttribute == null)
            {
                var interfaceProperties = property.DeclaringType?.GetInterfaces().Select(e => e.GetProperties().SingleOrDefault(p => p.Name == property.Name));
                defaultValueAttribute = interfaceProperties?.FirstOrDefault()?.GetCustomAttributes <DefaultValueAttribute>(true).SingleOrDefault();
            }
            return(defaultValueAttribute != null ? new PropertyStrategy(defaultValueAttribute.Value) : DefaultPropertyStrategy);
        }