public override void InjectTypeProperties()
        {
            var resolvedProperties = Context.ResolvedProperties;

            //resolving injection properties, which wheren't registered in the "PropertyInjections"
            var propsToInjectValue = Context.SourceType.GetProperties()
                                     .Select(Context.GetPropertyMappingInfo)
                                     .Where(x => !resolvedProperties.Contains(x)).ToArray();

            foreach (var prop in propsToInjectValue)
            {
                var propKey = BuilderUtils.GetKey(prop);
                //mark ignored propertieswas as resolved
                if (Context.IgnoreProperties.Contains(propKey))
                {
                    resolvedProperties.Add(prop);
                    continue;
                }

                var resolutionResult = ResolvePropertyInfo(prop);
                if (resolutionResult != null)
                {
                    Context.MapProperty(prop, resolutionResult);
                }
            }
        }
        public void InjectNamedProperty <TProp>(Expression <Func <TClass, TProp> > poperty, string reristeredName)
        {
            var propInfo = TypeHelpers.GetPropertyInfo(poperty);
            var key      = BuilderUtils.GetKey(propInfo);

            PropertyInjectionResolvers.Add(key, new KeyValuePair <string, Type>(reristeredName, propInfo.PropertyType));
        }
        public ISourceInfo ResolveSourceValue(IPropertyMappingInfo propertyInfo, object source)
        {
            var    key = BuilderUtils.GetKey(propertyInfo);
            object value;

            if (propertyInjections.TryGetValue(key, out value))
            {
                return(SourceInfo.Create(value));
            }
            return(null);
        }
        public ISourceInfo ResolveSourceValue(IPropertyMappingInfo propInfo, object source)
        {
            var propInfoKey = BuilderUtils.GetKey(propInfo);
            KeyValuePair <string, Type> valueType;

            if (PropertyInjectionResolvers.TryGetValue(propInfoKey, out valueType))
            {
                object value;
                if (locator.TryResolve(valueType.Value, valueType.Key, out value))
                {
                    return(SourceInfo.Create(value));
                }
            }
            return(null);
        }
 public bool IsMemberSuitable(IPropertyMappingInfo propertyInfo)
 {
     return(propertyInjections.ContainsKey(BuilderUtils.GetKey(propertyInfo)));
 }
        public void RegisterInjection <TClass, TProp>(Expression <Func <TClass, TProp> > poperty, TProp value)
        {
            var propInfo = TypeHelpers.GetPropertyInfo(poperty);

            propertyInjections.Add(BuilderUtils.GetKey(propInfo), value);
        }
        public void AddInjectionResolver(PropertyInfo propInfo, Type type)
        {
            var key = BuilderUtils.GetKey(propInfo);

            PropertyInjectionResolvers.Add(key, new KeyValuePair <string, Type>(string.Empty, type));
        }
        public bool IsMemberSuitable(IPropertyMappingInfo propInfo)
        {
            var propInfoKey = BuilderUtils.GetKey(propInfo);

            return(PropertyInjectionResolvers.ContainsKey(propInfoKey));
        }
Exemple #9
0
        public void IgnoreProperty <TProp>(Expression <Func <TClass, TProp> > expression)
        {
            var propInfo = TypeHelpers.GetPropertyInfo(expression);

            IgnoredProperties.Add(BuilderUtils.GetKey(propInfo));
        }