Пример #1
0
        public PropertyMappingValue GetMapping(string sourcePropertyName)
        {
            PropertyMappingValue propertyMappingValue = null;

            _propertyMappingValues.TryGetValue(sourcePropertyName, out propertyMappingValue);
            return
                (propertyMappingValue
                 ?? throw new InvalidPropertyMappingException($"Source property name '{sourcePropertyName}' for source type {typeof(TSource)} not mapped to target type {typeof(TTarget)}."));
        }
Пример #2
0
        public IEnumerable <PropertyMappingValue> GetMappings(params string[] sourcePropertyNames)
        {
            PropertyMappingValue        propertyMappingValue  = null;
            List <PropertyMappingValue> propertyMappingValues = new List <PropertyMappingValue>();

            Array.ForEach(sourcePropertyNames, sourcePropertyName =>
            {
                _propertyMappingValues.TryGetValue(sourcePropertyName, out propertyMappingValue);
                if (propertyMappingValue == null)
                {
                    throw new InvalidPropertyMappingException($"Source property name '{sourcePropertyName}' for source type {typeof(TSource)} not mapped to target type {typeof(TTarget)}.");
                }
                propertyMappingValues.Add(propertyMappingValue);
            });
            return(propertyMappingValues);
        }