Example #1
0
 /// <summary>
 /// 读取指定服务配置
 /// 先按照私有配置读取,如果失败,再按照共有配置读取
 /// </summary>
 /// <typeparam name="T">返回配置内容类</typeparam>
 /// <param name="serviceConfig"></param>
 /// <param name="serviceName">共有服务</param>
 /// <param name="hostServiceName">私有子服务</param>
 /// <returns></returns>
 public static T GetServiceFromBuffer <T>(this IServiceConfig serviceConfig, ServiceName serviceName, ServiceName hostServiceName) where T : class
 {
     try
     {
         return(serviceConfig.GetServiceFromBuffer <T>(string.Format("{0}-{1}", serviceName, hostServiceName))); //先获取独立配置
     }
     catch (MissConfigException)                                                                                 //如果没有取到
     {
         return(serviceConfig.GetServiceFromBuffer <T>(serviceName.ToString()));                                 //再尝试全局配置
     }
 }
Example #2
0
 /// <summary>
 /// 读取指定服务配置
 /// </summary>
 /// <typeparam name="T">返回配置内容类</typeparam>
 /// <param name="serviceConfig"></param>
 /// <param name="serviceName">共有服务</param>
 /// <returns></returns>
 public static T GetServiceFromBuffer <T>(this IServiceConfig serviceConfig, ServiceName serviceName) where T : class
 {
     return(serviceConfig.GetServiceFromBuffer <T>(serviceName.ToString()));
 }