public TestEntity(ScriptObj script, string fullName) { Script = script; FullName = fullName; FileInfo f = new FileInfo(fullName); if (f.Exists) Name = f.Name.Replace(StaticFields.SCRIPT_EXTENTION, string.Empty); }
private SaveData() { CopyStepEntities = new ScriptObj(); CopyTestEntities = new TestObj(); Test = new TestObj(); Script = new ScriptObj(); TestSuite = new TestSuite(); ClientMessages = new ObservableCollection<AutomationCommon.ClientMessage>(); }
//public TestEntity ActiveScriptEntity1 { get; set; } //public int LableIndex1 { get; set; } //public string LableName { get; set; } //public bool ActivateGoTo1() //{ // return LableIndex1 != -1; //} //private FlowHandler() //{ // LableIndex1 = -1; //} //public bool FindLableIndex1(string lable) //{ // LableName = lable; // StepEntity s; // for (int i = 0; i < ActiveScriptEntity.Script.Entities.Count; i++) // { // s = ActiveScriptEntity.Script.Entities[i]; // if (s.Action.TypeId == Enums.ActionTypeId.Lable) // { // if (((LabelAction)s.Action)._type == LabelAction.ActionType.Create) // { // if (((LabelAction)s.Action)._actionData.LableName == lable) // { // LableIndex1 = i; // return true; // } // } // } // } // return false; //} public void FindLableIndex(string lable, ScriptObj scriptObj) { StepEntity s; for (int i = 0; i < scriptObj.Entities.Count; i++) { s = scriptObj.Entities[i]; if (s.Action.TypeId == Enums.ActionTypeId.Lable) { if (((LabelAction)s.Action)._type == LabelAction.ActionType.Create) { if (((LabelAction)s.Action)._actionData.LableName == lable) { scriptObj.NextepIndex = i; return; } } } } AutoApp.Logger.WriteFailLog(string.Format("Label {0} was not found ")); scriptObj.NextepIndex = -1; }
public static ScriptObj ExtructScriptFromFile(string fileName) { string detail = string.Empty; if (string.IsNullOrEmpty(fileName)) return null; if (!File.Exists(fileName)) { return null; } ScriptObj script = new ScriptObj(); ActionBase action = null; StepEntity stepEntity = null; using (XmlReader reader = XmlReader.Create(fileName)) // using (XmlReader reader =XmlReader.Create(new StreamReader(fileName, Encoding.GetEncoding("ISO-8859-9")))) { while (reader.Read()) { // Only detect start elements. if (reader.IsStartElement()) { switch (reader.Name) { case "Script": script = new ScriptObj(); break; case "Enable": stepEntity.Enable = bool.Parse(reader.ReadInnerXml()); break; case "Description": detail = reader.ReadInnerXml(); detail = detail.Replace("&", "&").Replace("<", "<").Replace(">", ">");//encode special characters -The characters &, <, and > are replaced with &, <, and >, respectively script.Description = detail; break; case "Step": if (stepEntity != null) { stepEntity.Action = action; stepEntity.Action.Construct(); script.Entities.Add(stepEntity); } stepEntity = new StepEntity(action); break; case "OnFailureLable": stepEntity.OnFailureLabel = reader.ReadInnerXml(); break; case "Comment": detail = reader.ReadInnerXml(); detail = detail.Replace("&", "&").Replace("<", "<").Replace(">", ">");//encode special characters -The characters &, <, and > are replaced with &, <, and >, respectively stepEntity.Comment = detail; break; case "ID": var id = Enum.Parse(typeof(Enums.ActionTypeId), reader.ReadInnerXml().ToString()); action = ActionFactory.GetAction((Enums.ActionTypeId)id); break; case "Name": action.Name = reader.ReadInnerXml(); break; case "Detail": detail = reader.ReadInnerXml(); detail = detail.Replace("&", "&").Replace("<", "<").Replace(">", ">");//encode special characters -The characters &, <, and > are replaced with &, <, and >, respectively action.Details.Add(detail); break; } } } } //adding the last step entity if (action != null) { stepEntity.Action = action; stepEntity.Action.Construct(); script.Entities.Add(stepEntity); } return script; }
public void SaveToMemento(ScriptObj script) { _mementoStack.Push(new MementoScript(script)); }
public MementoScript(ScriptObj stateToSave) { SavedState = new ScriptObj(); foreach (var entity in stateToSave.Entities) SavedState.Entities.Add(entity); }