using System; using System.IO; using System.Xml.Serialization; using TBF.BenchControl.Generic; namespace TBF.BenchControl.ResultsPrinters.Basic { public class PrinterCfg : ComponentCfgBase, Generic.IComponentCfg { /// Parameterless constructor public PrinterCfg() { } /// /// Basic results printer configuration parameters /// /// BasicPrinter factory /// Printer name public PrinterCfg(IComponentFactory factory, string name) : base(factory, name) { } public IComponentCfg Clone() { return new PrinterCfg(Factory, Name); } 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)) { PrinterCfg config = (PrinterCfg)(new XmlSerializer(typeof(PrinterCfg))).Deserialize(reader); config.InitCfgBaseFromEntity(component, factory); return config; } } } }