/// <summary>
 /// 
 /// </summary>
 /// <param name="connectString"></param>
 /// <param name="getStoredProcedure"></param>
 /// <param name="setStoredProcedure"></param>
 /// <param name="refreshStoredProcedure"></param>
 /// <param name="removeStoredProcedure"></param>
 public SqlConfigurationSystem(
             string connectString, 
             string getStoredProcedure, 
             string setStoredProcedure, 
             string refreshStoredProcedure,
             string removeStoredProcedure)
 {
     this.data = new SqlConfigurationData(connectString, getStoredProcedure, setStoredProcedure, refreshStoredProcedure, removeStoredProcedure);
 }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="data"></param>
        /// <param name="refresh"></param>
        public SqlConfigurationSourceImplementation(SqlConfigurationData data, bool refresh)
        {
            this.data = new SqlConfigurationData(data);

            this.refresh = refresh;

            this.watchedConfigSourceMapping = new Dictionary<string, ConfigurationSourceWatcher>();
            this.watchedSectionMapping = new Dictionary<string, ConfigurationSourceWatcher>();
        }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="connectionString"></param>
 /// <param name="getStoredProc"></param>
 /// <param name="saveStoredProc"></param>
 /// <param name="refreshStoredProc"></param>
 /// <param name="removeStoredProc"></param>
 public SqlConfigurationParameter(
             string connectionString, 
             string getStoredProc, 
             string saveStoredProc, 
             string refreshStoredProc, 
             string removeStoredProc)
 {
     this.data = new SqlConfigurationData(connectionString, getStoredProc, saveStoredProc, refreshStoredProc, removeStoredProc);
 }
