Beispiel #1
0
        internal Mapper(Mapper <TKey, TValue> mapper, KeyPredicate <TKey> keyPredicate, ValueFunc <TValue> valueFunc)
        {
            if (mapper == null)
            {
                throw new ArgumentNullException(nameof(mapper));
            }
            if (keyPredicate == null)
            {
                throw new ArgumentNullException(nameof(keyPredicate));
            }
            if (valueFunc == null)
            {
                throw new ArgumentNullException(nameof(valueFunc));
            }

            KeyValues = new Dictionary <KeyPredicate <TKey>, ValueFunc <TValue> >(mapper.KeyValues);
            KeyValues.Add(keyPredicate, valueFunc);

            DefaultValue = mapper.DefaultValue;
        }
Beispiel #2
0
 private IMapper <TKey, TValue> CreateMapperWithDefaultValueFunc(ValueFunc <TValue> defaultValueFunc)
 {
     return(new Mapper <TKey, TValue>(this, defaultValueFunc));
 }
Beispiel #3
0
        public IMapper <TKey, TValue> Default(Func <TValue> defaultValueFactory)
        {
            var defaultValueFunc = new ValueFunc <TValue>(defaultValueFactory);

            return(CreateMapperWithDefaultValueFunc(defaultValueFunc));
        }
Beispiel #4
0
 internal Mapper(Mapper <TKey, TValue> mapper, ValueFunc <TValue> defaultValue)
 {
     KeyValues    = new Dictionary <KeyPredicate <TKey>, ValueFunc <TValue> >(mapper.KeyValues);
     DefaultValue = defaultValue;
 }