コード例 #1
0
        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;
            }
        }
コード例 #2
0
ファイル: Server.cs プロジェクト: sizzles/framework
        public static void SetSemiSymbolIds <S>() where S : SemiSymbol
        {
            if (OfflineMode)
            {
                return;
            }

            SemiSymbol.SetSemiSymbolIdsAndNames <S>(Server.Return((IBaseServer s) => s.GetSemiSymbolIdsAndNames(typeof(S))));
        }
コード例 #3
0
ファイル: Server.cs プロジェクト: jeason0813/framework-2
        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));
        }
コード例 #4
0
 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;
     }
 }
コード例 #5
0
        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;
            }
        }
コード例 #6
0
 public Dictionary <string, SemiSymbol> GetSemiSymbolFromDatabase(Type type)
 {
     return(Return(MethodInfo.GetCurrentMethod(),
                   () => SemiSymbol.GetFromDatabase(type)));
 }
コード例 #7
0
ファイル: ServerBasic.cs プロジェクト: soabel/framework
 public Dictionary <string, (PrimaryKey id, string name)> GetSemiSymbolIdsAndNames(Type type)
 {
     return(Return(MethodInfo.GetCurrentMethod(),
                   () => SemiSymbol.GetSemiSymbolIdsAndNames(type)));
 }