Пример #1
0
        public SchemaBuilder(bool isDefault)
        {
            schema = new Schema(new SchemaSettings());

            if (isDefault)
            {
                if (TypeEntity.AlreadySet)
                {
                    throw new InvalidOperationException("Only one default SchemaBuilder per application allowed");
                }

                TypeEntity.SetTypeNameCallbacks(
                    t => schema.TypeToName.GetOrThrow(t, "Type {0} not found in the schema"),
                    cleanName => schema.NameToType.TryGetC(cleanName));

                FromEnumMethodExpander.miQuery = ReflectionTools.GetMethodInfo(() => Database.Query <Entity>()).GetGenericMethodDefinition();
                Include <TypeEntity>()
                .WithUniqueIndex(t => new { t.Namespace, t.ClassName });
            }

            Settings.AssertNotIncluded = MixinDeclarations.AssertNotIncluded = t =>
            {
                if (schema.Tables.ContainsKey(t))
                {
                    throw new InvalidOperationException("{0} is already included in the Schema".FormatWith(t.TypeName()));
                }
            };
        }
Пример #2
0
        public NavigationManager(bool multithreaded)
        {
            this.multithreaded = multithreaded;
            EntitySettings     = new Dictionary <Type, EntitySettings>();

            if (!Server.OfflineMode)
            {
                TypeEntity.SetTypeNameCallbacks(
                    t => Server.ServerTypes.GetOrThrow(t).CleanName,
                    Server.TryGetType);

                TypeEntity.SetTypeDNCallbacks(
                    t => Server.ServerTypes.GetOrThrow(t),
                    tdn => Server.GetType(tdn.CleanName));
            }
        }
Пример #3
0
        public SchemaBuilder()
        {
            schema = new Schema(new SchemaSettings());

            TypeEntity.SetTypeNameCallbacks(
                t => schema.TypeToName.GetOrThrow(t, "Type {0} not found in the schema"),
                cleanName => schema.NameToType.TryGetC(cleanName));

            FromEnumMethodExpander.miQuery = ReflectionTools.GetMethodInfo(() => Database.Query <Entity>()).GetGenericMethodDefinition();
            Include <TypeEntity>();
            Settings.AssertNotIncluded = MixinDeclarations.AssertNotIncluded = t =>
            {
                if (schema.Tables.ContainsKey(t))
                {
                    throw new InvalidOperationException("{0} is already included in the Schema".FormatWith(t.TypeName()));
                }
            };
        }