示例#1
0
        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;
        }
示例#2
0
 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;
			}
示例#6
0
 public IntegerEnumerator(ConstantType par)
 {
     parent = par;
     nIndex = -1;
 }
示例#7
0
 public void InsertValueAt(ConstantType newValue, int index)
 {
     InsertDomElementAt("", "Value", index, newValue);
 }
		public void ReplaceValueAt(ConstantType newValue, int index)
		{
			ReplaceDomElementAt("", "Value", index, newValue);
		}
示例#9
0
        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;
        }
示例#10
0
		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;
		}
示例#11
0
        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;
        }
示例#12
0
 public String2Enumerator(ConstantType par)
 {
     parent = par;
     nIndex = -1;
 }
示例#13
0
 public Float2Enumerator(ConstantType par)
 {
     parent = par;
     nIndex = -1;
 }
示例#14
0
		public void AddValue(ConstantType newValue)
		{
			AppendDomElement("", "Value", newValue);
		}
示例#15
0
		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;
		}
示例#16
0
		public void InsertValueAt(ConstantType newValue, int index)
		{
			InsertDomElementAt("", "Value", index, newValue);
		}
示例#17
0
		public void AddConstant(ConstantType newValue)
		{
			AppendDomElement("", "Constant", newValue);
		}
示例#18
0
 public void AddValue(ConstantType newValue)
 {
     AppendDomElement("", "Value", newValue);
 }
示例#19
0
			public BooleanEnumerator(ConstantType par) 
			{
				parent = par;
				nIndex = -1;
			}
示例#20
0
 public void ReplaceValueAt(ConstantType newValue, int index)
 {
     ReplaceDomElementAt("", "Value", index, newValue);
 }
示例#21
0
 public BooleanEnumerator(ConstantType par)
 {
     parent = par;
     nIndex = -1;
 }