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)); } }
public static void Start(SchemaBuilder sb, DynamicQueryManager dqm) { 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(dqm, () => t => new { Entity = t, t.Id, t.TableName, t.CleanName, t.ClassName, t.Namespace, }); TypeEntity.SetTypeDNCallbacks( t => TypeToEntity.GetOrThrow(t), t => EntityToType.GetOrThrow(t)); } }