XmlSerializers created by XmlSerializer.FromType(new[] {typeof(...)})[0]; This prevents throwing an exception => better debugging.

This commit is contained in:
Milan Hanajik
2017-06-22 21:37:05 +02:00
parent 7ad8c986d7
commit 17f6f7c3be
193 changed files with 450 additions and 182 deletions
@@ -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
{