Пример #1
0
        public SmartSqlContext_Test()
        {
            _configLoader = new LocalFileConfigLoader("SmartSqlMapConfig.xml", LoggerFactory);
            var config = _configLoader.Load();

            _smartSqlContext = new SmartSqlContext(LoggerFactory.CreateLogger <SmartSqlContext>(), _configLoader.Load());
        }
Пример #2
0
        public static T Load <T>(string filePathName) where T : Config
        {
            var config = s_cfgLoader.Load <T>(filePathName);

            config.FilePathName = filePathName;
            return(config);
        }
Пример #3
0
 public DirectoryChecker(IConfigLoader configLoader)
 {
     if (configLoader == null)
     {
         throw new ArgumentNullException(nameof(configLoader));
     }
     _config = configLoader.Load();
 }
Пример #4
0
 public ServiceLauncher(IService service, IConfigLoader configLoader)
 {
     _service = service ?? throw new ArgumentNullException(nameof(service));
     if (configLoader == null)
     {
         throw new ArgumentNullException(nameof(configLoader));
     }
     _config = configLoader.Load();
 }
Пример #5
0
 public MyDebugLogger(IConfigLoader loader)
 {
     _syncObject = new object();
     if (loader == null)
     {
         throw new ArgumentNullException(nameof(loader));
     }
     _config = loader.Load();
 }
Пример #6
0
 public SnakesAndLadders(ILevel level, IDice dice,
                         IConfigLoader configLoader, IOptions <SnakesAndLaddersConfig> config)
 {
     _level        = level;
     _dice         = dice;
     _configLoader = configLoader;
     _config       = config;
     _level.Initialize(_configLoader.Load(_config.Value.ConfigFileName));
     players = new ConcurrentDictionary <string, Player>();
 }
Пример #7
0
 public static Configuration GetManager(IConfigLoader loader)
 {
     lock (typeof(ConfigurationManager))
     {
         Configuration result = new Configuration();
         result.Name         = loader.Name;
         result.ConfigLoader = loader;
         result.LoadConfig(loader.Load());
         return(result);
     }
 }
Пример #8
0
        public List <ConfigObject> Extract(string configFilePath)
        {
            var debinarizedConfig = _configLoader.Load(configFilePath);

            _tokenizer.Initialize(debinarizedConfig);
            var tokenizedConfig = _tokenizer.Tokenize().ToList();

            var result = _converter.Convert(tokenizedConfig);

            return(result);
        }
Пример #9
0
 public BaraMapper(String baraMapConfigFilePath, IConfigLoader configLoader)
 {
     ConfigLoader = configLoader;
     ConfigLoader.Load(baraMapConfigFilePath, this);
     DbProviderFactory = BaraMapConfig.DataBase.DbProvider.DbProviderFactory;
     SessionStore      = new DbConnectionSessionStore(this.GetHashCode().ToString());
     SqlBuilder        = new SqlBuilder(this);
     DataSourceManager = new DataSourceManager(this);
     CacheManager      = new CacheManager(this);
     SqlExecutor       = new SqlExecutor(SqlBuilder, this);
 }
Пример #10
0
 public SmartSqlMapper(String sqlMapConfigFilePath, IConfigLoader configLoader)
 {
     ConfigLoader = configLoader;
     ConfigLoader.Load(sqlMapConfigFilePath, this);
     DbProviderFactory = SqlMapConfig.Database.DbProvider.DbProviderFactory;
     SessionStore      = new DbConnectionSessionStore(this.GetHashCode().ToString());
     SqlBuilder        = new SqlBuilder(this);
     DataSourceManager = new DataSourceManager(this);
     CacheManager      = new CacheManager(this);
     _sqlRuner         = new SqlRuner(SqlBuilder, this);
 }
Пример #11
0
 public FileProcessor(IConfigLoader loader, IFileReader fileReader, ILogger logger)
 {
     if (loader == null)
     {
         throw new ArgumentNullException(nameof(loader));
     }
     _config     = loader.Load();
     _delay      = _config.DelayForAnotherAttempt;
     _attempts   = _config.AttempsToAccessFilesystem;
     _fileReader = fileReader ?? throw new ArgumentNullException(nameof(fileReader));
     _logger     = logger ?? throw new ArgumentNullException(nameof(logger));
 }
