예제 #1
0
 /// <summary>
 /// 触发请求保存配置事件
 /// </summary>
 /// <param name="e">事件参数</param>
 protected virtual void OnRequireSaveConfig(ServiceConfigEventArgs e)
 {
     if (ReuqireSaveConfig != null)
     {
         ReuqireSaveConfig(this, e);
     }
 }
예제 #2
0
        /// <summary>
        /// 触发请求加载配置事件
        /// </summary>
        /// <param name="e">事件参数</param>
        /// <returns>返回是否被处理</returns>
        protected virtual bool OnRequireLoadConfig(ServiceConfigEventArgs e)
        {
            if (RequireLoadConfig != null)
            {
                RequireLoadConfig(this, e);
            }

            return(e.IsHandled);
        }
예제 #3
0
 /// <summary>
 /// 保存配置
 /// </summary>
 protected virtual void SaveConfig()
 {
     if (ProviderConfig != null)
     {
         ServiceConfigEventArgs e = new ServiceConfigEventArgs()
         {
             ConfigObject = ProviderConfig
         };
         OnRequireSaveConfig(e);
     }
 }
예제 #4
0
        /// <summary>
        /// 加载配置
        /// </summary>
        /// <typeparam name="T">配置类型</typeparam>
        /// <returns>加载的配置</returns>
        protected virtual T LoadConfig <T>() where T : class
        {
            if (ProviderConfig == null)
            {
                ServiceConfigEventArgs e = new ServiceConfigEventArgs()
                {
                    Type = typeof(T)
                };
                if (OnRequireLoadConfig(e))
                {
                    ProviderConfig = e.ConfigObject;
                }
            }

            return(ProviderConfig as T);
        }