tbf/TestBenchFramework/BenchControl/DataEntry/Munich/EntryFormCfg.cs
2014-07-28 09:56:40 +02:00

63 lines
1.7 KiB
C#

using System;
using System.IO;
using System.Xml.Serialization;
using TBF.BenchControl.Generic;
namespace TBF.BenchControl.DataEntry.Munich
{
public class EntryFormCfg : ComponentCfgBase, Generic.IComponentCfg
{
public string ProtocolTitle1;
public string ProtocolTitle2;
public string ProtocolTitle3;
/// Parameterless constructor
public EntryFormCfg()
{
}
/// <summary>
/// Data entry form configuration parameters
/// </summary>
/// <param name="factory">Data entry form factory</param>
/// <param name="name">Component name</param>
public EntryFormCfg(IComponentFactory factory, string name,
string protocolTitle1, string protocolTitle2, string protocolTitle3)
: base(factory, name)
{
this.ProtocolTitle1 = protocolTitle1;
this.ProtocolTitle2 = protocolTitle2;
this.ProtocolTitle3 = protocolTitle3;
}
public IComponentCfg Clone()
{
return new EntryFormCfg(Factory, Name, ProtocolTitle1, ProtocolTitle2, ProtocolTitle3);
}
public string ToString(int i)
{
return string.Empty;
}
public TBF.Entities.Component CreateDbEntity()
{
using (var writer = new StringWriter())
{
(new XmlSerializer(GetType())).Serialize(writer, this);
return Entities.Component.CreateFromCfg(Name, Factory.ClassName, ParentName, ItemNr, DebugLevel, LogLevel, writer.ToString());
}
}
public static IComponentCfg CreateFromDbEntity(Entities.Component component, IComponentFactory factory)
{
using (var reader = new StringReader(component.Parameters))
{
EntryFormCfg config = (EntryFormCfg)(new XmlSerializer(typeof(EntryFormCfg))).Deserialize(reader);
config.InitCfgBaseFromEntity(component, factory);
return config;
}
}
}
}