コード例 #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
ファイル: Config.cs プロジェクト: Fubineva/NOps.Common
        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
ファイル: BaraMapper.cs プロジェクト: llorch19/Bara
 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
ファイル: BaraMapper.cs プロジェクト: llorch19/Bara
 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
ファイル: MapsModule.cs プロジェクト: sbrydon/Norbert
        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
ファイル: SmartSqlMapper.cs プロジェクト: yinguopeng/SmartSql
        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
ファイル: SmartSqlMaper.cs プロジェクト: codecopy/SmartSql
 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
ファイル: SmartSqlMaper.cs プロジェクト: codecopy/SmartSql
 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
ファイル: ChatLogModule.cs プロジェクト: sbrydon/Norbert
        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
ファイル: SqlBuilder_Test.cs プロジェクト: tomtangrx/SmartSql
        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());
 }