56 lines
1.4 KiB
C#
56 lines
1.4 KiB
C#
|
|
using System;
|
|||
|
|
using System.IO;
|
|||
|
|
using System.Xml.Serialization;
|
|||
|
|
using TBF.BenchControl.Generic;
|
|||
|
|
|
|||
|
|
namespace TBF.BenchControl.BenchId
|
|||
|
|
{
|
|||
|
|
/// <summary>
|
|||
|
|
/// Holds information identifying the test bench - serializable configuration.
|
|||
|
|
/// </summary>
|
|||
|
|
public class ComponentCfg : ComponentCfgBase, Generic.IComponentCfg
|
|||
|
|
{
|
|||
|
|
public int TestBenchNr;
|
|||
|
|
|
|||
|
|
/// Parameterless constructor
|
|||
|
|
public ComponentCfg()
|
|||
|
|
{
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public ComponentCfg(IComponentFactory factory, string name, int testBenchNr)
|
|||
|
|
: base(factory, name)
|
|||
|
|
{
|
|||
|
|
TestBenchNr = testBenchNr;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public IComponentCfg Clone()
|
|||
|
|
{
|
|||
|
|
return new ComponentCfg(Factory, Name, TestBenchNr);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public string ToString(int i)
|
|||
|
|
{
|
|||
|
|
return string.Format("TestBenchNr = {0}", TestBenchNr);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
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))
|
|||
|
|
{
|
|||
|
|
ComponentCfg config = (ComponentCfg)(new XmlSerializer(typeof(ComponentCfg))).Deserialize(reader);
|
|||
|
|
config.InitCfgBaseFromEntity(component, factory);
|
|||
|
|
return config;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|