XmlSerializers created by XmlSerializer.FromType(new[] {typeof(...)})[0]; This prevents throwing an exception => better debugging.
This commit is contained in:
@@ -20,7 +20,7 @@ namespace TBF.BenchControl.Modbus.Common
|
||||
|
||||
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
|
||||
{
|
||||
return ComponentCfgBase.CreateFromDbEntity(typeof(ModbusCfg), component, this);
|
||||
return ComponentCfgBase.CreateFromDbEntity(ModbusCfg.Serializer, component, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,9 @@ namespace TBF.BenchControl.Modbus.Common
|
||||
{
|
||||
public class ModbusCfg : ComponentCfgBase, Generic.IComponentCfg
|
||||
{
|
||||
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(ModbusCfg) })[0];
|
||||
protected override XmlSerializer GetSerializer() { return Serializer; }
|
||||
|
||||
public IComponentCfgCtrl GetControl() { return new ModbusCfgCtrl(); }
|
||||
|
||||
///
|
||||
|
||||
@@ -10,6 +10,9 @@ namespace TBF.BenchControl.Modbus.Easytherm
|
||||
{
|
||||
public class EasythermCfg : ComponentCfgBase, Generic.IChildComponentCfg
|
||||
{
|
||||
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(EasythermCfg) })[0];
|
||||
protected override XmlSerializer GetSerializer() { return Serializer; }
|
||||
|
||||
public IComponentCfgCtrl GetControl() { return new EasythermCfgCtrl(); }
|
||||
|
||||
///
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace TBF.BenchControl.Modbus.Easytherm
|
||||
|
||||
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
|
||||
{
|
||||
return ComponentCfgBase.CreateFromDbEntity(typeof(EasythermCfg), component, this);
|
||||
return ComponentCfgBase.CreateFromDbEntity(EasythermCfg.Serializer, component, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,9 @@ namespace TBF.BenchControl.Modbus.Easytherm
|
||||
{
|
||||
public class ProcParams : ProcedureParamsBase, IParamsProvider, IProcedureParams
|
||||
{
|
||||
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(ProcParams) })[0];
|
||||
protected override XmlSerializer GetSerializer() { return Serializer; }
|
||||
|
||||
public float RequiredTemp; /// [°C] target temperature for a temperature controller or 0=not communicated to the controller
|
||||
|
||||
|
||||
@@ -101,14 +104,13 @@ namespace TBF.BenchControl.Modbus.Easytherm
|
||||
if (dbEntity == null) return;
|
||||
try
|
||||
{
|
||||
ProcParams tmp = (ProcParams)(new XmlSerializer(typeof(ProcParams)))
|
||||
.Deserialize(new StringReader(dbEntity.Parameters));
|
||||
ProcParams tmp = Serializer.Deserialize(new StringReader(dbEntity.Parameters)) as ProcParams;
|
||||
|
||||
procedureParamsEntity = dbEntity;
|
||||
componentName = dbEntity.CmpntName;
|
||||
procedure = dbEntity.Procedure;
|
||||
|
||||
tmp.CopyContentTo(this);
|
||||
if (tmp != null) tmp.CopyContentTo(this);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace TBF.BenchControl.Modbus.PressureMeter.Meret
|
||||
|
||||
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
|
||||
{
|
||||
return ComponentCfgBase.CreateFromDbEntity(typeof(PressureMeterCfg), component, this);
|
||||
return ComponentCfgBase.CreateFromDbEntity(PressureMeterCfg.Serializer, component, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,9 @@ namespace TBF.BenchControl.Modbus.PressureMeter.Meret
|
||||
{
|
||||
public class PressureMeterCfg : ComponentCfgBase, Generic.IChildComponentCfg
|
||||
{
|
||||
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(PressureMeterCfg) })[0];
|
||||
protected override XmlSerializer GetSerializer() { return Serializer; }
|
||||
|
||||
public IComponentCfgCtrl GetControl() { return new PressureMeterCfgCtrl(); }
|
||||
|
||||
///
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace TBF.BenchControl.Modbus.QuidoRS
|
||||
|
||||
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
|
||||
{
|
||||
return ComponentCfgBase.CreateFromDbEntity(typeof(QuidoRSCfg), component, this);
|
||||
return ComponentCfgBase.CreateFromDbEntity(QuidoRSCfg.Serializer, component, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,9 @@ namespace TBF.BenchControl.Modbus.QuidoRS
|
||||
{
|
||||
public class QuidoRSCfg : ComponentCfgBase, Generic.IChildComponentCfg
|
||||
{
|
||||
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(QuidoRSCfg) })[0];
|
||||
protected override XmlSerializer GetSerializer() { return Serializer; }
|
||||
|
||||
public IComponentCfgCtrl GetControl() { return new QuidoRSCfgCtrl(); }
|
||||
|
||||
///
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace TBF.BenchControl.Modbus.TankSelector
|
||||
|
||||
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
|
||||
{
|
||||
return ComponentCfgBase.CreateFromDbEntity(typeof(TankSelectorCfg), component, this);
|
||||
return ComponentCfgBase.CreateFromDbEntity(TankSelectorCfg.Serializer, component, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
///
|
||||
/// Copyright (c) 2017 Sensus Metering Systems
|
||||
///
|
||||
using System.Xml.Serialization;
|
||||
using TBF.BenchControl.Generic;
|
||||
|
||||
namespace TBF.BenchControl.Modbus.TankSelector
|
||||
{
|
||||
public class TankSelectorCfg : ComponentCfgBase, Generic.IChildComponentCfg
|
||||
{
|
||||
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(TankSelectorCfg) })[0];
|
||||
protected override XmlSerializer GetSerializer() { return Serializer; }
|
||||
|
||||
public IComponentCfgCtrl GetControl() { return new TankSelectorCfgCtrl(); }
|
||||
|
||||
///
|
||||
|
||||
Reference in New Issue
Block a user