Esempio n. 1
0
        internal DbContext()
        {
            var config = new FileDbConfiguration()
                         .SetDirectory(Paths.Get().DataDirectory)
                         .DefineCollection <Game>("GameDatabase")
                         .SetPart(x => x.Property(y => y.Id))
                         .SetPart(x => x.File("definition.xml"))
                         .SetSerializer <GameSerializer>()
                         .Conf()
                         .DefineCollection <Set>("Sets")
                         .OverrideRoot(x => x.Directory("GameDatabase"))
                         .SetPart(x => x.Property(y => y.GameId))
                         .SetPart(x => x.Directory("Sets"))
                         .SetPart(x => x.Property(y => y.Id))
                         .SetPart(x => x.File("set.xml"))
                         .SetSerializer <SetSerializer>()
                         .Conf()
                         .DefineCollection <GameScript>("Scripts")
                         .SetSteril()
                         //.OverrideRoot(x => x.Directory("GameDatabase"))
                         //.SetPart(x => x.Property(y => y.GameId))
                         .Conf()
                         .DefineCollection <ProxyDefinition>("Proxies")
                         .SetSteril()
                         //.OverrideRoot(x => x.Directory("GameDatabase"))
                         //.SetPart(x => x.Property(y=>y.Key))
                         .Conf()
                         .SetCacheProvider <FullCacheProvider>();

            Db = new FileDb(config);
        }
Esempio n. 2
0
        public void SetFileDb()
        {
            var config = new FileDbConfiguration()
                         .SetDirectory(Path.Combine(Config.Instance.Paths.DataDirectory, "IdeDevDatabase"))
                         .SetExternalDb()
                         .DefineCollection <Game>("Game")
                         .OverrideRoot(x => x.Directory(""))
                         .SetPart(x => x.Property(y => y.Id))
                         .SetPart(x => x.File("definition.xml"))
                         .SetSerializer <GameSerializer>()
                         .Conf()
                         .DefineCollection <Set>("Sets")
                         .OverrideRoot(x => x.Directory(""))
                         .SetPart(x => x.Property(y => y.GameId))
                         .SetPart(x => x.Directory("Sets"))
                         .SetPart(x => x.Property(y => y.Id))
                         .SetPart(x => x.File("set.xml"))
                         .SetSerializer <SetSerializer>()
                         .Conf()
                         .DefineCollection <GameScript>("Scripts")
                         .OverrideRoot(x => x.Directory(""))
                         .SetSteril()
                         .Conf()
                         .DefineCollection <ProxyDefinition>("Proxies")
                         .OverrideRoot(x => x.Directory(""))
                         .SetSteril()
                         .Conf()
                         .SetCacheProvider <FullCacheProvider>();

            DbContext.SetContext(config);
        }
Esempio n. 3
0
        public void Test()
        {
            var config = new FileDbConfiguration();
            config
                .SetDirectory(Config.Instance.Paths.DataDirectory)
                .DefineCollection<Game>("GameDatabase")
                .SetPart(x => x.Property(y => y.Id))
                .SetPart(x => x.File("definition.xml"))
                .Conf()
                .DefineCollection<Set>("Sets")
                .OverrideRoot(x => x.Directory("GameDatabase"))
                .SetPart(x => x.Property(y => y.GameId))
                .SetPart(x => x.Directory("Sets"))
                .SetPart(x => x.Property(y => y.Id))
                .SetPart(x => x.File("set.xml"));

            Assert.AreEqual(2, config.Configurations.Count);
            var conf = config.Configurations[0];
            Assert.AreEqual(2, conf.Parts.Count());

            Assert.AreEqual("{Id}", conf.Parts.First().PartString);
            Assert.AreEqual("definition.xml", conf.Parts.Skip(1).Take(1).First().PartString);
            Assert.AreEqual("GameDatabase", conf.Root.PartString);
            foreach (var c in config.Configurations)
            {
                System.Console.WriteLine(c.Path);
                foreach (var d in new DirectoryInfo(c.Path).Split())
                {
                    Console.WriteLine(d);
                }
            }

            //config.Query<Game>().By(x => x.Id,Op.Eq, );
        }
