XmlSerializers created by XmlSerializer.FromType(new[] {typeof(...)})[0]; This prevents throwing an exception => better debugging.
This commit is contained in:
@@ -13,6 +13,9 @@ namespace TBF.BenchControl.TestMethods.PMaxTest
|
||||
{
|
||||
public class PMaxTestParams : TestParamsBase, IParamsProvider, ITestParams
|
||||
{
|
||||
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(PMaxTestParams) })[0];
|
||||
protected override XmlSerializer GetSerializer() { return Serializer; }
|
||||
|
||||
public float PressureLo; /// Presure range low limit in [bar]
|
||||
public float PressureHi; /// Presure range high limit in [bar]
|
||||
public int DurationPMax; /// Duration of the test in [s]
|
||||
@@ -99,14 +102,13 @@ namespace TBF.BenchControl.TestMethods.PMaxTest
|
||||
if (dbEntity == null) return;
|
||||
try
|
||||
{
|
||||
PMaxTestParams tmp = (PMaxTestParams)(new XmlSerializer(typeof(PMaxTestParams)))
|
||||
.Deserialize(new StringReader(dbEntity.Parameters));
|
||||
PMaxTestParams tmp = Serializer.Deserialize(new StringReader(dbEntity.Parameters)) as PMaxTestParams;
|
||||
|
||||
testParamsEntity = dbEntity;
|
||||
componentName = dbEntity.CmpntName;
|
||||
test = dbEntity.Test;
|
||||
|
||||
tmp.CopyContentTo(this);
|
||||
if (tmp != null) tmp.CopyContentTo(this);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
@@ -12,6 +12,9 @@ namespace TBF.BenchControl.TestMethods.PMaxTest
|
||||
{
|
||||
public class TestMethodCfg : ComponentCfgBase, Generic.IComponentCfg
|
||||
{
|
||||
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(TestMethodCfg) })[0];
|
||||
protected override XmlSerializer GetSerializer() { return Serializer; }
|
||||
|
||||
public IComponentCfgCtrl GetControl() { return new TestMethodCfgCtrl(); }
|
||||
|
||||
/// <summary> Test parameters </summary>
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace TBF.BenchControl.TestMethods.PMaxTest
|
||||
|
||||
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
|
||||
{
|
||||
return ComponentCfgBase.CreateFromDbEntity(typeof(TestMethodCfg), component, this);
|
||||
return ComponentCfgBase.CreateFromDbEntity(TestMethodCfg.Serializer, component, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user