Пример #1
0
        /// <summary>
        /// 取任意已经提供的Web服务。客户端使用
        /// </summary>
        /// <typeparam name="T">服务类型。</typeparam>
        /// <param name="MapKey">服务标识。</param>
        /// <returns></returns>
        public static T GetRemoteService <T>(string MapKey = "") where T : class
        {
            if (AppSettings.Debug)
            {
                return(GetService <T>(MapKey));
            }
            var theMaped = MapContainer.GetTypeMap(MapKey, typeof(T).FullName);

            if (theMaped == null)
            {
                throw new Exception(typeof(T).FullName + " 没有在配置文件中注册映射。");
            }
            var Manager = GetService <IRemoteProxyManager>();
            T   proxy   = Manager.GetApiProxy <T>(theMaped);

            return(proxy);
        }
Пример #2
0
 /// <summary>
 /// 按给定的key取任意已经提供的服务。
 /// </summary>
 /// <param name="typeName">服务类型名</param>
 /// <param name="MapKey">服务标识</param>
 /// <param name="Params">获取服务的参数</param>
 /// <returns></returns>
 public static object GetServiceByKey(string MapKey, string typeName, params object[] Params)
 {
     return(MapContainer.GetInstance(MapKey, typeName, Params));
 }
Пример #3
0
 /// <summary>
 /// 取任意已经提供的服务,如果存在多个,则返回第一个。
 /// </summary>
 /// <param name="typeName">服务类型名</param>
 /// <param name="Params">获取服务的参数</param>
 /// <returns></returns>
 public static object GetService(string typeName, params object[] Params)
 {
     return(MapContainer.GetInstance(typeName, "", Params));
 }
Пример #4
0
 public static object GetServiceByKey <T>(string MapKey)
 {
     return(MapContainer.GetInstance(MapKey));
 }
Пример #5
0
 /// <summary>
 /// 按给定的key取任意已经提供的服务。
 /// </summary>
 /// <typeparam name="T">服务类型</typeparam>
 /// <param name="MapKey">服务标识</param>
 /// <param name="Params">获取服务的参数</param>
 /// <returns></returns>
 public static T GetServiceByKey <T>(string MapKey, params object[] Params) where T : class
 {
     return(MapContainer.GetInstance(MapKey, typeof(T).FullName, Params) as T);
 }
Пример #6
0
 /// <summary>
 /// 取任意已经提供的服务,如果存在多个,则返回第一个。
 /// </summary>
 /// <typeparam name="T">服务类型</typeparam>
 /// <param name="Params">获取服务的参数</param>
 /// <returns></returns>
 public static T GetService <T>(params object[] Params) where T : class
 {
     return(MapContainer.GetInstance("", typeof(T).FullName, Params) as T);
 }