public static void Start(SchemaBuilder sb, Func <IEnumerable <T> > getSemiSymbols) { if (sb.NotDefined(typeof(SemiSymbolLogic <T>).GetMethod("Start"))) { sb.Include <T>(); sb.Schema.Initializing += () => lazy.Load(); sb.Schema.Synchronizing += Schema_Synchronizing; sb.Schema.Generating += Schema_Generating; SemiSymbolLogic <T> .getSemiSymbols = getSemiSymbols; lazy = sb.GlobalLazy(() => { using (AvoidCache()) { var current = Database.RetrieveAll <T>().Where(a => a.Key.HasText()); var result = EnumerableExtensions.JoinRelaxed( current, getSemiSymbols(), c => c.Key, s => s.Key, (c, s) => { s.SetIdAndProps(c); return(s); }, "caching " + typeof(T).Name); SemiSymbol.SetFromDatabase <T>(current.ToDictionary(a => a.Key)); return(result.ToDictionary(a => a.Key)); } }, new InvalidateWith(typeof(T)), Schema.Current.InvalidateMetadata); sb.Schema.EntityEvents <T>().Retrieved += SymbolLogic_Retrieved; } }
public static void SetSemiSymbolIds <S>() where S : SemiSymbol { if (OfflineMode) { return; } SemiSymbol.SetSemiSymbolIdsAndNames <S>(Server.Return((IBaseServer s) => s.GetSemiSymbolIdsAndNames(typeof(S)))); }
public static void SetSemiSymbolIds <S>() where S : SemiSymbol { if (OfflineMode) { return; } SemiSymbol.SetFromDatabase <S>(Server.Return((IBaseServer s) => s.GetSemiSymbolFromDatabase(typeof(S))).ToDictionary(a => a.Key, a => (S)a.Value)); }
public virtual void SetIdAndProps(SemiSymbol other) { this.id = other.id; this.IsNew = false; this.toStr = this.Key; this.Name = other.Name; if (this.Modified != ModifiedState.Sealed) { this.Modified = ModifiedState.Sealed; } }
public static void Start(SchemaBuilder sb, Func <IEnumerable <T> > getSemiSymbols) { if (sb.NotDefined(typeof(SemiSymbolLogic <T>).GetMethod("Start"))) { sb.Include <T>(); sb.Schema.Initializing += () => lazy.Load(); sb.Schema.Synchronizing += Schema_Synchronizing; sb.Schema.Generating += Schema_Generating; SemiSymbolLogic <T> .getSemiSymbols = getSemiSymbols; lazy = sb.GlobalLazy(() => { using (AvoidCache()) { SemiSymbol.SetSemiSymbolIdsAndNames <T>(Database.RetrieveAll <T>().Where(a => a.Key.HasText()).ToDictionary(a => a.Key, a => Tuple.Create(a.Id, a.Name))); return(getSemiSymbols().ToDictionary(a => a.Key)); } }, new InvalidateWith(typeof(T))); sb.Schema.EntityEvents <T>().Retrieved += SymbolLogic_Retrieved; } }
public Dictionary <string, SemiSymbol> GetSemiSymbolFromDatabase(Type type) { return(Return(MethodInfo.GetCurrentMethod(), () => SemiSymbol.GetFromDatabase(type))); }
public Dictionary <string, (PrimaryKey id, string name)> GetSemiSymbolIdsAndNames(Type type) { return(Return(MethodInfo.GetCurrentMethod(), () => SemiSymbol.GetSemiSymbolIdsAndNames(type))); }