コード例 #1
0
        public void setValueWithData(SimCapiData data)
        {
            switch (_type)
            {
            case SimCapiValueType.NUMBER:
            {
                NumberData numberData = (NumberData)_value;

                float?value = data.getNumber();

                if (value == null)
                {
                    SimCapiConsole.log("Cannot set " + _type.ToString() + " with " + data.GetType().ToString());
                }
                else
                {
                    numberData.value = value.Value;
                }

                break;
            }

            case SimCapiValueType.ARRAY:
            {
                ArrayData arrayData = (ArrayData)_value;

                string[] value = data.getStringArray();

                if (value == null)
                {
                    SimCapiConsole.log("Cannot set " + _type.ToString() + " with " + data.GetType().ToString());
                }
                else
                {
                    arrayData.value = value;
                }

                break;
            }

            case SimCapiValueType.BOOLEAN:
            {
                BoolData boolData = (BoolData)_value;

                bool?value = data.getBool();

                if (value == null)
                {
                    SimCapiConsole.log("Cannot set " + _type.ToString() + " with " + data.GetType().ToString());
                }
                else
                {
                    boolData.value = value.Value;
                }

                break;
            }

            case SimCapiValueType.STRING:
            case SimCapiValueType.ENUM:
            case SimCapiValueType.MATH_EXPR:
            case SimCapiValueType.ARRAY_POINT:
            {
                StringData stringData = (StringData)_value;
                stringData.value = data.ToString();
                break;
            }
            }
        }