Пример #1
0
        public void Assign(IValue value, Int32 number = 0)
        {
            switch (value.DataType)
            {
            case DataType.String:
                String str = value.AsString();
                NativeApiProxy.SetVariantStr(variant, number, str, str.Length);
                break;

            case DataType.Boolean:
                NativeApiProxy.SetVariantBool(variant, number, value.AsBoolean());
                break;

            case DataType.Number:
                Decimal num = value.AsNumber();
                if (num % 1 == 0)
                {
                    NativeApiProxy.SetVariantInt(variant, number, Convert.ToInt32(value.AsNumber()));
                }
                else
                {
                    NativeApiProxy.SetVariantReal(variant, number, Convert.ToDouble(value.AsNumber()));
                }
                break;

            case DataType.Object when value.AsObject() is BinaryDataContext binaryData:
                NativeApiProxy.SetVariantBlob(variant, number, binaryData.Buffer, binaryData.Buffer.Length);

                break;

            default:
                NativeApiProxy.SetVariantEmpty(variant, number);
                break;
            }
        }