public static void Start(SchemaBuilder sb) { if (sb.NotDefined(MethodInfo.GetCurrentMethod())) { TypeLogic.AssertStarted(sb); AuthLogic.AssertStarted(sb); TypeConditionLogic.Start(sb); sb.Schema.EntityEventsGlobal.Saving += Schema_Saving; //because we need Modifications propagated sb.Schema.EntityEventsGlobal.Retrieved += EntityEventsGlobal_Retrieved; sb.Schema.IsAllowedCallback += Schema_IsAllowedCallback; sb.Schema.SchemaCompleted += () => { foreach (var type in TypeConditionLogic.Types) { miRegister.GetInvoker(type)(Schema.Current); } }; sb.Schema.Synchronizing += Schema_Synchronizing; sb.Schema.EntityEventsGlobal.PreUnsafeDelete += query => { return(TypeAuthLogic.OnIsDelete(query.ElementType)); }; cache = new TypeAuthCache(sb, merger: TypeAllowedMerger.Instance); AuthLogic.ExportToXml += exportAll => cache.ExportXml(exportAll ? TypeLogic.TypeToEntity.Keys.ToList() : null); AuthLogic.ImportFromXml += (x, roles, replacements) => cache.ImportXml(x, roles, replacements); TypeConditionLogic.Register(UserCondition.DeactivatedUsers, (UserEntity u) => u.State == UserState.Deactivated); } }