Bug Fix
This commit is contained in:
@@ -85,13 +85,16 @@ namespace Modbus.Net
|
|||||||
{
|
{
|
||||||
if (Protocals.ContainsKey(protocalName))
|
if (Protocals.ContainsKey(protocalName))
|
||||||
protocalUnitReturn = Protocals[protocalName];
|
protocalUnitReturn = Protocals[protocalName];
|
||||||
//自动寻找存在的协议并将其加载
|
else
|
||||||
var protocalUnit =
|
{
|
||||||
Activator.CreateInstance(type.GetTypeInfo().Assembly.GetType(protocalName)) as TProtocalUnit;
|
//自动寻找存在的协议并将其加载
|
||||||
if (protocalUnit == null)
|
var protocalUnit =
|
||||||
throw new InvalidCastException($"No ProtocalUnit {nameof(TProtocalUnit)} implemented");
|
Activator.CreateInstance(type.GetTypeInfo().Assembly.GetType(protocalName)) as TProtocalUnit;
|
||||||
protocalUnit.Endian = Endian;
|
if (protocalUnit == null)
|
||||||
Register(protocalUnit);
|
throw new InvalidCastException($"No ProtocalUnit {nameof(TProtocalUnit)} implemented");
|
||||||
|
protocalUnit.Endian = Endian;
|
||||||
|
Register(protocalUnit);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return protocalUnitReturn ?? Protocals[protocalName];
|
return protocalUnitReturn ?? Protocals[protocalName];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user