예제 #1
0
        static void Main(string[] args)
        {
            var engine = new SterlingEngine();
            var logger = new SterlingDefaultLogger(SterlingLogLevel.Information);

            engine.Activate();
            var db = engine.SterlingDatabase.RegisterDatabase <CoolDatabase>(new MemoryDriver());

            db.RegisterTrigger(new GuidTrigger <CoolColor>());
            CoolDatabase.PopulateDatabase(db);
            var colorList = db.Query <CoolColor, Guid>().OrderBy(c => c.LazyValue.Value.Name).Select(c => c.LazyValue.Value).ToList();

            foreach (var color in colorList)
            {
                Console.WriteLine($"Loaded color {color.Name} with database-generated key {color.Id}.");
            }
            var idx = (new Random().Next(0, colorList.Count - 1));

            Console.WriteLine($"Picked random color {colorList[idx].Name}");
            var combos    = db.Query <Combo, int>().Where(c => c.LazyValue.Value.Color.Id == colorList[idx].Id).Select(c => c.LazyValue.Value);
            var comboList = combos.Select(c => $"{c.Color.Name} {c.Planet.Name} {c.Cat.Name}");

            foreach (var combo in comboList.OrderBy(c => c))
            {
                Console.WriteLine($"Found awesome combo {combo}.");
            }
        }
        /// <summary>
        /// Activate the database instance
        /// </summary>
        public void Activate()
        {
            if (DesignerProperties.IsInDesignTool)
            {
                return;
            }

            if (Debugger.IsAttached)
            {
                this.sterlingDefaultLogger = new SterlingDefaultLogger(SterlingLogLevel.Verbose);
            }

            this.sterlingEngine = new SterlingEngine();

            // custom serializer for types
            this.sterlingEngine.SterlingDatabase.RegisterSerializer<TypeSerializer>();

            // change this for more verbose messages
            this.sterlingDefaultLogger = new SterlingDefaultLogger(SterlingLogLevel.Information);

            this.sterlingEngine.Activate();

            this.Database = this.sterlingEngine.SterlingDatabase.RegisterDatabase<VBForumsMetroDatabase>(new IsolatedStorageDriver());

            // see if we need to load it
            VBForumsMetroDatabase.CheckAndCreate(this.Database);
        }
        /// <summary>
        /// Activate the database instance
        /// </summary>
        public void Activate()
        {
            if (DesignerProperties.IsInDesignTool)
            {
                return;
            }

            if (Debugger.IsAttached)
            {
                this.sterlingDefaultLogger = new SterlingDefaultLogger(SterlingLogLevel.Verbose);
            }

            this.sterlingEngine = new SterlingEngine();

            // custom serializer for types
            this.sterlingEngine.SterlingDatabase.RegisterSerializer <TypeSerializer>();

            // change this for more verbose messages
            this.sterlingDefaultLogger = new SterlingDefaultLogger(SterlingLogLevel.Information);

            this.sterlingEngine.Activate();

            this.Database = this.sterlingEngine.SterlingDatabase.RegisterDatabase <VBForumsMetroDatabase>(new IsolatedStorageDriver());

            // see if we need to load it
            VBForumsMetroDatabase.CheckAndCreate(this.Database);
        }
예제 #4
0
 /// <summary>
 /// Handles the application startup event.
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="e">The <see cref="System.Windows.StartupEventArgs"/> 
 /// instance containing the event data.</param>
 private static void HandleApplicationStartup(Object sender, StartupEventArgs e)
 {
     s_engine = new SterlingEngine();
     s_logger = new SterlingDefaultLogger(SterlingLogLevel.Information);
     s_engine.Activate();
     s_database = s_engine.SterlingDatabase.RegisterDatabase<AppDatabase>();
 }
예제 #5
0
 /// <summary>
 /// Handles the application startup event.
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="e">The <see cref="System.Windows.StartupEventArgs"/>
 /// instance containing the event data.</param>
 private static void HandleApplicationStartup(Object sender, StartupEventArgs e)
 {
     s_engine = new SterlingEngine();
     s_logger = new SterlingDefaultLogger(SterlingLogLevel.Information);
     s_engine.Activate();
     s_database = s_engine.SterlingDatabase.RegisterDatabase <AppDatabase>();
 }
예제 #6
0
        public void StartService(ApplicationServiceContext context)
        {
            _engine = new SterlingEngine();
            _logger = new SterlingDefaultLogger(SterlingLogLevel.Information);

            //Создаем локальную базу данных:
            LocalDataBase = new LocalDB();

            Current = this;
        }
예제 #7
0
        /// <summary>
        /// 服务启动
        /// </summary>
        public void Starting()
        {
            if (DesignerProperties.IsInDesignTool)
            {
                return;
            }
            if (Debugger.IsAttached)
            {
                sdlogger = new SterlingDefaultLogger(SterlingLogLevel.Verbose);
            }

            sengine.Activate();

            Database = sengine.SterlingDatabase.RegisterDatabase <SMTLacalDB>();
        }
예제 #8
0
        /// <summary>
        /// 服务启动
        /// </summary>
        public void Starting()
        {
            if (DesignerProperties.IsInDesignTool)
            {
                return;
            }
            if (Debugger.IsAttached)
            {
                sdlogger = new SterlingDefaultLogger(SterlingLogLevel.Verbose);
            }

            sengine.Activate();

            Database = sengine.SterlingDatabase.RegisterDatabase<SMTLacalDB>();
        }
        public void ActivateEngine()
        {
            _engine = new SterlingEngine();
            _engine.SterlingDatabase.RegisterSerializer<DefaultSerializer>();
            _logger = new SterlingDefaultLogger(SterlingLogLevel.Information);
            _engine.Activate();

            _database = _engine.SterlingDatabase.RegisterDatabase<CoachesDatabase>(new IsolatedStorageDriver());

            _database.RegisterTrigger(new IdentityTrigger<EventDto>(_database));
            _database.RegisterTrigger(new IdentityTrigger<PracticeDrillDto>(_database));
            _database.RegisterTrigger(new IdentityTrigger<TeamDto>(_database));
            _database.RegisterTrigger(new IdentityTrigger<LocationDto>(_database));
            _database.RegisterTrigger(new IdentityTrigger<PlayerDto>(_database));
            _database.RegisterTrigger(new IdentityTrigger<SportDto>(_database));
        }
예제 #10
0
        public void StartService()
        {
            _engine = new SterlingEngine();

            if (Debugger.IsAttached)
            {
                _logger = new SterlingDefaultLogger(SterlingLogLevel.Verbose);
            }

            _engine.Activate();
            Database = _engine.SterlingDatabase.RegisterDatabase<BizcardDatabase>(_driver);
            Database.RegisterTrigger(new IdentityTrigger<Contact>(Database));
            Database.RegisterTrigger(new IdentityTrigger<Group>(Database));

            Current = this;
        }
예제 #11
0
 static UsdaDatabase()
 {
     _logger = new SterlingDefaultLogger(SterlingLogLevel.Information);
     RestartEngine();
 }
예제 #12
0
        private void SetupTheDatabase()
        {
            // create the sterling engine
            _engine = new SterlingEngine();

            // create a logger for the sterling db
            _logger = new SterlingDefaultLogger(SterlingLogLevel.Verbose);

            // activate the sterling engine
            _engine.Activate();

            // Register your database with the sterling engine and specify its persistence in isolated storage
            Database = _engine.SterlingDatabase.RegisterDatabase<ItemsDatabaseInstance>(new IsolatedStorageDriver());
        }