52 lines
1.4 KiB
C#
52 lines
1.4 KiB
C#
using System.IO;
|
|
using System.Xml.Serialization;
|
|
using TBF.BenchControl.Generic;
|
|
|
|
namespace TBF.BenchControl.Elde.Diverter
|
|
{
|
|
public class DiverterCfg : ComponentCfgBase, IChildComponentCfg
|
|
{
|
|
public int BitPosition;
|
|
|
|
/// Parameterless constructor
|
|
public DiverterCfg()
|
|
{
|
|
}
|
|
/// Constructor
|
|
public DiverterCfg(IComponentFactory factory, string name, string parentName, int bitPosition)
|
|
: base(factory, name, parentName)
|
|
{
|
|
this.BitPosition = bitPosition;
|
|
}
|
|
|
|
public IComponentCfg Clone()
|
|
{
|
|
return new DiverterCfg(Factory, Name, ParentName, BitPosition);
|
|
}
|
|
|
|
public string ToString(int i)
|
|
{
|
|
return string.Format("bit={0}", BitPosition);
|
|
}
|
|
|
|
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))
|
|
{
|
|
DiverterCfg config = (DiverterCfg)(new XmlSerializer(typeof(DiverterCfg))).Deserialize(reader);
|
|
config.InitCfgBaseFromEntity(component, factory);
|
|
return config;
|
|
}
|
|
}
|
|
}
|
|
}
|