Exemplo n.º 1
0
        public void RunDbExample()
        {
            ILogger logger = container.Resolve <ILogger>();

            //load config
            IConfigLoader loader = container.Resolve <IConfigLoader>();
            IConfig       config = loader.GetConfig("C:\\\\setting.xml");

            config.ConnectionString = "This IS connectuion string.";
            logger.LogInfo($"{config.ConnectionString.ToString()}");

            //get PC for both DB
            IDbConnector connectorMsSql = container.Resolve <IMsSql>(new NamedParameter("connectionString", config.ConnectionString));

            connectorMsSql.CreateNewPc();
            IDbConnector connectorOracle = container.Resolve <IOracle>(new NamedParameter("connectionString", config.ConnectionString));

            connectorOracle.CreateNewPc();

            //create PC for one DB
            IDbConnector connectorDbRandom;

            if ((new Random()).Next(0, 2) == 0)
            {
                //parameter is used only when not specified in container
                connectorDbRandom = container.Resolve <IMsSql>(new NamedParameter("connectionString", config.ConnectionString));
            }
            else
            {
                connectorDbRandom = container.Resolve <IOracle>(new NamedParameter("connectionString", config.ConnectionString));
            }
            connectorDbRandom.ConnectToDb();
            connectorDbRandom.CreateNewPc();

            Console.ReadLine();
        }
Exemplo n.º 2
0
 private DeviceList GetConfig()
 {
     return(_configLoader.GetConfig());
 }