Example #1
0
 /// <summary>
 /// 生成接口实例
 /// </summary>
 /// <param name="interfaceName">接口名</param>
 /// <returns></returns>
 public static DynInterface CreateInterface(string interfaceName)
 {
     if (!string.IsNullOrEmpty(interfaceName))
     {
         DynInterface dynInterface = null;
         if (!_dynInterfaces.TryGetValue(interfaceName, out dynInterface))
         {
             dynInterface = new DynInterface(interfaceName);
             _dynInterfaces.Add(interfaceName, dynInterface);
         }
         return(dynInterface);
     }
     else
     {
         throw new ApplicationException("接口名不能为空或null");
     }
 }
Example #2
0
 /// <summary>
 /// 添加接口
 /// </summary>
 /// <param name="dynInterface">接口</param>
 public static void RegistInterface(DynInterface dynInterface)
 {
     if (dynInterface != null)
     {
         if (!_dynInterfaces.ContainsKey(dynInterface.Name))
         {
             _dynInterfaces.Add(dynInterface.Name, dynInterface);
         }
         else
         {
             throw new ApplicationException(string.Format("已经存在名称为{0}的接口", dynInterface.Name));
         }
     }
     else
     {
         throw new ApplicationException("动态接口不能为null");
     }
 }
Example #3
0
 /// <summary>
 /// 获取接口,如果没有则返回null
 /// </summary>
 /// <param name="name"></param>
 /// <returns></returns>
 public static DynInterface GetInterface(string interfaceName)
 {
     if (!string.IsNullOrEmpty(interfaceName))
     {
         DynInterface value = null;
         if (_dynInterfaces.TryGetValue(interfaceName, out value))
         {
             return(value);
         }
         else
         {
             throw new ApplicationException("不存在接口" + interfaceName);
         }
     }
     else
     {
         throw new ApplicationException("接口名不能为空或null");
     }
 }