public Value MakeConstant(AiRuleEngine.VariableType type, object value) { Value newValue = new Value(); ConstantType newConstant = new ConstantType(); switch (type) { case AiRuleEngine.VariableType.BOOLEAN: newConstant.AddBoolean(new Altova.Types.SchemaBoolean((bool)value)); break; case AiRuleEngine.VariableType.INT: newConstant.AddInteger(new Altova.Types.SchemaLong((long)(int)value)); break; case AiRuleEngine.VariableType.FLOAT: newConstant.AddFloat2(new Altova.Types.SchemaDecimal((decimal)(float)value)); break; case AiRuleEngine.VariableType.STRING: newConstant.AddString2(new Altova.Types.SchemaString((string)value)); break; } newValue.AddConstant(newConstant); return newValue; }
public void AddConstant(ConstantType newValue) { AppendDomElement("", "Constant", newValue); }
public String2Enumerator(ConstantType par) { parent = par; nIndex = -1; }
public Float2Enumerator(ConstantType par) { parent = par; nIndex = -1; }
public IntegerEnumerator(ConstantType par) { parent = par; nIndex = -1; }
public void InsertValueAt(ConstantType newValue, int index) { InsertDomElementAt("", "Value", index, newValue); }
public void ReplaceValueAt(ConstantType newValue, int index) { ReplaceDomElementAt("", "Value", index, newValue); }
static public object GetValueFromConstant(ConstantType constant) { object result = null; if (constant.HasBoolean()) { result = (bool)constant.GetBoolean().Value; } else if (constant.HasInteger()) { result = (int)constant.GetInteger().Value; } else if (constant.HasFloat2()) { result = (float)constant.GetFloat2().Value; } else if (constant.HasString2()) { result = (string)constant.GetString2().Value; } return result; }
static public ConstantType GetConstantFromValue(VariableType type, object value) { if (value == null) { Debug.LogError("Error null value in GetConstantFromValue"); return null; } ConstantType constantType = new ConstantType(); switch (type) { case VariableType.BOOLEAN: constantType.AddBoolean(new SchemaBoolean((bool)value)); break; case VariableType.FLOAT: constantType.AddFloat2(new SchemaDecimal((decimal)(float)value)); break; case VariableType.INT: constantType.AddInteger(new SchemaLong((long)(int)value)); break; case VariableType.STRING: constantType.AddString2(new SchemaString((string)value)); break; } return constantType; }
static public ConstantType GetConstantFromValue(object value) { if (value == null) { Debug.LogError("Error null value in GetConstantFromValue"); return null; } ConstantType constantType = new ConstantType(); if (value.GetType() == typeof(bool)) { constantType.AddBoolean(new SchemaBoolean((bool)value)); } else if (value.GetType() == typeof(float)) { constantType.AddFloat2(new SchemaDecimal((decimal)(float)value)); } else if (value.GetType() == typeof(int)) { long longValue = (long)(int)value; constantType.AddInteger(new SchemaLong(longValue)); } else if (value.GetType() == typeof(string)) { constantType.AddString2(new SchemaString((string)value)); } else { string objectString; if (ObjectToString(value, out objectString)) constantType.AddString2(new SchemaString(objectString)); else constantType.AddString2(new SchemaString(value.GetType().ToString())); } return constantType; }
public void AddValue(ConstantType newValue) { AppendDomElement("", "Value", newValue); }
static public object GetValueFromConstant(VariableType type, ConstantType constant) { object result = null; if (constant.HasBoolean()) { bool boolValue = (bool)constant.GetBoolean().Value; switch(type) { case VariableType.BOOLEAN: result = boolValue; break; case VariableType.INT: result = (int)(boolValue ? 1 : 0); break; case VariableType.FLOAT: result = (float)(boolValue ? 1 : 0); break; case VariableType.STRING: result = (boolValue ? "true" : "false"); break; } } else if (constant.HasInteger()) { int intValue = (int)constant.GetInteger().Value; switch(type) { case VariableType.BOOLEAN: result = (intValue == 1) ? true : false; break; case VariableType.INT: result = intValue; break; case VariableType.FLOAT: result = intValue; break; case VariableType.STRING: result = intValue.ToString(); break; } } else if (constant.HasFloat2()) { float floatValue = (float)constant.GetFloat2().Value; switch(type) { case VariableType.BOOLEAN: result = (floatValue == 1) ? true : false; break; case VariableType.INT: result = (int)floatValue; break; case VariableType.FLOAT: result = floatValue; break; case VariableType.STRING: result = floatValue.ToString(); break; } } else if (constant.HasString2()) { string stringValue = constant.GetString2().Value; switch(type) { case VariableType.BOOLEAN: result = (stringValue == "true") ? true : false; break; case VariableType.STRING: result = stringValue; break; case VariableType.INT: result = stringValue; break; case VariableType.FLOAT: result = Convert.ToSingle(stringValue); break; } } return result; }
public BooleanEnumerator(ConstantType par) { parent = par; nIndex = -1; }