/// <summary> /// 创建本地远程调用通道 /// </summary> /// <param name="channelName">通道名称</param> /// <param name="pro">通道回调</param> public static void CreateChannelA(string channelName, Action <object> pro) { if (string.IsNullOrWhiteSpace(channelName)) { throw new ArgumentNullException(nameof(channelName), "本地远程调用通道名称不能为空或全空格"); } if (pro == null) { throw new ArgumentNullException(nameof(pro), "回调委托不能为null"); } if (_channelDic.ContainsKey(channelName)) { throw new ArgumentException(string.Format("已存在名称为:{0}的本地远程调用通道", channelName)); } _channelDic[channelName] = new LRPCChannel(channelName, pro); }
/// <summary> /// 创建本地远程调用通道[返回值:true:创建成功;false:创建失败,该通道已存在] /// </summary> /// <param name="channelName">通道名称</param> /// <param name="pro">通道回调</param> /// <returns>创建结果</returns> public static bool TryCreateChannelA(string channelName, Action <object> pro) { if (string.IsNullOrWhiteSpace(channelName)) { throw new ArgumentNullException(nameof(channelName), "本地远程调用通道名称不能为空或全空格"); } if (pro == null) { throw new ArgumentNullException(nameof(pro), "回调委托不能为null"); } if (_channelDic.ContainsKey(channelName)) { return(false); } _channelDic[channelName] = new LRPCChannel(channelName, pro); return(true); }