diff --git a/Modbus.Net/Modbus.Net.Modbus/ModbusTcpProtocolLinker.cs b/Modbus.Net/Modbus.Net.Modbus/ModbusTcpProtocolLinker.cs
index 81b07e4..8365eaf 100644
--- a/Modbus.Net/Modbus.Net.Modbus/ModbusTcpProtocolLinker.cs
+++ b/Modbus.Net/Modbus.Net.Modbus/ModbusTcpProtocolLinker.cs
@@ -1,4 +1,5 @@
-using System.Configuration;
+using System.Collections.Generic;
+using System.Configuration;
namespace Modbus.Net.Modbus
{
@@ -23,7 +24,7 @@ namespace Modbus.Net.Modbus
/// 端口
public ModbusTcpProtocolLinker(string ip, int port) : base(ip, port)
{
- ((BaseConnector)BaseConnector).AddController(new FifoController(0));
+ ((BaseConnector)BaseConnector).AddController(new FifoController(0, true, DuplicateWithCount.GetDuplcateFunc(new List{4,5})));
}
///
diff --git a/Modbus.Net/Modbus.Net.Modbus/ModbusUdpProtocolLinker.cs b/Modbus.Net/Modbus.Net.Modbus/ModbusUdpProtocolLinker.cs
index cb7e394..96aab98 100644
--- a/Modbus.Net/Modbus.Net.Modbus/ModbusUdpProtocolLinker.cs
+++ b/Modbus.Net/Modbus.Net.Modbus/ModbusUdpProtocolLinker.cs
@@ -1,4 +1,5 @@
-using System.Configuration;
+using System.Collections.Generic;
+using System.Configuration;
namespace Modbus.Net.Modbus
{
@@ -23,7 +24,7 @@ namespace Modbus.Net.Modbus
/// 端口
public ModbusUdpProtocolLinker(string ip, int port) : base(ip, port)
{
- ((BaseConnector)BaseConnector).AddController(new FifoController(0));
+ ((BaseConnector)BaseConnector).AddController(new FifoController(0, true, DuplicateWithCount.GetDuplcateFunc(new List { 4, 5 })));
}
///
diff --git a/Modbus.Net/Modbus.Net.Siemens/SiemensTcpProtocolLinker.cs b/Modbus.Net/Modbus.Net.Siemens/SiemensTcpProtocolLinker.cs
index c55031b..aa77b16 100644
--- a/Modbus.Net/Modbus.Net.Siemens/SiemensTcpProtocolLinker.cs
+++ b/Modbus.Net/Modbus.Net.Siemens/SiemensTcpProtocolLinker.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Configuration;
+using System.Linq;
namespace Modbus.Net.Siemens
{
@@ -26,7 +27,7 @@ namespace Modbus.Net.Siemens
public SiemensTcpProtocolLinker(string ip, int port)
: base(ip, port)
{
- ((BaseConnector)BaseConnector).AddController(new MatchDirectlySendController(new ICollection<(int,int)>[] { new List<(int,int)> { (11,11), (12,12) } }));
+ ((BaseConnector)BaseConnector).AddController(new MatchDirectlySendController(new ICollection<(int,int)>[] { new List<(int,int)> { (11,11), (12,12) } }, DuplicateWithCount.GetDuplcateFunc(new List{2, 3})));
}
///
diff --git a/Modbus.Net/Modbus.Net/AsyncHelper.cs b/Modbus.Net/Modbus.Net/Async/AsyncHelper.cs
similarity index 100%
rename from Modbus.Net/Modbus.Net/AsyncHelper.cs
rename to Modbus.Net/Modbus.Net/Async/AsyncHelper.cs
diff --git a/Modbus.Net/Modbus.Net/BaseConnector.cs b/Modbus.Net/Modbus.Net/Connector/BaseConnector.cs
similarity index 100%
rename from Modbus.Net/Modbus.Net/BaseConnector.cs
rename to Modbus.Net/Modbus.Net/Connector/BaseConnector.cs
diff --git a/Modbus.Net/Modbus.Net/ComConnector.cs b/Modbus.Net/Modbus.Net/Connector/ComConnector.cs
similarity index 98%
rename from Modbus.Net/Modbus.Net/ComConnector.cs
rename to Modbus.Net/Modbus.Net/Connector/ComConnector.cs
index ecc0329..895c111 100644
--- a/Modbus.Net/Modbus.Net/ComConnector.cs
+++ b/Modbus.Net/Modbus.Net/Connector/ComConnector.cs
@@ -489,9 +489,12 @@ namespace Modbus.Net
$"Com client {ConnectionToken} receive msg: {String.Concat(returnBytes.Select(p => " " + p.ToString("X2")))}");
var isMessageConfirmed = Controller.ConfirmMessage(returnBytes);
- if (isMessageConfirmed == false)
+ foreach (var confirmed in isMessageConfirmed)
{
- //主动传输事件
+ if (confirmed == false)
+ {
+ //主动传输事件
+ }
}
RefreshReceiveCount();
diff --git a/Modbus.Net/Modbus.Net/SerialPortHelper.cs b/Modbus.Net/Modbus.Net/Connector/SerialPortHelper.cs
similarity index 100%
rename from Modbus.Net/Modbus.Net/SerialPortHelper.cs
rename to Modbus.Net/Modbus.Net/Connector/SerialPortHelper.cs
diff --git a/Modbus.Net/Modbus.Net/SocketMessageEventArgs.cs b/Modbus.Net/Modbus.Net/Connector/SocketMessageEventArgs.cs
similarity index 100%
rename from Modbus.Net/Modbus.Net/SocketMessageEventArgs.cs
rename to Modbus.Net/Modbus.Net/Connector/SocketMessageEventArgs.cs
diff --git a/Modbus.Net/Modbus.Net/TcpConnector.cs b/Modbus.Net/Modbus.Net/Connector/TcpConnector.cs
similarity index 97%
rename from Modbus.Net/Modbus.Net/TcpConnector.cs
rename to Modbus.Net/Modbus.Net/Connector/TcpConnector.cs
index 4cb6248..7de16e5 100644
--- a/Modbus.Net/Modbus.Net/TcpConnector.cs
+++ b/Modbus.Net/Modbus.Net/Connector/TcpConnector.cs
@@ -239,11 +239,14 @@ namespace Modbus.Net
Log.Verbose(
$"Tcp client {ConnectionToken} receive: {String.Concat(receiveBytes.Select(p => " " + p.ToString("X2")))}");
var isMessageConfirmed = Controller.ConfirmMessage(receiveBytes);
- if (isMessageConfirmed == false)
+ foreach (var confirmed in isMessageConfirmed)
{
- //主动传输事件
+ if (confirmed == false)
+ {
+ //主动传输事件
+ }
}
-
+
RefreshReceiveCount();
}
}
diff --git a/Modbus.Net/Modbus.Net/UdpConnector.cs b/Modbus.Net/Modbus.Net/Connector/UdpConnector.cs
similarity index 97%
rename from Modbus.Net/Modbus.Net/UdpConnector.cs
rename to Modbus.Net/Modbus.Net/Connector/UdpConnector.cs
index dae4717..2d2702c 100644
--- a/Modbus.Net/Modbus.Net/UdpConnector.cs
+++ b/Modbus.Net/Modbus.Net/Connector/UdpConnector.cs
@@ -220,9 +220,12 @@ namespace Modbus.Net
Log.Verbose(
$"Udp client {ConnectionToken} receive: {String.Concat(receiveBytes.Select(p => " " + p.ToString("X2")))}");
var isMessageConfirmed = Controller.ConfirmMessage(receiveBytes);
- if (isMessageConfirmed == false)
+ foreach (var confirmed in isMessageConfirmed)
{
- //主动传输事件
+ if (confirmed == false)
+ {
+ //主动传输事件
+ }
}
}
diff --git a/Modbus.Net/Modbus.Net/BaseController.cs b/Modbus.Net/Modbus.Net/Controller/BaseController.cs
similarity index 78%
rename from Modbus.Net/Modbus.Net/BaseController.cs
rename to Modbus.Net/Modbus.Net/Controller/BaseController.cs
index 43ed15a..b87452d 100644
--- a/Modbus.Net/Modbus.Net/BaseController.cs
+++ b/Modbus.Net/Modbus.Net/Controller/BaseController.cs
@@ -21,12 +21,19 @@ namespace Modbus.Net
///
protected Task SendingThread { get; set; }
+ ///
+ /// зλ
+ ///
+ protected Func> DuplicateFunc { get; }
+
///
///
///
- protected BaseController()
+ /// зֺ
+ protected BaseController(Func> duplicateFunc = null)
{
WaitingMessages = new List();
+ DuplicateFunc = duplicateFunc;
}
///
@@ -97,22 +104,31 @@ namespace Modbus.Net
protected abstract (string,string)? GetKeyFromMessage(byte[] message);
///
- public bool ConfirmMessage(byte[] receiveMessage)
+ public ICollection ConfirmMessage(byte[] receiveMessage)
{
- var def = GetMessageFromWaitingList(receiveMessage);
- if (def != null)
+ var ans = new List();
+ var duplicatedMessages = DuplicateFunc?.Invoke(receiveMessage);
+ duplicatedMessages = duplicatedMessages ?? new List {receiveMessage};
+ foreach (var message in duplicatedMessages)
{
- def.ReceiveMessage = receiveMessage;
- lock (WaitingMessages)
+ var def = GetMessageFromWaitingList(message);
+ if (def != null)
{
- WaitingMessages.Remove(def);
+ def.ReceiveMessage = receiveMessage;
+ lock (WaitingMessages)
+ {
+ WaitingMessages.Remove(def);
+ }
+ def.ReceiveMutex.Set();
+ ans.Add(true);
}
- def.ReceiveMutex.Set();
- return true;
+ ans.Add(false);
}
- return false;
+ return ans;
}
+
+
///
/// ӵȴƥϢ
///
diff --git a/Modbus.Net/Modbus.Net/Controller/DuplicateWithCount.cs b/Modbus.Net/Modbus.Net/Controller/DuplicateWithCount.cs
new file mode 100644
index 0000000..a8eac8d
--- /dev/null
+++ b/Modbus.Net/Modbus.Net/Controller/DuplicateWithCount.cs
@@ -0,0 +1,59 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Modbus.Net
+{
+ ///
+ /// 按照长度断包的函数
+ ///
+ public static class DuplicateWithCount
+ {
+ ///
+ /// 切分包
+ ///
+ /// 收到的报文信息
+ /// 收到的断包长度查询位置
+ /// 切分后的报文信息
+ private static ICollection DuplicateMessages(byte[] receiveMessage, ICollection packageCountPositions)
+ {
+ if (packageCountPositions == null)
+ return new List { receiveMessage };
+ var ans = new List();
+ var pos = 0;
+ while (pos < receiveMessage.Length)
+ {
+ try
+ {
+ var length = 0;
+ foreach (var countPos in packageCountPositions)
+ {
+ length = length * 256 + receiveMessage[pos + countPos];
+ }
+ if (pos + length > receiveMessage.Length) break;
+ byte[] currentPackage = new byte[length];
+ Array.Copy(receiveMessage, pos, currentPackage, 0, length);
+ ans.Add(currentPackage);
+ pos += length;
+ }
+ catch (Exception)
+ {
+ break;
+ }
+ }
+ return ans;
+ }
+
+ ///
+ /// 获取按照长度断包的函数
+ ///
+ /// 断包长度的位置信息
+ /// 断包函数
+ public static Func> GetDuplcateFunc(ICollection packageCountPositions)
+ {
+ return receiveMessage => DuplicateMessages(receiveMessage, packageCountPositions);
+ }
+ }
+}
diff --git a/Modbus.Net/Modbus.Net/FifoController.cs b/Modbus.Net/Modbus.Net/Controller/FifoController.cs
similarity index 95%
rename from Modbus.Net/Modbus.Net/FifoController.cs
rename to Modbus.Net/Modbus.Net/Controller/FifoController.cs
index 4bcf679..d35a4dc 100644
--- a/Modbus.Net/Modbus.Net/FifoController.cs
+++ b/Modbus.Net/Modbus.Net/Controller/FifoController.cs
@@ -1,4 +1,5 @@
using System;
+using System.Collections.Generic;
using System.Linq;
using System.Threading;
using Serilog;
@@ -28,7 +29,9 @@ namespace Modbus.Net
///
/// 间隔时间
/// 是否开启信号量
- public FifoController(int acquireTime, bool activateSema = true)
+ /// 包切分函数
+ public FifoController(int acquireTime, bool activateSema = true, Func> duplicateFunc = null)
+ : base(duplicateFunc)
{
if (activateSema)
{
diff --git a/Modbus.Net/Modbus.Net/MatchController.cs b/Modbus.Net/Modbus.Net/Controller/MatchController.cs
similarity index 84%
rename from Modbus.Net/Modbus.Net/MatchController.cs
rename to Modbus.Net/Modbus.Net/Controller/MatchController.cs
index 02643ee..8a60388 100644
--- a/Modbus.Net/Modbus.Net/MatchController.cs
+++ b/Modbus.Net/Modbus.Net/Controller/MatchController.cs
@@ -1,4 +1,5 @@
-using System.Collections.Generic;
+using System;
+using System.Collections.Generic;
using System.Linq;
namespace Modbus.Net
@@ -19,7 +20,9 @@ namespace Modbus.Net
/// 匹配字典,每个Collection代表一个匹配集合,每一个匹配集合中的数字代表需要匹配的位置,最后计算出来的数字是所有位置数字按照集合排序后叠放在一起
/// 获取间隔
/// 是否开启信号量
- public MatchController(ICollection<(int,int)>[] keyMatches, int acquireTime, bool activateSema = true) : base(acquireTime, activateSema)
+ /// 包切分函数
+ public MatchController(ICollection<(int, int)>[] keyMatches, int acquireTime, bool activateSema = true,
+ Func> duplicateFunc = null) : base(acquireTime, activateSema, duplicateFunc)
{
KeyMatches = keyMatches;
}
diff --git a/Modbus.Net/Modbus.Net/MatchDirectlySendController.cs b/Modbus.Net/Modbus.Net/Controller/MatchDirectlySendController.cs
similarity index 85%
rename from Modbus.Net/Modbus.Net/MatchDirectlySendController.cs
rename to Modbus.Net/Modbus.Net/Controller/MatchDirectlySendController.cs
index d27f39c..834426d 100644
--- a/Modbus.Net/Modbus.Net/MatchDirectlySendController.cs
+++ b/Modbus.Net/Modbus.Net/Controller/MatchDirectlySendController.cs
@@ -12,8 +12,9 @@ namespace Modbus.Net
public class MatchDirectlySendController : MatchController
{
///
- public MatchDirectlySendController(ICollection<(int, int)>[] keyMatches) : base(keyMatches,
- 0, false)
+ public MatchDirectlySendController(ICollection<(int, int)>[] keyMatches,
+ Func> duplicateFunc = null) : base(keyMatches,
+ 0, false, duplicateFunc)
{
}
diff --git a/Modbus.Net/Modbus.Net/IConnector.cs b/Modbus.Net/Modbus.Net/Interface/IConnector.cs
similarity index 100%
rename from Modbus.Net/Modbus.Net/IConnector.cs
rename to Modbus.Net/Modbus.Net/Interface/IConnector.cs
diff --git a/Modbus.Net/Modbus.Net/IController.cs b/Modbus.Net/Modbus.Net/Interface/IController.cs
similarity index 91%
rename from Modbus.Net/Modbus.Net/IController.cs
rename to Modbus.Net/Modbus.Net/Interface/IController.cs
index b4cda35..f911966 100644
--- a/Modbus.Net/Modbus.Net/IController.cs
+++ b/Modbus.Net/Modbus.Net/Interface/IController.cs
@@ -1,3 +1,5 @@
+using System.Collections.Generic;
+
namespace Modbus.Net
{
///
@@ -32,7 +34,7 @@ namespace Modbus.Net
///
/// صϢ
/// Ƿȷ
- bool ConfirmMessage(byte[] receiveMessage);
+ ICollection ConfirmMessage(byte[] receiveMessage);
///
/// ûκηʱǿɾȴϵϢ
diff --git a/Modbus.Net/Modbus.Net/IMachineMethod.cs b/Modbus.Net/Modbus.Net/Interface/IMachineMethod.cs
similarity index 100%
rename from Modbus.Net/Modbus.Net/IMachineMethod.cs
rename to Modbus.Net/Modbus.Net/Interface/IMachineMethod.cs
diff --git a/Modbus.Net/Modbus.Net/IProtocol.cs b/Modbus.Net/Modbus.Net/Interface/IProtocol.cs
similarity index 100%
rename from Modbus.Net/Modbus.Net/IProtocol.cs
rename to Modbus.Net/Modbus.Net/Interface/IProtocol.cs
diff --git a/Modbus.Net/Modbus.Net/IProtocolFormatting.cs b/Modbus.Net/Modbus.Net/Interface/IProtocolFormatting.cs
similarity index 100%
rename from Modbus.Net/Modbus.Net/IProtocolFormatting.cs
rename to Modbus.Net/Modbus.Net/Interface/IProtocolFormatting.cs
diff --git a/Modbus.Net/Modbus.Net/IProtocolLinker.cs b/Modbus.Net/Modbus.Net/Interface/IProtocolLinker.cs
similarity index 100%
rename from Modbus.Net/Modbus.Net/IProtocolLinker.cs
rename to Modbus.Net/Modbus.Net/Interface/IProtocolLinker.cs
diff --git a/Modbus.Net/Modbus.Net/IProtocolLinkerBytesExtend.cs b/Modbus.Net/Modbus.Net/Interface/IProtocolLinkerBytesExtend.cs
similarity index 100%
rename from Modbus.Net/Modbus.Net/IProtocolLinkerBytesExtend.cs
rename to Modbus.Net/Modbus.Net/Interface/IProtocolLinkerBytesExtend.cs
diff --git a/Modbus.Net/Modbus.Net/IUtilityMethod.cs b/Modbus.Net/Modbus.Net/Interface/IUtilityMethod.cs
similarity index 100%
rename from Modbus.Net/Modbus.Net/IUtilityMethod.cs
rename to Modbus.Net/Modbus.Net/Interface/IUtilityMethod.cs
diff --git a/Modbus.Net/Modbus.Net/ComProtocalLinker.cs b/Modbus.Net/Modbus.Net/Linker/ComProtocalLinker.cs
similarity index 100%
rename from Modbus.Net/Modbus.Net/ComProtocalLinker.cs
rename to Modbus.Net/Modbus.Net/Linker/ComProtocalLinker.cs
diff --git a/Modbus.Net/Modbus.Net/TcpProtocalLinker.cs b/Modbus.Net/Modbus.Net/Linker/TcpProtocalLinker.cs
similarity index 100%
rename from Modbus.Net/Modbus.Net/TcpProtocalLinker.cs
rename to Modbus.Net/Modbus.Net/Linker/TcpProtocalLinker.cs
diff --git a/Modbus.Net/Modbus.Net/UdpProtocolLinker.cs b/Modbus.Net/Modbus.Net/Linker/UdpProtocolLinker.cs
similarity index 100%
rename from Modbus.Net/Modbus.Net/UdpProtocolLinker.cs
rename to Modbus.Net/Modbus.Net/Linker/UdpProtocolLinker.cs
diff --git a/Modbus.Net/Modbus.Net/AddressCombiner.cs b/Modbus.Net/Modbus.Net/Machine/AddressCombiner.cs
similarity index 100%
rename from Modbus.Net/Modbus.Net/AddressCombiner.cs
rename to Modbus.Net/Modbus.Net/Machine/AddressCombiner.cs
diff --git a/Modbus.Net/Modbus.Net/AddressFormater.cs b/Modbus.Net/Modbus.Net/Machine/AddressFormater.cs
similarity index 100%
rename from Modbus.Net/Modbus.Net/AddressFormater.cs
rename to Modbus.Net/Modbus.Net/Machine/AddressFormater.cs
diff --git a/Modbus.Net/Modbus.Net/AddressHelper.cs b/Modbus.Net/Modbus.Net/Machine/AddressHelper.cs
similarity index 100%
rename from Modbus.Net/Modbus.Net/AddressHelper.cs
rename to Modbus.Net/Modbus.Net/Machine/AddressHelper.cs
diff --git a/Modbus.Net/Modbus.Net/BaseMachine.cs b/Modbus.Net/Modbus.Net/Machine/BaseMachine.cs
similarity index 100%
rename from Modbus.Net/Modbus.Net/BaseMachine.cs
rename to Modbus.Net/Modbus.Net/Machine/BaseMachine.cs
diff --git a/Modbus.Net/Modbus.Net/BaseMachineExtend.cs b/Modbus.Net/Modbus.Net/Machine/BaseMachineExtend.cs
similarity index 100%
rename from Modbus.Net/Modbus.Net/BaseMachineExtend.cs
rename to Modbus.Net/Modbus.Net/Machine/BaseMachineExtend.cs
diff --git a/Modbus.Net/Modbus.Net/BaseProtocol.cs b/Modbus.Net/Modbus.Net/Protocol/BaseProtocol.cs
similarity index 100%
rename from Modbus.Net/Modbus.Net/BaseProtocol.cs
rename to Modbus.Net/Modbus.Net/Protocol/BaseProtocol.cs
diff --git a/Modbus.Net/Modbus.Net/PipeUnit.cs b/Modbus.Net/Modbus.Net/Protocol/PipeUnit.cs
similarity index 100%
rename from Modbus.Net/Modbus.Net/PipeUnit.cs
rename to Modbus.Net/Modbus.Net/Protocol/PipeUnit.cs
diff --git a/Modbus.Net/Modbus.Net/ProtocalLinker.cs b/Modbus.Net/Modbus.Net/Protocol/ProtocalLinker.cs
similarity index 100%
rename from Modbus.Net/Modbus.Net/ProtocalLinker.cs
rename to Modbus.Net/Modbus.Net/Protocol/ProtocalLinker.cs
diff --git a/Modbus.Net/Modbus.Net/ProtocalUnit.cs b/Modbus.Net/Modbus.Net/Protocol/ProtocalUnit.cs
similarity index 100%
rename from Modbus.Net/Modbus.Net/ProtocalUnit.cs
rename to Modbus.Net/Modbus.Net/Protocol/ProtocalUnit.cs
diff --git a/Modbus.Net/Modbus.Net/TaskManager.cs b/Modbus.Net/Modbus.Net/Task/TaskManager.cs
similarity index 100%
rename from Modbus.Net/Modbus.Net/TaskManager.cs
rename to Modbus.Net/Modbus.Net/Task/TaskManager.cs
diff --git a/Modbus.Net/Modbus.Net/TypeExtensions.cs b/Modbus.Net/Modbus.Net/TypeExtensions.cs
deleted file mode 100644
index 25a197e..0000000
--- a/Modbus.Net/Modbus.Net/TypeExtensions.cs
+++ /dev/null
@@ -1,126 +0,0 @@
-using System;
-using System.Diagnostics;
-using System.Linq;
-using System.Reflection;
-
-namespace Modbus.Net
-{
- ///
- /// Extensions of Reflection
- ///
- public static class TypeExtensions
- {
- #region Public Methods
-
- ///
- /// Looks for the method in the type matching the name and arguments.
- ///
- ///
- ///
- /// The name of the method to find.
- ///
- ///
- /// The types of the method's arguments to match.
- ///
- ///
- /// Is method Generic Method.
- ///
- ///
- ///
- /// Thrown if:
- /// - The name of the method is not specified.
- ///
- public static MethodInfo GetRuntimeMethod(this Type type, string methodName, Type[] args, bool isGenericMethod)
- {
- if (ReferenceEquals(type, null))
- throw new NullReferenceException("The type has not been specified.");
-
- if (string.IsNullOrEmpty(methodName))
- throw new ArgumentNullException(nameof(methodName), "The name of the method has not been specified.");
-
-
- var methods =
- type.GetRuntimeMethods()
- .Where(methodInfo => string.Equals(methodInfo.Name, methodName, StringComparison.OrdinalIgnoreCase))
- .ToList();
-
- if (!methods.Any())
- return null; // No methods have the specified name.
-
- if (isGenericMethod)
- methods = methods.Where(method => method.IsGenericMethod).ToList();
- else
- methods = methods.Where(method => !method.IsGenericMethod).ToList();
-
- var ans = methods.Where(method => IsSignatureMatch(method, args));
-
- if (ans.Count() <= 1)
- return ans.Count() == 1 ? ans.Single() : null;
-
- // Oh noes, don't make me go there.
- throw new NotImplementedException("Resolving overloaded methods is not implemented as of now.");
- }
-
- #endregion
-
- #region Private Methods
-
- ///
- /// Finds out if the provided arguments matches the specified method's signature.
- ///
- ///
- ///
- ///
- private static bool IsSignatureMatch(MethodBase methodInfo, Type[] args)
- {
- Debug.Assert(!ReferenceEquals(methodInfo, null), "The methodInfo has not been specified.");
-
-
- // Gets the parameters of the method to analyze.
- var parameters = methodInfo.GetParameters();
-
- var currentArgId = 0;
-
- foreach (var parameterInfo in parameters)
- {
- if (!ReferenceEquals(args, null) && currentArgId < args.Length)
- {
- // Find out if the types matchs.
- if (parameterInfo.ParameterType == args[currentArgId])
- {
- currentArgId++;
- continue; // Yeah! Try the next one.
- }
-
- // Is this a generic parameter?
- if (parameterInfo.ParameterType.IsGenericParameter)
- {
- // Gets the base type of the generic parameter.
- var baseType = parameterInfo.ParameterType.GetTypeInfo().BaseType;
-
-
- // TODO: This is not good v and works with the most simple situation.
- // Does the base type match?
- if (args[currentArgId].GetTypeInfo().BaseType == baseType)
- {
- currentArgId++;
- continue; // Yeah! Go on to the next parameter.
- }
- }
- }
-
- // Is this parameter optional or does it have a default value?
- if (parameterInfo.IsOptional || parameterInfo.HasDefaultValue)
- continue; // Uhum. So let's ignore this parameter for now.
-
- // No need to go further. It does not match :(
- return false;
- }
-
- // Ye!
- return true;
- }
-
- #endregion
- }
-}
\ No newline at end of file
diff --git a/Modbus.Net/Modbus.Net/AddressTranslator.cs b/Modbus.Net/Modbus.Net/Utility/AddressTranslator.cs
similarity index 100%
rename from Modbus.Net/Modbus.Net/AddressTranslator.cs
rename to Modbus.Net/Modbus.Net/Utility/AddressTranslator.cs
diff --git a/Modbus.Net/Modbus.Net/BaseUtility.cs b/Modbus.Net/Modbus.Net/Utility/BaseUtility.cs
similarity index 100%
rename from Modbus.Net/Modbus.Net/BaseUtility.cs
rename to Modbus.Net/Modbus.Net/Utility/BaseUtility.cs
diff --git a/Modbus.Net/Modbus.Net/CRC16.cs b/Modbus.Net/Modbus.Net/Value/CRC16.cs
similarity index 100%
rename from Modbus.Net/Modbus.Net/CRC16.cs
rename to Modbus.Net/Modbus.Net/Value/CRC16.cs
diff --git a/Modbus.Net/Modbus.Net/ValueHelper.cs b/Modbus.Net/Modbus.Net/Value/ValueHelper.cs
similarity index 100%
rename from Modbus.Net/Modbus.Net/ValueHelper.cs
rename to Modbus.Net/Modbus.Net/Value/ValueHelper.cs