public override TVariable Convert(XmlUserVariable o, XmlModelConvertContext c) { var variable = (TVariable)Activator.CreateInstance(typeof(TVariable)); variable.Name = o.Name; return(variable); }
private static string GetVariableReferenceString(XmlUserVariableReference xmlUserVariableReference) { XmlUserVariable var = xmlUserVariableReference.UserVariable; if (XmlParserTempProjectHelper.inObjectVarList) { return(GetStepDownString(5) + XmlConstants.ObjectList + "/" + XmlConstants.Object + GetReferenceNumeration(var.ObjectNum) + "/" + XmlConstants.ScriptList + "/" + XmlConstants.Script + GetReferenceNumeration(var.ScriptNum) + "/" + XmlConstants.BrickList + "/" + XmlConstants.Brick + GetReferenceNumeration(var.BrickNum) + "/" + XmlConstants.UserVariable + GetReferenceNumeration(var.VariableNum)); } else if (XmlParserTempProjectHelper.inProgramVarList) { return(GetStepDownString(3) + XmlConstants.ObjectList + "/" + XmlConstants.Object + GetReferenceNumeration(var.ObjectNum) + "/" + XmlConstants.ScriptList + "/" + XmlConstants.Script + GetReferenceNumeration(var.ScriptNum) + "/" + XmlConstants.BrickList + "/" + XmlConstants.Brick + GetReferenceNumeration(var.BrickNum) + "/" + XmlConstants.UserVariable + GetReferenceNumeration(var.VariableNum)); } else if (xmlUserVariableReference.UserVariable.ObjectNum != XmlParserTempProjectHelper.currentObjectNum) { return(GetStepDownString(6) + XmlConstants.Object + GetReferenceNumeration(var.ObjectNum) + "/" + XmlConstants.ScriptList + "/" + XmlConstants.Script + GetReferenceNumeration(var.ScriptNum) + "/" + XmlConstants.BrickList + "/" + XmlConstants.Brick + GetReferenceNumeration(var.BrickNum) + "/" + XmlConstants.UserVariable + GetReferenceNumeration(var.VariableNum)); } else if (xmlUserVariableReference.UserVariable.ScriptNum != XmlParserTempProjectHelper.currentScriptNum) { return(GetStepDownString(4) + XmlConstants.Script + GetReferenceNumeration(var.ScriptNum) + "/" + XmlConstants.Brick + GetReferenceNumeration(var.BrickNum) + "/" + XmlConstants.UserVariable + GetReferenceNumeration(var.VariableNum)); } else if (xmlUserVariableReference.UserVariable.BrickNum != XmlParserTempProjectHelper.currentBrickNum) { return(GetStepDownString(2) + XmlConstants.Brick + GetReferenceNumeration(var.BrickNum) + "/" + XmlConstants.UserVariable + GetReferenceNumeration(var.VariableNum)); } else if (xmlUserVariableReference.UserVariable.VariableNum != XmlParserTempProjectHelper.currentVariableNum) { return(GetStepDownString(1) + XmlConstants.UserVariable + GetReferenceNumeration(var.VariableNum)); } else { return("the ReferenceHelper is not working properly!"); } }
private static XmlFormulaTree CreateVariableNode(XmlUserVariable variable) { return(new XmlFormulaTree { VariableType = "USER_VARIABLE", VariableValue = variable != null ? variable.Name : null, LeftChild = null, RightChild = null }); }
internal override void LoadFromXml(XElement xRoot) { if (xRoot != null) { VariableFormula = new XmlFormula(xRoot, XmlConstants.VariableChange); if (xRoot.Element(XmlConstants.UserVariable) != null) { UserVariable = new XmlUserVariable(xRoot.Element(XmlConstants.UserVariable)); } } }
public override XmlSetVariableBrick Convert1(SetVariableBrick m, XmlModelConvertBackContext c) { var formulaConverter = new FormulaConverter(); XmlUserVariable variable = null; if (m.Variable != null) { c.Variables.TryGetValue(m.Variable, out variable); } return(new XmlSetVariableBrick { UserVariable = variable, VariableFormula = m.Value == null ? new XmlFormula() : formulaConverter.Convert(m.Value, c) }); }
public static XmlFormulaTree CreateGlobalVariableNode(XmlUserVariable variable) { return(CreateVariableNode(variable)); }