2014-08-30 update 1 small changes in ResourceManager

This commit is contained in:
parallelbgls@outlook.com
2014-08-30 09:58:53 +08:00
parent 49f2a5272c
commit ada2568ff1
3 changed files with 12 additions and 28 deletions

View File

@@ -77,23 +77,5 @@ namespace ModBus.Net {
return ResourceManager.GetString("IP", resourceCulture);
}
}
/// <summary>
/// 查找类似 502 的本地化字符串。
/// </summary>
internal static string Port {
get {
return ResourceManager.GetString("Port", resourceCulture);
}
}
/// <summary>
/// 查找类似 1000 的本地化字符串。
/// </summary>
internal static string SocketTimeOut {
get {
return ResourceManager.GetString("SocketTimeOut", resourceCulture);
}
}
}
}

View File

@@ -123,10 +123,4 @@
<data name="IP" xml:space="preserve">
<value>192.168.3.247</value>
</data>
<data name="Port" xml:space="preserve">
<value>502</value>
</data>
<data name="SocketTimeOut" xml:space="preserve">
<value>1000</value>
</data>
</root>

View File

@@ -10,15 +10,23 @@ namespace ModBus.Net
/// 连接对象
/// </summary>
protected TcpProtocalLinker()
protected TcpProtocalLinker() : this(ConfigurationManager.IP)
{
//初始化连对象
_baseConnector = new TcpConnector(ConfigurationManager.IP, int.Parse(ConfigurationManager.Port), false);
}
protected TcpProtocalLinker(string ip)
{
_baseConnector = new TcpConnector(ip, int.Parse(ConfigurationManager.Port), false);
int port;
if (ConfigurationManager.ResourceManager.GetString("Port") != null && int.TryParse(ConfigurationManager.ResourceManager.GetString("Port"),out port))
{
}
else
{
port = 502;
}
_baseConnector = new TcpConnector(ip, port, false);
}
}
}