/// /// Copyright (c) 2020 Sensus Slovensko a.s. /// using System; using System.Collections.Generic; using System.Xml.Serialization; using Config.Entities; using TBF.BenchControl.Generic; using TBF.Resources; namespace TBF.BenchControl.TestMethods.FixedStartMassCollAdvanced { /// /// Holds backup and security options - serializable configuration. /// public class TestMethodCfg : ComponentCfgBase, Generic.IComponentCfg, Config.Entities.IParamsProvider { public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(TestMethodCfg) })[0]; public override XmlSerializer GetSerializer() { return Serializer; } public IComponentCfgCtrl GetControl(IList cmpntEntities) { return new Configs.ParamsProvider.ComponentCfgCtrl(this, null); } /// /// Serialized parameters /// public bool DataEntryInTransBefore; /// Private parameterless constructor invoked by all other (public) constructors TestMethodCfg() {} public TestMethodCfg(string name, IComponentFactory factory) : this() { Name = name; Factory = factory; ParentName = string.Empty; InitializeAll(); } public string ComponentName { get { return Name; } } public void InitializeAll() { DataEntryInTransBefore = false; } string[] paramNames = new string[] { "Data entry form is displayed in transition before test", }; public string ParamName(int i) { return paramNames[i]; } public int ParamsCount() { return paramNames.Length; } public ICollection ParamValues(int i) { return null; } public string ToString(int i) { if (i == -1) { return string.Format("{0}: DataEntryInTransitionBefore = {1}", Name, DataEntryInTransBefore); } switch (i) { case 0: return DataEntryInTransBefore ? Strings.yes : Strings.no; default: return string.Empty; } } public CfgUpdateFlags UpdateParam(int i, string strValue) { switch (i) { case 0: DataEntryInTransBefore = (strValue == Strings.yes); return CfgUpdateFlags.RestartRqrd; default: return CfgUpdateFlags.None; } } public bool ValidateParam(int i, string strValue, out string message) { message = string.Empty; switch (i) { case 0: /// Real number between 0.8 and 1.2 expected if (strValue == Strings.yes || strValue == Strings.no) return true; break; default: message = "Invalid index"; return false; } message = ParamName(i) + " is invalid"; return false; } void CopyContentTo(TestMethodCfg prms) { prms.DataEntryInTransBefore = this.DataEntryInTransBefore; } public Config.Entities.IParamsProvider Clone() { TestMethodCfg pars = new TestMethodCfg(); CopyContentTo(pars); return pars; } public bool UpdateEmbeddedDbEntity() { return true; /// =OK, do nothing } } }