public ReturnExpression(Mapper <TKey, TValue> mapper, Predicate <TKey> keyPredicate)
        {
            if (mapper == null)
            {
                throw new ArgumentNullException(nameof(mapper));
            }
            if (keyPredicate == null)
            {
                throw new ArgumentNullException(nameof(keyPredicate));
            }

            _mapper       = mapper;
            _keyPredicate = new KeyPredicate <TKey>(keyPredicate);
        }
Exemple #2
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;
        }
        internal ReturnExpression(Mapper <TKey, TValue> mapper, params TKey[] keys)
        {
            if (mapper == null)
            {
                throw new ArgumentNullException(nameof(mapper));
            }
            if (keys == null)
            {
                throw new ArgumentNullException(nameof(keys));
            }
            if (!keys.Any())
            {
                throw new ArgumentException("No key was passed.", nameof(keys));
            }

            _mapper = mapper;

            CheckKeyDuplications(_mapper, keys);

            _keyPredicate = new KeyPredicate <TKey>(keys);
        }