Пример #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);
 }
Пример #3
0
			public String2Enumerator(ConstantType par) 
			{
				parent = par;
				nIndex = -1;
			}
Пример #4
0
			public Float2Enumerator(ConstantType par) 
			{
				parent = par;
				nIndex = -1;
			}
Пример #5
0
			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);
 }
Пример #8
0
		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;
 }