Esempio n. 1
0
        private DictionarySourceMember(
            Type dictionaryType,
            IQualifiedMember wrappedSourceMember,
            QualifiedMember matchedTargetMember,
            bool isEntireDictionaryMatch,
            Type keyType   = null,
            Type valueType = null)
        {
            _wrappedSourceMember    = wrappedSourceMember;
            _matchedTargetMember    = matchedTargetMember;
            IsEntireDictionaryMatch = isEntireDictionaryMatch;

            Type = dictionaryType;

            if (keyType == null)
            {
                var dictionaryTypes = Type.GetDictionaryTypes();
                KeyType   = dictionaryTypes.Key;
                ValueType = dictionaryTypes.Value;
            }
            else
            {
                KeyType   = keyType;
                ValueType = valueType;
            }

            EntryMember = (wrappedSourceMember as DictionaryEntrySourceMember) ??
                          new DictionaryEntrySourceMember(ValueType, matchedTargetMember, this);

            HasObjectEntries = ValueType == typeof(object);

            CouldContainSourceInstance =
                HasObjectEntries || (matchedTargetMember.IsEnumerable == ValueType.IsEnumerable());
        }