/// <summary> ///- /// </summary> /// <param name="state"> /// Represent the call context of the SqlMap or DaoManager ConfigureAndWatch method call. /// </param> /// <param name="onWhatchedFileChange"></param> public ConfigWatcherHandler(TimerCallback onWhatchedFileChange, StateConfig state) { for (int index = 0; index < _filesToWatch.Count; index++) { FileInfo configFile = (FileInfo)_filesToWatch[index]; AttachWatcher(configFile); // Create the timer that will be used to deliver events. Set as disabled // callback : A TimerCallback delegate representing a method to be executed. // state : An object containing information to be used by the callback method, or a null reference // dueTime : The amount of time to delay before callback is invoked, in milliseconds. Specify Timeout.Infinite to prevent the timer from starting. Specify zero (0) to start the timer immediately // period : The time interval between invocations of callback, in milliseconds. Specify Timeout.Infinite to disable periodic signaling _timer = new Timer(onWhatchedFileChange, state, Timeout.Infinite, Timeout.Infinite); } }
/// <summary> ///- /// </summary> /// <param name="state"> /// Represent the call context of the SqlMap or DaoManager ConfigureAndWatch method call. /// </param> /// <param name="onWhatchedFileChange"></param> public ConfigWatcherHandler(TimerCallback onWhatchedFileChange, StateConfig state) { for(int index = 0; index < _filesToWatch.Count; index++) { FileInfo configFile = (FileInfo)_filesToWatch[index]; AttachWatcher(configFile); // Create the timer that will be used to deliver events. Set as disabled // callback : A TimerCallback delegate representing a method to be executed. // state : An object containing information to be used by the callback method, or a null reference // dueTime : The amount of time to delay before callback is invoked, in milliseconds. Specify Timeout.Infinite to prevent the timer from starting. Specify zero (0) to start the timer immediately // period : The time interval between invocations of callback, in milliseconds. Specify Timeout.Infinite to disable periodic signaling _timer = new Timer(onWhatchedFileChange, state, Timeout.Infinite, Timeout.Infinite); } }
/// <summary> /// Configure and monitor the configuration file for modifications /// and automatically reconfigure the ISqlMapper instance. /// </summary> /// <param name="resource"> /// A FileInfo to a SqlMap.config file. /// </param> ///<param name="configureDelegate"> /// Delegate called when the file has changed. /// </param> /// <returns>An ISqlMapper instance.</returns> public ISqlMapper ConfigureAndWatch( FileInfo resource, ConfigureHandler configureDelegate ) { XmlDocument document = Resources.GetFileInfoAsXmlDocument(resource); ConfigWatcherHandler.ClearFilesMonitored(); ConfigWatcherHandler.AddFileToWatch( resource ); TimerCallback callBakDelegate = new TimerCallback( OnConfigFileChange ); StateConfig state = new StateConfig(); state.FileName = resource.FullName; state.ConfigureHandler = configureDelegate; ISqlMapper sqlMapper = Build( document, true ); new ConfigWatcherHandler(callBakDelegate, state); return sqlMapper; }
/// <summary> /// Configure and monitor the configuration file for modifications /// and automatically reconfigure the ISqlMapper instance. /// </summary> /// <param name="resource"> /// A relative ressource path from your Application root /// or an absolue file path file:\\c:\dir\a.config /// </param> ///<param name="configureDelegate"> /// Delegate called when the file has changed. /// </param> /// <returns>An ISqlMapper instance.</returns> public ISqlMapper ConfigureAndWatch( string resource, ConfigureHandler configureDelegate ) { XmlDocument document = null; if (resource.StartsWith("file://")) { document = Resources.GetUrlAsXmlDocument( resource.Remove(0, 7) ); } else { document = Resources.GetResourceAsXmlDocument( resource ); } ConfigWatcherHandler.ClearFilesMonitored(); ConfigWatcherHandler.AddFileToWatch( Resources.GetFileInfo( resource ) ); TimerCallback callBakDelegate = new TimerCallback( OnConfigFileChange ); StateConfig state = new StateConfig(); state.FileName = resource; state.ConfigureHandler = configureDelegate; ISqlMapper sqlMapper = Build( document, true ); new ConfigWatcherHandler( callBakDelegate, state ); return sqlMapper; }
public static void ConfigureAndWatch(string resource, ConfigureHandler configureDelegate) { ConfigWatcherHandler.ClearFilesMonitored(); ConfigWatcherHandler.AddFileToWatch( Resources.GetFileInfo( resource ) ); XmlDocument document = Resources.GetConfigAsXmlDocument( resource ); new DomDaoManagerBuilder().BuildDaoManagers( document, true ); TimerCallback callBackDelegate = new TimerCallback( DomDaoManagerBuilder.OnConfigFileChange ); StateConfig state = new StateConfig(); state.FileName = resource; state.ConfigureHandler = configureDelegate; new ConfigWatcherHandler( callBackDelegate, state ); }