ActionBase IActionVisitor <XElement, ActionBase> .Visit(ActionWith action, XElement xAction) { var xActions = xAction.Element("actions"); if (xActions != null) { XAction.FromXml(xActions, action.Actions); } return(action); }
ActionBase IActionVisitor <XElement, ActionBase> .Visit(ActionDefineFunction action, XElement xAction) { var xArgs = xAction.RequiredElement("args"); var xActions = xAction.Element("actions"); action.Name = xAction.RequiredStringAttribute("name"); foreach (var xArg in xArgs.Elements()) { action.Args.Add(xArg.RequiredStringAttribute("value")); } if (xActions != null) { XAction.FromXml(xActions, action.Actions); } return(action); }
ActionBase IActionVisitor <XElement, ActionBase> .Visit(ActionTry action, XElement xAction) { var xReserved = xAction.Attribute("reserved"); var xCatchReg = xAction.Attribute("catchReg"); var xCatchName = xAction.Attribute("catchName"); var xTry = xAction.Element("try"); var xCatch = xAction.Element("catch"); var xFinally = xAction.Element("finally"); if (xReserved != null) { action.Reserved = byte.Parse(xReserved.Value); } if (xCatchReg != null && xCatchName == null) { action.CatchInRegister = true; action.CatchRegister = byte.Parse(xCatchReg.Value); } else if (xCatchReg == null && xCatchName != null) { action.CatchInRegister = false; action.CatchName = xCatchName.Value; } else if (xCatchReg != null && xCatchName != null) { throw new InvalidOperationException("catchReg and catchName are mutally exclusive"); } else { throw new InvalidOperationException("Either catchReg or catchName must be specified"); } XAction.FromXml(xTry, action.Try); if (xCatch != null) { action.CatchBlock = true; XAction.FromXml(xCatch, action.Catch); } if (xFinally != null) { action.FinallyBlock = true; XAction.FromXml(xFinally, action.Finally); } return(action); }