Esempio n. 4
0
 internal DbContext()
 {
     var config = new FileDbConfiguration()
         .SetDirectory(Paths.Get().DataDirectory)
         .DefineCollection<Game>("GameDatabase")
         .SetPart(x => x.Property(y => y.Id))
         .SetPart(x => x.File("definition.xml"))
         .SetSerializer<GameSerializer>()
         .Conf()
         .DefineCollection<Set>("Sets")
         .OverrideRoot(x => x.Directory("GameDatabase"))
         .SetPart(x => x.Property(y => y.GameId))
         .SetPart(x => x.Directory("Sets"))
         .SetPart(x => x.Property(y => y.Id))
         .SetPart(x => x.File("set.xml"))
         .SetSerializer<SetSerializer>()
         .Conf()
         .DefineCollection<GameScript>("Scripts")
         .SetSteril()
         //.OverrideRoot(x => x.Directory("GameDatabase"))
         //.SetPart(x => x.Property(y => y.GameId))
         .Conf()
         .DefineCollection<ProxyDefinition>("Proxies")
         .SetSteril()
         //.OverrideRoot(x => x.Directory("GameDatabase"))
         //.SetPart(x => x.Property(y=>y.Key))
         .Conf()
         .SetCacheProvider<FullCacheProvider>();
     Db = new FileDb(config);
 }
Esempio n. 5
0
        public void LoadGame(string filename)
        {
            var s    = new Octgn.DataNew.GameSerializer();
            var conf = new FileDbConfiguration();

            conf.DefineCollection <Game>("Game");
            s.Def = new CollectionDefinition <Game>(conf, "GameDatabase");
            try
            {
                GamePath = new FileInfo(filename).Directory.FullName;
                Game     = (Game)s.Deserialize(filename);
            }
            catch (System.Exception e)
            {
                GamePath = "";
            }
        }
Esempio n. 6
0
        public void LoadGame(Guid guid)
        {
            NeedsSave     = false;
            DidManualSave = true;


            var g    = new Octgn.DataNew.GameSerializer();
            var conf = new FileDbConfiguration();

            conf.DefineCollection <Game>("Game");
            g.Def = new CollectionDefinition <Game>(conf, "GameDatabase");
            try
            {
                Game     = DbContext.Get().GameById(guid);
                GamePath = Game.InstallPath;
                Sets     = DbContext.Get().SetQuery.By(x => x.GameId, Op.Eq, Game.Id);
            }
            catch (System.Exception)
            {
                GamePath = "";
            }
        }
Esempio n. 7
0
        public void Test()
        {
            var config = new FileDbConfiguration();

            config
            .SetDirectory(Config.Instance.Paths.DataDirectory)
            .DefineCollection <Game>("GameDatabase")
            .SetPart(x => x.Property(y => y.Id))
            .SetPart(x => x.File("definition.xml"))
            .Conf()
            .DefineCollection <Set>("Sets")
            .OverrideRoot(x => x.Directory("GameDatabase"))
            .SetPart(x => x.Property(y => y.GameId))
            .SetPart(x => x.Directory("Sets"))
            .SetPart(x => x.Property(y => y.Id))
            .SetPart(x => x.File("set.xml"));

            Assert.AreEqual(2, config.Configurations.Count);
            var conf = config.Configurations[0];

            Assert.AreEqual(2, conf.Parts.Count());

            Assert.AreEqual("{Id}", conf.Parts.First().PartString);
            Assert.AreEqual("definition.xml", conf.Parts.Skip(1).Take(1).First().PartString);
            Assert.AreEqual("GameDatabase", conf.Root.PartString);
            foreach (var c in config.Configurations)
            {
                System.Console.WriteLine(c.Path);
                foreach (var d in new DirectoryInfo(c.Path).Split())
                {
                    Console.WriteLine(d);
                }
            }

            //config.Query<Game>().By(x => x.Id,Op.Eq, );
        }
Esempio n. 8
0
 public void LoadGame(string filename)
 {
     var s = new Octgn.DataNew.GameSerializer();
     var conf = new FileDbConfiguration();
     conf.DefineCollection<Game>("Game");
     s.Def = new CollectionDefinition<Game>(conf, "GameDatabase");
     try
     {
         GamePath = new FileInfo(filename).Directory.FullName;
         Game = (Game)s.Deserialize(filename);
     }
     catch (System.Exception e)
     {
         GamePath = "";
     }
 }
 public SatellitePassFileRepository(ILogger <SatellitePassFileRepository> logger, IOptions <FileDbConfiguration> dbConfig)
 {
     _dbConfig = dbConfig.Value;
     _logger   = logger;
 }
Esempio n. 10
0
 public static DbContext SetContext(FileDbConfiguration config)
 {
     return(Context = new DbContext(config));
 }
Esempio n. 11
0
 internal DbContext(FileDbConfiguration config)
 {
     Db = new FileDb(config);
 }
 public UpcomingPassFileRepository(ILogger <UpcomingPassFileRepository> logger, IOptions <FileDbConfiguration> dbConfig)
 {
     _dbConfig = dbConfig.Value;
     _logger   = logger;
 }
Esempio n. 13
0
 public static IDbContext SetContext(FileDbConfiguration config)
 {
     lock (Sync) {
         return(Context = new DbContext(config));
     }
 }