124 lines
3.1 KiB
C#
124 lines
3.1 KiB
C#
///
|
|
/// Copyright (c) 2023 Sensus Slovensko a.s.
|
|
///
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Xml.Serialization;
|
|
using Common;
|
|
using Config.Entities;
|
|
using TBF.Resources;
|
|
using TBF.Rig.Generic;
|
|
|
|
namespace TBF.Rig.TestMethods.Message
|
|
{
|
|
public class TestMethodCfg : ComponentCfgBase, IChildComponentCfg, IParamsProvider
|
|
{
|
|
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(TestMethodCfg) })[0];
|
|
public override XmlSerializer GetSerializer() { return Serializer; }
|
|
|
|
public IComponentCfgCtrl GetControl(IList<Component> cmpntEntities)
|
|
{
|
|
return new Configs.ParamsProvider.ComponentCfgCtrl(this, null);
|
|
}
|
|
|
|
///
|
|
/// Serialized parameters
|
|
///
|
|
public string MessageStr { get; set; } /// 0
|
|
|
|
/// Private parameterless constructor invoked by all other (public) constructors
|
|
TestMethodCfg() { }
|
|
|
|
public TestMethodCfg(string name, IComponentFactory factory)
|
|
: this()
|
|
{
|
|
this.Name = name;
|
|
this.Factory = factory;
|
|
InitializeAll();
|
|
}
|
|
|
|
public string ComponentName { get { return Name; } }
|
|
|
|
public void InitializeAll()
|
|
{
|
|
MessageStr = "Trať je zavodnená";
|
|
}
|
|
|
|
string[] paramNames = new string[]
|
|
{
|
|
"Message", /// 0
|
|
};
|
|
public string ParamName(int i) { return paramNames[i]; }
|
|
public int ParamsCount() { return paramNames.Length; }
|
|
|
|
public ICollection<string> ParamValues(int i)
|
|
{
|
|
switch (i)
|
|
{
|
|
case 0:
|
|
default:
|
|
return null;
|
|
}
|
|
}
|
|
|
|
|
|
public string ToString(int i)
|
|
{
|
|
switch (i)
|
|
{
|
|
case 0:
|
|
return MessageStr;
|
|
default:
|
|
return string.Format("{0} message = {1}", Name, MessageStr);
|
|
}
|
|
}
|
|
|
|
public CfgUpdateFlags UpdateParam(int i, string str)
|
|
{
|
|
switch (i)
|
|
{
|
|
case 0:
|
|
MessageStr = str;
|
|
return CfgUpdateFlags.RestartRqrd;
|
|
default:
|
|
return CfgUpdateFlags.None;
|
|
}
|
|
}
|
|
|
|
public bool ValidateParam(int i, string str, out string message)
|
|
{
|
|
message = string.Empty;
|
|
|
|
switch (i)
|
|
{
|
|
case 0:
|
|
return true;
|
|
default:
|
|
message = "Invalid index";
|
|
return false;
|
|
}
|
|
|
|
message = ParamName(i) + " is invalid";
|
|
return false;
|
|
}
|
|
|
|
void CopyContentTo(TestMethodCfg prms)
|
|
{
|
|
prms.MessageStr = MessageStr;
|
|
}
|
|
|
|
public IParamsProvider Clone()
|
|
{
|
|
TestMethodCfg pars = new TestMethodCfg();
|
|
CopyContentTo(pars);
|
|
return pars;
|
|
}
|
|
|
|
public bool UpdateEmbeddedDbEntity()
|
|
{
|
|
return true; /// =OK, do nothing
|
|
}
|
|
}
|
|
}
|