Esempio n. 1
0
        private ITypeDescription CreateType(TypeName name,
                                            IReflectClass classInfo,
                                            Func <TypeName, Maybe <IReflectClass> > classLookup,
                                            IDictionary <string, ITypeDescription> knownTypes)
        {
            var knownType = typeResolver(name)
                            .Otherwise(() => typeResolver(name.GetGenericTypeDefinition()));

            if (knownType.HasValue)
            {
                var systemType = KnownType.Create(knownType.Value,
                                                  name.GenericArguments.Select(
                                                      t => GetOrCreateTypeByName(t.Value, classLookup, knownTypes)).
                                                  ToList(), IndexLookUp);
                knownTypes[name.FullName] = systemType;
                return(systemType);
            }
            return(SimpleClassDescription.Create(name,
                                                 classInfo.GetSuperclass().AsMaybe().Convert(sc => GetOrCreateType(sc, classLookup,
                                                                                                                   knownTypes)),
                                                 t =>
            {
                knownTypes[name.FullName] = t;
                return ExtractFields(name, classInfo,
                                     typeName =>
                                     GetOrCreateType(typeName, classLookup,
                                                     knownTypes));
            }));
        }
Esempio n. 2
0
        /// <summary>
        /// For some types there is no type info available from db4o. Therefore we just create an empty class.
        /// </summary>
        private ITypeDescription MockTypeFor(TypeName typeName,
                                             IDictionary <string, ITypeDescription> knownTypes)
        {
            var type = SimpleClassDescription.Create(typeName, t => Enumerable.Empty <SimpleFieldDescription>());

            knownTypes[typeName.FullName] = type;
            return(type);
        }