示例#1
0
        static void Main(string[] args)
        {
            var configHelper = new IpSettingsFactory().GetSettingsHelper(null);
            var connString   = (ConnectionStringSettings)configHelper.GetSetting(IpArgument.GetConfigConnString("Connection"));
            var allowCors    = configHelper.GetSetting(IpArgument.GetConfigAppSetting("AllowCors"));

            Console.WriteLine(connString.ConnectionString);
            Console.WriteLine(allowCors);
            Console.ReadKey();
        }
        /// <summary>
        /// Gets the datalayer using the connection string from the config file
        /// </summary>
        /// <param name="connectionStringName">The connection string name</param>
        /// <param name="useDefault">If not provided, should it use the default provider name</param>
        /// <returns>An instantiated data layer of the provider type from the connection string</returns>
        public virtual IIpBaseDataLayer GetDataLayer(string connectionStringName, bool useDefault = false)
        {
            #region Validations
            var exceptions = IpValidationHelper.Validate(new List <IIpValidator> {
                new IpRequiredStringValidator(connectionStringName)
            });


            if (exceptions.Any())
            {
                throw new IpDataAccessException(string.Join(" | ", exceptions));
            }
            #endregion

            var configHelper = new IpSettingsFactory().GetSettingsHelper((IIpConfigurationSettingsHelper)null);
            var connString   = (ConnectionStringSettings)configHelper.GetSetting(IpArgument.GetConfigConnString(connectionStringName));

            return(GetDataLayerByProvider(connString.ConnectionString, connString.ProviderName, useDefault));
        }