protected static Dictionary <string, Type> InitializeModelMappings([CanBeNull] Type[] potentialEntityReaderTypes)
        {
            int len = (potentialEntityReaderTypes == null) ? 0 : potentialEntityReaderTypes.Length;

            var typeReaderDictionary = new Dictionary <string, Type>(len);

            if (potentialEntityReaderTypes == null)
            {
                return(typeReaderDictionary);
            }

            foreach (Type entityReaderType in potentialEntityReaderTypes)
            {
                if (entityReaderType.IsValueType || (entityReaderType.IsAbstract))
                {
                    continue;
                }

                string typeToMapModelOn = ModelMappingAttribute.GetTypeToMapOn(entityReaderType);

                if (string.IsNullOrEmpty(typeToMapModelOn))
                {
                    continue;
                }

                if (typeof(IClrObjMappingModel).IsAssignableFrom(entityReaderType))
                {
                    typeReaderDictionary[typeToMapModelOn] = entityReaderType;
                }
            }

            return(typeReaderDictionary);
        }
        public PriorityFallbackMatchTypeProvider AddOrUpdate([NotNull] Type entityModelCandidate)
        {
            Assert.ArgumentNotNull(entityModelCandidate, "entityModelCandidate");
            if (!CandidateTypeIsValid(entityModelCandidate))
            {
                throw new ArgumentException(
                          "{0} type is not valid as likely not implementing {1}".FormatWith(entityModelCandidate.Name,
                                                                                            typeof(IClrObjMappingModel).Name));
            }
            string typeName;

            if (ModelMappingAttribute.TryGetTypeToMapOn(entityModelCandidate, out typeName))
            {
                Priority[typeName] = entityModelCandidate;
            }
            else
            {
                throw new ArgumentException(
                          "Could not read {0} attribute from {1} type.".FormatWith(typeof(ModelMappingAttribute).Name,
                                                                                   entityModelCandidate.Name));
            }

            return(this);
        }
        public static IEnumerable <TMappingType> ExtractFromHeap <TMappingType>(this IModelMapperFactory factory, IMemoryDumpConnectionPath connectionDetails) where TMappingType : IClrObjMappingModel
        {
            var typeName = ModelMappingAttribute.GetTypeToMapOn(typeof(TMappingType), assert: true);

            return(ExtractFromHeapByType(factory, typeName, connectionDetails).OfType <TMappingType>());
        }