Пример #12
0
 public BaraMapper(ILoggerFactory loggerFactory, String baraMapConfigFilePath, IConfigLoader configLoader)
 {
     _loggerFactory = loggerFactory;
     _logger        = _loggerFactory.CreateLogger <BaraMapper>();
     ConfigLoader   = configLoader;
     ConfigLoader.Load(baraMapConfigFilePath, this);
     DbProviderFactory = BaraMapConfig.DataBase.DbProvider.DbProviderFactory;
     SessionStore      = new DbConnectionSessionStore(loggerFactory, this.GetHashCode().ToString());
     SqlBuilder        = new SqlBuilder(loggerFactory, this);
     DataSourceManager = new DataSourceManager(loggerFactory, this);
     CacheManager      = new CacheManager(loggerFactory, this);
     SqlExecutor       = new SqlExecutor(loggerFactory, SqlBuilder, this);
 }
Пример #13
0
    object LoadRes(string path, Type t)
    {
        object re = null;

        if (path.EndsWith(TYPE_XML))
        {
            string content = m_assets.Load(path).ToString();
            using (StringReader sr = new StringReader(content))
            {
                XmlSerializer xmldes = new XmlSerializer(t);
                re = xmldes.Deserialize(sr);
            }
        }
        else if (path.EndsWith(TYPE_JSON))
        {
            string content = m_assets.Load(path).ToString();
            re = Newtonsoft.Json.JsonConvert.DeserializeObject(content, t);
        }
        else if (path.EndsWith(TYPE_UNITY))
        {
            object asset = m_assets.Load(path);
            re = UnityEngine.Object.Instantiate((UnityEngine.Object)asset);
        }
        else
        {
            re = Activator.CreateInstance(t);
        }

        MethodInfo mi = t.GetMethod("Init", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public);

        if (mi != null)
        {
            mi.Invoke(re, null);
        }

        return(re);
    }
Пример #14
0
        private static Config LoadConfig(IConfigLoader configLoader)
        {
            var config = configLoader.Load<Config>("Maps/Config.json") ?? new Config();

            if (string.IsNullOrWhiteSpace(config.ApiKey))
            {
                Log.Warn("No 'apikey' defined in Config.json");
            }
            else
            {
                Log.Info("Found 'apikey' in Config.json");
            }

            return config;
        }
Пример #15
0
        public SmartSqlMapper(ILoggerFactory loggerFactory, String sqlMapConfigFilePath, IConfigLoader configLoader)
        {
            _loggerFactory    = loggerFactory;
            _logger           = loggerFactory.CreateLogger <SmartSqlMapper>();
            ConfigLoader      = configLoader;
            SqlMapConfig      = ConfigLoader.Load();
            DbProviderFactory = SqlMapConfig.Database.DbProvider.DbProviderFactory;
            SessionStore      = new DbConnectionSessionStore(loggerFactory, this.GetHashCode().ToString());
            SqlBuilder        = new SqlBuilder(loggerFactory, this);
            DataSourceManager = new DataSourceManager(loggerFactory, this);
            CacheManager      = new CacheManager(loggerFactory, this);
            _sqlRuner         = new SqlRuner(loggerFactory, SqlBuilder, this);

            ConfigLoader.OnChanged = SqlConfigOnChanged;
            SqlMapConfig.SetLogger(_loggerFactory.CreateLogger <SmartSqlMapConfig>());
        }
Пример #16
0
 public SmartSqlMapper(
     ILoggerFactory loggerFactory,
     String sqlMapConfigFilePath = "SmartSqlMapConfig.xml"
     )
 {
     _loggerFactory = loggerFactory;
     _logger        = loggerFactory.CreateLogger <SmartSqlMapper>();
     ConfigLoader   = new LocalFileConfigLoader(loggerFactory);
     ConfigLoader.Load(sqlMapConfigFilePath, this);
     DbProviderFactory = SqlMapConfig.Database.DbProvider.DbProviderFactory;
     SessionStore      = new DbConnectionSessionStore(loggerFactory, this.GetHashCode().ToString());
     SqlBuilder        = new SqlBuilder(loggerFactory, this);
     DataSourceManager = new DataSourceManager(loggerFactory, this);
     CacheManager      = new CacheManager(loggerFactory, this);
     _sqlRuner         = new SqlRuner(loggerFactory, SqlBuilder, this);
 }
