Example #1
0
        /// <summary>
        /// 当一个监视项改变时,调用对应处理函数
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void fsw_Changed(object sender, FileSystemEventArgs e)
        {
            Debug.WriteLine(e.FullPath + " file changed");
            FileChangedEventHandler handler = (FileChangedEventHandler)this.m_watchers[sender];
            string fullPath           = Path.GetFullPath(e.FullPath);
            FileChangedEventArgs args = new FileChangedEventArgs(fullPath, m_keys[fullPath.ToLower()]);

            if (handler != null)
            {
                try
                {
                    if (handler.Method.IsStatic)
                    {
                        handler.Method.Invoke(null, new object[] { this, args });
                    }
                    else
                    {
                        handler.Method.Invoke(handler.Target, new object[] { this, args });
                    }
                }
                catch (System.Reflection.TargetInvocationException tiEx)
                {
                    Debug.WriteLine(tiEx.InnerException.ToString());
                    throw tiEx;
                }
            }
            else
            {
                this.m_watchers.Remove(sender);
            }
        }
Example #2
0
 /// <summary>
 /// 配置文件改变时的处理函数
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ConfigFileChangedHandler(object sender, FileChangedEventArgs e)
 {
     if (m_enableAutoRefreshConfig)
     {
         LoadSection((string)e.Key);
     }
 }