Emergency Fix: Support .NET Core
This commit is contained in:
@@ -5,7 +5,15 @@ namespace Modbus.Net
|
||||
/// <summary>
|
||||
/// 基础的协议连接类
|
||||
/// </summary>
|
||||
public abstract class BaseConnector
|
||||
public abstract class BaseConnector : BaseConnector<byte[], byte[]>
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 基础的协议连接类
|
||||
/// </summary>
|
||||
public abstract class BaseConnector<TParamIn, TParamOut>
|
||||
{
|
||||
/// <summary>
|
||||
/// 标识Connector的连接关键字
|
||||
@@ -40,27 +48,27 @@ namespace Modbus.Net
|
||||
/// </summary>
|
||||
/// <param name="message">需要发送的数据</param>
|
||||
/// <returns>是否发送成功</returns>
|
||||
public abstract bool SendMsgWithoutReturn(byte[] message);
|
||||
public abstract bool SendMsgWithoutReturn(TParamIn message);
|
||||
|
||||
/// <summary>
|
||||
/// 无返回发送数据
|
||||
/// </summary>
|
||||
/// <param name="message">需要发送的数据</param>
|
||||
/// <returns>是否发送成功</returns>
|
||||
public abstract Task<bool> SendMsgWithoutReturnAsync(byte[] message);
|
||||
public abstract Task<bool> SendMsgWithoutReturnAsync(TParamIn message);
|
||||
|
||||
/// <summary>
|
||||
/// 带返回发送数据
|
||||
/// </summary>
|
||||
/// <param name="message">需要发送的数据</param>
|
||||
/// <returns>是否发送成功</returns>
|
||||
public abstract byte[] SendMsg(byte[] message);
|
||||
public abstract TParamOut SendMsg(TParamIn message);
|
||||
|
||||
/// <summary>
|
||||
/// 带返回发送数据
|
||||
/// </summary>
|
||||
/// <param name="message">需要发送的数据</param>
|
||||
/// <returns>是否发送成功</returns>
|
||||
public abstract Task<byte[]> SendMsgAsync(byte[] message);
|
||||
public abstract Task<TParamOut> SendMsgAsync(TParamIn message);
|
||||
}
|
||||
}
|
||||
@@ -594,8 +594,7 @@ namespace Modbus.Net
|
||||
if (BaseUtility is TUtilityMethod)
|
||||
{
|
||||
Type t = typeof(TUtilityMethod);
|
||||
object returnValue = t.GetMethod(methodName,
|
||||
BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public)
|
||||
object returnValue = t.GetRuntimeMethod(methodName, parameters.Select(p => p.GetType()).ToArray())
|
||||
.Invoke(BaseUtility, parameters);
|
||||
return (TReturnType) returnValue;
|
||||
}
|
||||
@@ -616,8 +615,7 @@ namespace Modbus.Net
|
||||
if (this is TMachineMethod)
|
||||
{
|
||||
Type t = typeof(TMachineMethod);
|
||||
object returnValue = t.GetMethod(methodName,
|
||||
BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public)
|
||||
object returnValue = t.GetRuntimeMethod(methodName, parameters.Select(p => p.GetType()).ToArray())
|
||||
.Invoke(this, parameters);
|
||||
return (TReturnType) returnValue;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace Modbus.Net.Tests
|
||||
{
|
||||
BaseMachine<int, int> baseMachine = new ModbusMachine<int, int>(ModbusType.Tcp, "192.168.3.12", null, true, 2, 0);
|
||||
var utility = baseMachine.GetUtility<IUtilityTime>();
|
||||
var methods = utility.GetType().GetMethods(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly);
|
||||
var methods = utility.GetType().GetRuntimeMethods();
|
||||
Assert.AreEqual(methods.FirstOrDefault(method => method.Name == "GetTimeAsync") != null, true);
|
||||
Assert.AreEqual(methods.FirstOrDefault(method => method.Name == "SetTimeAsync") != null, true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user