Example #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));
            }));
        }
Example #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);
        }
 public static SimpleClassDescription Create(TypeName fullName, Maybe<ITypeDescription> baseClass,
     Func<ITypeDescription, IEnumerable<SimpleFieldDescription>> fieldGenerator)
 {
     if (fullName.OrderOfArray != 0)
     {
         throw new ArgumentException("Cannot be an array-type " + fullName.FullName);
     }
     var toConstruct = new SimpleClassDescription(fullName, baseClass);
     toConstruct.fields = fieldGenerator(toConstruct).ToArray();
     return toConstruct;
 }
        public static SimpleClassDescription Create(TypeName fullName, Maybe <ITypeDescription> baseClass,
                                                    Func <ITypeDescription, IEnumerable <SimpleFieldDescription> > fieldGenerator)
        {
            if (fullName.OrderOfArray != 0)
            {
                throw new ArgumentException("Cannot be an array-type " + fullName.FullName);
            }
            var toConstruct = new SimpleClassDescription(fullName, baseClass);

            toConstruct.fields = fieldGenerator(toConstruct).ToArray();
            return(toConstruct);
        }