Ejemplo n.º 1
0
        public DependencyInjectionConfig()
        {
            Logging.Configure(Serilog.Events.LogEventLevel.Information);
            DirectoryHelper.EnsureCreated();
            ResourceController.Load();
            GameInformationFactory.Create();

            var serviceCollection = new ServiceCollection();

            ConfigureServices(serviceCollection);

            ServiceProvider = serviceCollection.BuildServiceProvider();
            RegisterTools(ServiceProvider.GetService <ToolFactory>());
        }
Ejemplo n.º 2
0
        void Load(GameTypeEnum game)
        {
            if (_gameTableDefinitions.ContainsKey(game))
            {
                return;
            }

            string path = DirectoryHelper.SchemaDirectory + "\\" + GameInformationFactory.GetGameById(game).ShortID + "_schema.json";   // Try local copy first

            if (!File.Exists(path))
            {
                path = "Resources\\Schemas\\" + GameInformationFactory.GetGameById(game).ShortID + "_schema.json";
            }

            var content = LoadSchemaFile(path);

            if (content != null)
            {
                _gameTableDefinitions.Add(game, content);
            }

            path = DirectoryHelper.SchemaDirectory + "\\" + GameInformationFactory.GetGameById(game).ShortID + "_AnimMetaDataSchema.json"; // Try local copy first
            if (!File.Exists(path))
            {
                var allResource = GetResourceNames();

                var resourceFileName = GameInformationFactory.GetGameById(game).ShortID + "_AnimMetaDataSchema.json";
                var entry            = allResource.FirstOrDefault(x => x.Key.ToString().Contains(resourceFileName, StringComparison.InvariantCultureIgnoreCase));
                if (entry.Key != null)
                {
                    using var resourceReader = new StreamReader(entry.Value as Stream);
                    var resourceContent = resourceReader.ReadToEnd();
                    content = LoadSchemaFileFromContent(resourceContent);
                }
            }
            else
            {
                content = LoadSchemaFile(path);
            }
            if (content != null)
            {
                _gameAnimMetaDefinitions.Add(game, content);
            }
        }
Ejemplo n.º 3
0
 public bool SaveDbSchema()
 {
     _logger.Information("Trying to save file");
     try
     {
         if (!_gameTableDefinitions.ContainsKey(CurrentGame))
         {
             return(false);
         }
         string path    = DirectoryHelper.SchemaDirectory + "\\" + GameInformationFactory.GetGameById(CurrentGame).ShortID + "_schema.json";
         var    content = JsonConvert.SerializeObject(_gameTableDefinitions[CurrentGame], Formatting.Indented);
         File.WriteAllText(path, content);
         return(true);
     }
     catch (Exception e)
     {
         _logger.Fatal(e.Message);
         throw e;
     }
 }
Ejemplo n.º 4
0
        public bool SaveMetaDataSchema()
        {
            _logger.Information("Trying to metadat schema");
            try
            {
                if (!_gameAnimMetaDefinitions.ContainsKey(CurrentGame))
                {
                    return(false);
                }
                string path    = DirectoryHelper.SchemaDirectory + "\\" + GameInformationFactory.GetGameById(CurrentGame).ShortID + "_AnimMetaDataSchema.json";
                var    content = JsonConvert.SerializeObject(_gameAnimMetaDefinitions[CurrentGame], Formatting.Indented);
                File.WriteAllText(path, content);

                MessageBox.Show("Be kind and send the updated scehema to the developers so it can be shared");

                return(true);
            }
            catch (Exception e)
            {
                _logger.Fatal(e.Message);
                throw e;
            }
        }