Пример #17
0
 public SmartSqlMapper(
     String sqlMapConfigFilePath
     , IDbConnectionSessionStore sessionStore
     , IDataSourceManager dataSourceManager
     , ICacheManager cacheManager
     , ISqlBuilder sqlBuilder
     , IConfigLoader configLoader
     )
 {
     configLoader.Load(sqlMapConfigFilePath, this);
     DbProviderFactory = SqlMapConfig.Database.DbProvider.DbProviderFactory;
     SessionStore      = sessionStore;
     SqlBuilder        = sqlBuilder;
     DataSourceManager = dataSourceManager;
     CacheManager      = cacheManager;
     _sqlRuner         = new SqlRuner(SqlBuilder, this);
 }
Пример #18
0
        public FolderMonitor(IConfigLoader loader, IFileProcessor fileProcessor, IReceiptSender receiptSender, ILogger logger, IDirectoryChecker directoryChecker)
        {
            try
            {
                directoryChecker?.CheckDirectories();
            }
            catch (Exception ex)
            {
                _logger.Log($"{ex.GetType()}:\n{ex.Message}");
                Console.WriteLine($"{ex.GetType()}:\n{ex.Message}");
                throw ex;
            }
            _fileProcessor    = fileProcessor ?? throw new ArgumentNullException(nameof(fileProcessor));
            _config           = loader.Load();
            _watcher          = new FileSystemWatcher(_config.InputFolder);
            _watcher.Created += OnCreatedFile;
            _receiptSender    = receiptSender ?? throw new ArgumentNullException(nameof(receiptSender));
            _logger           = logger ?? throw new ArgumentNullException(nameof(logger));

            //System.IO.Directory.SetCurrentDirectory(System.AppDomain.CurrentDomain.BaseDirectory);
        }
Пример #19
0
 public SmartSqlMapper(
     ILoggerFactory loggerFactory,
     String sqlMapConfigFilePath
     , IDbConnectionSessionStore sessionStore
     , IDataSourceManager dataSourceManager
     , ICacheManager cacheManager
     , ISqlBuilder sqlBuilder
     , IConfigLoader configLoader
     )
 {
     _loggerFactory = loggerFactory;
     _logger        = loggerFactory.CreateLogger <SmartSqlMapper>();
     configLoader.Load(sqlMapConfigFilePath, this);
     DbProviderFactory           = SqlMapConfig.Database.DbProvider.DbProviderFactory;
     SessionStore                = sessionStore;
     SqlBuilder                  = sqlBuilder;
     DataSourceManager           = dataSourceManager;
     CacheManager                = cacheManager;
     CacheManager.SmartSqlMapper = this;
     _sqlRuner = new SqlRuner(loggerFactory, SqlBuilder, this);
 }
Пример #20
0
        private static Config LoadConfig(IConfigLoader configLoader, IFileSystem fileSystem)
        {
            var config = configLoader.Load<Config>("ChatLog/Config.json") ?? new Config();

            if (string.IsNullOrWhiteSpace(config.Path))
            {
                config.Path = "ChatLogs";
                Log.Info("No path specified, using 'ChatLogs'");
            }
            else
            {
                config.Path = config.Path;
            }

            try
            {
                if (fileSystem.DirectoryExists(config.Path))
                {
                    Log.Info("Path exists, skipping creation");
                }
                else
                {
                    Log.Info("Path does not exist, creating it..");
                    fileSystem.CreateDirectory(config.Path);
                }

                Log.Info($"Path is '{config.Path}'");
            }
            catch (Exception e)
            {
                Log.Error($"Error creating '{config.Path}': {e.Message}");
                Log.Error("Path not set");
            }

            return config;
        }
Пример #21
0
        public SqlBuilder_Test()
        {
            _configLoader = new LocalFileConfigLoader(SqlMapConfigFilePath, LoggerFactory);
            var smartSqlContext = new SmartSqlContext(LoggerFactory.CreateLogger <SmartSqlContext>(), _configLoader.Load());

            _sqlBuilder = new SqlBuilder(LoggerFactory.CreateLogger <SqlBuilder>(), smartSqlContext);
        }
Пример #22
0
        public void Load()
        {
            var config = _configLoader.Load();

            Assert.NotNull(config);
        }
Пример #23
0
 public static string LoadConfigData(IConfigLoader loader)
 {
     return(loader.Load());
 }