Exemple #1
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.SetTypeEntityCallbacks(
                    t => Server.ServerTypes.GetOrThrow(t),
                    tdn => Server.GetType(tdn.CleanName));
            }
        }
Exemple #2
0
        public static void Start(SchemaBuilder sb)
        {
            if (sb.NotDefined(MethodInfo.GetCurrentMethod()))
            {
                Schema current = Schema.Current;

                current.SchemaCompleted += () =>
                {
                    var attributes = current.Tables.Keys.Select(t => KVP.Create(t, t.GetCustomAttribute <EntityKindAttribute>(true))).ToList();

                    var errors = attributes.Where(a => a.Value == null).ToString(a => "Type {0} does not have an EntityTypeAttribute".FormatWith(a.Key.Name), "\r\n");

                    if (errors.HasText())
                    {
                        throw new InvalidOperationException(errors);
                    }
                };

                current.Initializing += () =>
                {
                    current.typeCachesLazy.Load();
                };

                current.typeCachesLazy = sb.GlobalLazy(() => new TypeCaches(current),
                                                       new InvalidateWith(typeof(TypeEntity)),
                                                       Schema.Current.InvalidateMetadata);

                sb.Include <TypeEntity>()
                .WithQuery(() => t => new
                {
                    Entity = t,
                    t.Id,
                    t.TableName,
                    t.CleanName,
                    t.ClassName,
                    t.Namespace,
                });

                TypeEntity.SetTypeEntityCallbacks(
                    t => TypeToEntity.GetOrThrow(t),
                    t => EntityToType.GetOrThrow(t));
            }
        }