Example #4
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="connectString"></param>
 /// <param name="getStoredProcedure"></param>
 /// <param name="setStoredProcedure"></param>
 /// <param name="refreshStoredProcedure"></param>
 /// <param name="removeStoredProcedure"></param>
 public SqlConfigurationSystem(
     string connectString,
     string getStoredProcedure,
     string setStoredProcedure,
     string refreshStoredProcedure,
     string removeStoredProcedure)
 {
     this.data = new SqlConfigurationData(connectString, getStoredProcedure, setStoredProcedure, refreshStoredProcedure, removeStoredProcedure);
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="connectionString"></param>
 /// <param name="getStoredProc"></param>
 /// <param name="saveStoredProc"></param>
 /// <param name="refreshStoredProc"></param>
 /// <param name="removeStoredProc"></param>
 public SqlConfigurationParameter(
     string connectionString,
     string getStoredProc,
     string saveStoredProc,
     string refreshStoredProc,
     string removeStoredProc)
 {
     this.data = new SqlConfigurationData(connectionString, getStoredProc, saveStoredProc, refreshStoredProc, removeStoredProc);
 }
        /// <summary>
        /// Retrieves a specified configuration section for the current application's configuration
        /// </summary>
        /// <param name="sectionName">The configuration section name.</param>
        /// <param name="data">The configuration data for this connection.</param>
        /// <returns>The specified System.Configuration.ConfigurationSection object, or null if the section does not exist.</returns>
        public static object GetSection(string sectionName, SqlConfigurationData data)
        {
            if (string.IsNullOrEmpty(sectionName))
            {
                return null;
            }
            SqlConfigurationManager.PrepareConfigSystem(data);
            return SqlConfigurationManager.configSystem.GetSection(sectionName);

        }
 public void Initialize()
 {
     string connectString1 = @"server=(local)\SQLExpress;database=Northwind;Integrated Security=true";
     string connectString2 = @"server=(local)\SQLExpress;database=Northwind;";
     string getSproc = @"EntLib_GetConfig";
     string setStoredProc = @"EntLib_SetConfig";
     string refreshStoredProc = @"UpdateSectionDate";
     string removeStoredProc = @"EntLib_RemoveSection";
     
     data1 = new SqlConfigurationData(connectString1, getSproc, setStoredProc, refreshStoredProc, removeStoredProc);
     data2 = new SqlConfigurationData(connectString2, getSproc, setStoredProc, refreshStoredProc, removeStoredProc);
 }
        ///// <summary>
        ///// 
        ///// </summary>
        ///// <param name="connectString"></param>
        ///// <param name="getStoredProc"></param>
        ///// <param name="setStoredProc"></param>
        ///// <param name="refreshStoredProc"></param>
        ///// <param name="removeStoredProc"></param>
        //[TargetConstructor]
        //public SqlConfigurationSource(
        //                [Value("ConnectionString")]string connectString,
        //                [Value("GetStoredProcedure")]string getStoredProc,
        //                [Value("SetStoredProcedure")]string setStoredProc,
        //                [Value("RefreshStoredProcedure")]string refreshStoredProc,
        //                [Value("RemoveStoredProcedure")]string removeStoredProc
        //                )
        //{
        //    if (string.IsNullOrEmpty(connectString)) throw new ArgumentException(Resources.ExceptionStringNullOrEmpty, "connectString");
        //    if (string.IsNullOrEmpty(getStoredProc)) throw new ArgumentException(Resources.ExceptionStringNullOrEmpty, "getStoredProc");
        //    if (string.IsNullOrEmpty(setStoredProc)) throw new ArgumentException(Resources.ExceptionStringNullOrEmpty, "setStoredProc");
        //    if (string.IsNullOrEmpty(refreshStoredProc)) throw new ArgumentException(Resources.ExceptionStringNullOrEmpty, "refreshStoredProc");
        //    if (string.IsNullOrEmpty(removeStoredProc)) throw new ArgumentException(Resources.ExceptionStringNullOrEmpty, "removeStoredProc");

        //    this.data = new SqlConfigurationData(connectString, getStoredProc, setStoredProc, refreshStoredProc, removeStoredProc);
        
        //    EnsureImplementation(data);
        //}

        /// <summary>
        /// 
        /// </summary>
        /// <param name="connectString"></param>
        /// <param name="getStoredProc"></param>
        /// <param name="setStoredProc"></param>
        /// <param name="refreshStoredProc"></param>
        /// <param name="removeStoredProc"></param>
        public SqlConfigurationSource(
                        string connectString,
                        string getStoredProc,
                        string setStoredProc,
                        string refreshStoredProc,
                        string removeStoredProc
                        )
        {
            if (string.IsNullOrEmpty(connectString)) throw new ArgumentException(Resources.ExceptionStringNullOrEmpty, "connectString");
            if (string.IsNullOrEmpty(getStoredProc)) throw new ArgumentException(Resources.ExceptionStringNullOrEmpty, "getStoredProc");
            if (string.IsNullOrEmpty(setStoredProc)) throw new ArgumentException(Resources.ExceptionStringNullOrEmpty, "setStoredProc");
            if (string.IsNullOrEmpty(refreshStoredProc)) throw new ArgumentException(Resources.ExceptionStringNullOrEmpty, "refreshStoredProc");
            if (string.IsNullOrEmpty(removeStoredProc)) throw new ArgumentException(Resources.ExceptionStringNullOrEmpty, "removeStoredProc");

            this.data = new SqlConfigurationData(connectString, getStoredProc, setStoredProc, refreshStoredProc, removeStoredProc);

            EnsureImplementation(data);
        }
		public void Setup()
		{
            string connectString = @"server=(local)\SQLExpress;database=Northwind;Integrated Security=true";
            string getStoredProc = @"EntLib_GetConfig";
            string setStoredProc = @"EntLib_SetConfig";
            string refreshStoredProc = @"UpdateSectionDate";
            string removeStoredProc = @"EntLib_RemoveSection";

            this.data = new SqlConfigurationData(connectString, getStoredProc, setStoredProc, refreshStoredProc, removeStoredProc);

		    SqlConfigurationSource.ResetImplementation(data, false);

            System.Configuration.Configuration rwConfiguration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
			DummySection rwSection;

			rwConfiguration.Sections.Remove(localSection);
            rwConfiguration.Sections.Add(localSection, rwSection = new DummySection());
			rwSection.Name = localSection;
			rwSection.Value = 10;
            SqlConfigurationSourceImplementation configSourceImpl = new SqlConfigurationSourceImplementation(this.data,  false);
            configSourceImpl.SaveSection(rwSection.Name,rwSection);

			rwConfiguration.Sections.Remove(externalSection);
            rwConfiguration.Sections.Add(externalSection, rwSection = new DummySection());
			rwSection.Name = externalSection;
			rwSection.Value = 20;
            configSourceImpl.SaveSection(rwSection.Name, rwSection);

			rwConfiguration.Sections.Remove(localSection2);
            rwConfiguration.Sections.Add(localSection2, rwSection = new DummySection());
			rwSection.Name = localSection2;
			rwSection.Value = 30;
            configSourceImpl.SaveSection(rwSection.Name, rwSection);
		    
			rwConfiguration.Save();

			SqlConfigurationManager.RefreshSection(localSection, this.data);
            SqlConfigurationManager.RefreshSection(localSection2, this.data);
            SqlConfigurationManager.RefreshSection(externalSection, this.data);

			ConfigurationChangeSqlWatcher.ResetDefaultPollDelay();

			updatedSectionsTally = new Dictionary<string, int>(0);
		}
 private static void EnsureImplementation(SqlConfigurationData data)
 {
     if (!implementationByConnectionString.ContainsKey(data.ConnectionString))
     {
         lock (lockObject)
         {
             SqlConfigurationSourceImplementation implementation = new SqlConfigurationSourceImplementation(data);
             implementationByConnectionString.Add(data.ConnectionString, implementation);
         }
     }
 }
 /// <summary>
 /// <exclude>For unit testing purposes.</exclude>
 /// </summary>
 /// <param name="data"></param>
 /// <returns></returns>
 public static SqlConfigurationSourceImplementation GetImplementation(SqlConfigurationData data)
 {
     EnsureImplementation(data);
     string connectString = data.ConnectionString;
     return (implementationByConnectionString.ContainsKey(connectString)) ? implementationByConnectionString[connectString] : null;
 }
        /// <summary>
		/// <exclude>For unit testing purposes.</exclude>
		/// </summary>
		public static void ResetImplementation(SqlConfigurationData data, bool refreshing)
		{
            SqlConfigurationSourceImplementation currentImplementation = null;
            implementationByConnectionString.TryGetValue(data.ConnectionString, out currentImplementation);
            implementationByConnectionString[data.ConnectionString] =
                new SqlConfigurationSourceImplementation(data.ConnectionString, data.GetStoredProcedure, data.SetStoredProcedure, data.RefreshStoredProcedure, data.RemoveStoredProcedure, refreshing);

            if (currentImplementation != null)
            {
                currentImplementation.Dispose();
            }
		}
        public void SharedConfigurationFilesCanHaveDifferentCasing()
        {
            SqlConfigurationSourceImplementation configSourceImpl1 = SqlConfigurationSource.GetImplementation(data1);

            SqlConfigurationData tempData = new SqlConfigurationData(
                                                    data1.ConnectionString.ToUpper(), 
                                                    data1.GetStoredProcedure.ToUpper(), 
                                                    data1.SetStoredProcedure.ToUpper(), 
                                                    data1.RefreshStoredProcedure.ToUpper(),
                                                    data1.RemoveStoredProcedure.ToUpper());
            SqlConfigurationSourceImplementation configSourceImpl2 = SqlConfigurationSource.GetImplementation(tempData);

            Assert.AreSame(configSourceImpl1, configSourceImpl2);
        }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="sectionName"></param>
 /// <param name="section"></param>
 /// <param name="data"></param>
 public static void SaveSection(string sectionName, SerializableConfigurationSection section, SqlConfigurationData data)
 {
     if (!string.IsNullOrEmpty(sectionName))
     {
         SqlConfigurationManager.PrepareConfigSystem(data);
         SqlConfigurationManager.configSystem.SaveSection(sectionName, section);
     }
 }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="data"></param>
 public SqlConfigurationSourceImplementation(SqlConfigurationData data)
     : this(data, true)
 {
 }
 private static void EnsureConfigurationSystem(SqlConfigurationData data)
 {
     lock (SqlConfigurationManager.initLock)
     {
         if (SqlConfigurationManager.initState >= SqlConfigurationManager.InitState.Usable)
         {
             return;
         }
         SqlConfigurationManager.initState = SqlConfigurationManager.InitState.Started;
         try
         {
             try
             {
                 SqlConfigurationManager.configSystem = new SqlConfigurationSystem(data);
                 SqlConfigurationManager.initState = SqlConfigurationManager.InitState.Usable;
             }
             catch (Exception exception1)
             {
                 throw new ConfigurationErrorsException(Properties.Resources.ExceptionConfigurationInitialization, exception1);
             }
         }
         catch
         {
             SqlConfigurationManager.initState = SqlConfigurationManager.InitState.Completed;
             throw;
         }
     }
 }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="sectionName"></param>
 /// <param name="data"></param>
 public static void RemoveSection(string sectionName, SqlConfigurationData data)
 {
     if (!string.IsNullOrEmpty(sectionName))
     {
         SqlConfigurationManager.PrepareConfigSystem(data);
         SqlConfigurationManager.configSystem.RemoveSection(sectionName);
     }
 }
Example #18
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="name"></param>
 /// <param name="data"></param>
 public SqlConfigurationData(string name, SqlConfigurationData data)
     : this(name, data.ConnectionString, data.GetStoredProcedure, data.SetStoredProcedure, data.RefreshStoredProcedure, data.RemoveStoredProcedure)
 {
 }
 private static void PrepareConfigSystem(SqlConfigurationData data)
 {
     if (SqlConfigurationManager.initState < SqlConfigurationManager.InitState.Usable)
     {
         SqlConfigurationManager.EnsureConfigurationSystem(data);
     }
 }
 /// <summary>
 /// 
 /// </summary>
 public SqlConfigurationSystem(SqlConfigurationData data)
 {
     this.data = new SqlConfigurationData(data);
 }
Example #21
0
 /// <summary>
 ///
 /// </summary>
 public SqlConfigurationSystem(SqlConfigurationData data)
 {
     this.data = new SqlConfigurationData(data);
 }
        public void TestInitialize()
        {
            string connectString = @"server=(local)\SQLExpress;database=Northwind;Integrated Security=true";
            string getStoredProc= @"EntLib_GetConfig";
            string setStoredProc= @"EntLib_SetConfig";
            string refreshStoredProc= @"UpdateSectionDate";
            string removeStoredProc = @"EntLib_RemoveSection";

            this.data = new SqlConfigurationData(connectString, getStoredProc, setStoredProc, refreshStoredProc, removeStoredProc);

            ClearConfigs();
        }
Example #23
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="name"></param>
 /// <param name="data"></param>
 public SqlConfigurationData(string name, SqlConfigurationData data)
     :  this(name, data.ConnectionString, data.GetStoredProcedure, data.SetStoredProcedure, data.RefreshStoredProcedure, data.RemoveStoredProcedure)
 {
 }