ctrlX Data Layer API for .NET 5  2.1.0
Variant.cs
1 using Datalayer.Internal;
2 using FlatBuffers;
3 using System;
4 using System.Collections;
5 using System.Diagnostics;
6 using System.Runtime.InteropServices;
7 using System.Text;
8 
9 namespace Datalayer
10 {
14  [DebuggerDisplay("{Value}")]
15  public class Variant : IVariant, INative
16  {
17  // Fields
18  private readonly bool _skipDelete;
19  private unsafe void* _nativePtr;
20  private readonly DateTime _timestamp = DateTime.Now;
21 
22  #region Internal Constructors
23 
34  internal unsafe Variant(void* nativePtr)
35  {
36  _nativePtr = nativePtr;
37  _skipDelete = true;
38  }
39 
40  #endregion
41 
42  #region Internal Properties
43 
47  internal unsafe bool IsNullPtr => _nativePtr == null;
48 
53  unsafe void* INative.NativePtr => _nativePtr;
54 
55  #endregion
56 
57  #region Disposing
58 
62  public bool IsDisposed { get; private set; }
63 
68  protected virtual void Dispose(bool disposing)
69  {
70  if (!IsDisposed)
71  {
72  if (disposing)
73  {
74  // dispose managed state (managed objects)
75  }
76 
77  // free unmanaged resources (unmanaged objects) and override finalizer
78  Delete();
79  // set large fields to null
80  IsDisposed = true;
81  }
82  }
83 
87  private void Delete()
88  {
89  unsafe
90  {
91  if (_skipDelete)
92  {
93  _nativePtr = null;
94  return;
95  }
96 
97  NativeMethods.Datalayer.DLR_variantDelete(_nativePtr);
98  _nativePtr = null;
99  }
100  }
101 
105  ~Variant()
106  {
107  // Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method
108  Dispose(disposing: false);
109  }
110 
114  public void Dispose()
115  {
116  // Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method
117  Dispose(disposing: true);
118  GC.SuppressFinalize(this);
119  }
120 
121  #endregion
122 
123  #region Public Constructors
124 
128  public Variant()
129  {
130  unsafe
131  {
132  _nativePtr = NativeMethods.Datalayer.DLR_variantCreate();
133  }
134  }
135 
141  public Variant(IVariant other)
142  : this()
143  {
144  if (other == null)
145  {
146  throw new ArgumentNullException(nameof(other));
147  }
148 
149  unsafe
150  {
151  if (NativeMethods.Datalayer.DLR_variantCopy(_nativePtr, other.ToNativePtr()).IsBad())
152  {
153  throw new InvalidOperationException(Utils.Strings.ErrorObjectNotCreatable);
154  }
155  }
156  }
157 
163  public Variant(bool value)
164  : this()
165  {
166  if (SetBool(value).IsBad())
167  {
168  throw new InvalidOperationException(Utils.Strings.ErrorObjectNotCreatable);
169  }
170  }
171 
178  public Variant(string value)
179  : this()
180  {
181  if (SetString(value).IsBad())
182  {
183  throw new InvalidOperationException(Utils.Strings.ErrorObjectNotCreatable);
184  }
185  }
186 
192  public Variant(sbyte value)
193  : this()
194  {
195  if (SetInt8(value).IsBad())
196  {
197  throw new InvalidOperationException(Utils.Strings.ErrorObjectNotCreatable);
198  }
199  }
200 
206  public Variant(short value)
207  : this()
208  {
209  if (SetInt16(value).IsBad())
210  {
211  throw new InvalidOperationException(Utils.Strings.ErrorObjectNotCreatable);
212  }
213  }
214 
220  public Variant(int value)
221  : this()
222  {
223  if (SetInt32(value).IsBad())
224  {
225  throw new InvalidOperationException(Utils.Strings.ErrorObjectNotCreatable);
226  }
227  }
228 
234  public Variant(long value)
235  : this()
236  {
237  if (SetInt64(value).IsBad())
238  {
239  throw new InvalidOperationException(Utils.Strings.ErrorObjectNotCreatable);
240  }
241  }
242 
248  public Variant(byte value)
249  : this()
250  {
251  if (SetUInt8(value).IsBad())
252  {
253  throw new InvalidOperationException(Utils.Strings.ErrorObjectNotCreatable);
254  };
255  }
256 
262  public Variant(ushort value)
263  : this()
264  {
265  if (SetUInt16(value).IsBad())
266  {
267  throw new InvalidOperationException(Utils.Strings.ErrorObjectNotCreatable);
268  }
269  }
270 
276  public Variant(uint value)
277  : this()
278  {
279  if (SetUInt32(value).IsBad())
280  {
281  throw new InvalidOperationException(Utils.Strings.ErrorObjectNotCreatable);
282  }
283  }
284 
290  public Variant(ulong value)
291  : this()
292  {
293  if (SetUInt64(value).IsBad())
294  {
295  throw new InvalidOperationException(Utils.Strings.ErrorObjectNotCreatable);
296  }
297  }
298 
304  public Variant(float value)
305  : this()
306  {
307  if (SetFloat32(value).IsBad())
308  {
309  throw new InvalidOperationException(Utils.Strings.ErrorObjectNotCreatable);
310  }
311  }
312 
318  public Variant(double value)
319  : this()
320  {
321  if (SetFloat64(value).IsBad())
322  {
323  throw new InvalidOperationException(Utils.Strings.ErrorObjectNotCreatable);
324  }
325  }
326 
333  public Variant(bool[] value)
334  : this()
335  {
336  if (SetArrayOfBool(value).IsBad())
337  {
338  throw new InvalidOperationException(Utils.Strings.ErrorObjectNotCreatable);
339  }
340  }
341 
348  public Variant(string[] value)
349  : this()
350  {
351  if (SetArrayOfString(value).IsBad())
352  {
353  throw new InvalidOperationException(Utils.Strings.ErrorObjectNotCreatable);
354  }
355  }
356 
363  public Variant(sbyte[] value)
364  : this()
365  {
366  if (SetArrayOfInt8(value).IsBad())
367  {
368  throw new InvalidOperationException(Utils.Strings.ErrorObjectNotCreatable);
369  }
370  }
371 
378  public Variant(short[] value)
379  : this()
380  {
381  if (SetArrayOfInt16(value).IsBad())
382  {
383  throw new InvalidOperationException(Utils.Strings.ErrorObjectNotCreatable);
384  }
385  }
386 
393  public Variant(int[] value)
394  : this()
395  {
396  if (SetArrayOfInt32(value).IsBad())
397  {
398  throw new InvalidOperationException(Utils.Strings.ErrorObjectNotCreatable);
399  }
400  }
401 
408  public Variant(long[] value)
409  : this()
410  {
411  if (SetArrayOfInt64(value).IsBad())
412  {
413  throw new InvalidOperationException(Utils.Strings.ErrorObjectNotCreatable);
414  }
415  }
416 
423  public Variant(byte[] value)
424  : this()
425  {
426  if (SetArrayOfUInt8(value).IsBad())
427  {
428  throw new InvalidOperationException(Utils.Strings.ErrorObjectNotCreatable);
429  }
430  }
431 
438  public Variant(ushort[] value)
439  : this()
440  {
441  if (SetArrayOfUInt16(value).IsBad())
442  {
443  throw new InvalidOperationException(Utils.Strings.ErrorObjectNotCreatable);
444  }
445  }
446 
453  public Variant(uint[] value)
454  : this()
455  {
456  if (SetArrayOfUInt32(value).IsBad())
457  {
458  throw new InvalidOperationException(Utils.Strings.ErrorObjectNotCreatable);
459  }
460  }
461 
468  public Variant(ulong[] value)
469  : this()
470  {
471  if (SetArrayOfUInt64(value).IsBad())
472  {
473  throw new InvalidOperationException(Utils.Strings.ErrorObjectNotCreatable);
474  }
475  }
476 
483  public Variant(float[] value)
484  : this()
485  {
486  if (SetArrayOfFloat32(value).IsBad())
487  {
488  throw new InvalidOperationException(Utils.Strings.ErrorObjectNotCreatable);
489  }
490  }
491 
498  public Variant(double[] value)
499  : this()
500  {
501  if (SetArrayOfFloat64(value).IsBad())
502  {
503  throw new InvalidOperationException(Utils.Strings.ErrorObjectNotCreatable);
504  }
505  }
506 
513  public Variant(ByteBuffer flatBuffers)
514  : this()
515  {
516  if (SetFlatbuffers(flatBuffers).IsBad())
517  {
518  throw new InvalidOperationException(Utils.Strings.ErrorObjectNotCreatable);
519  }
520  }
521 
528  public Variant(FlatBufferBuilder builder)
529  : this()
530  {
531  if (builder == null)
532  {
533  throw new ArgumentNullException(nameof(builder));
534  }
535 
536  if (SetFlatbuffers(builder.DataBuffer).IsBad())
537  {
538  throw new InvalidOperationException(Utils.Strings.ErrorObjectNotCreatable);
539  }
540  }
541 
542  #endregion
543 
544  #region Public Overrides
545 
551  public override bool Equals(object obj)
552  {
553  return Equals(obj as Variant);
554  }
555 
562  public bool Equals(Variant other)
563  {
564  if (!(other is Variant))
565  {
566  return false;
567  }
568 
569  if (ReferenceEquals(this, other))
570  {
571  return true;
572  }
573 
574  var dataType = DataType;
575  if (dataType != other.DataType)
576  {
577  return false;
578  }
579 
580  //Arrays
581  if (Utils.IsArray(dataType))
582  {
583  return StructuralComparisons.StructuralEqualityComparer.Equals(Value, other.Value);
584  }
585 
586  //Flatbuffers
587  if (dataType == DLR_VARIANT_TYPE.DLR_VARIANT_TYPE_FLATBUFFERS)
588  {
589  return StructuralComparisons.StructuralEqualityComparer.Equals(ToFlatbuffers().ToSizedArray(), other.ToFlatbuffers().ToSizedArray());
590  }
591 
592  //Scalars
593  return Equals(Value, other.Value);
594  }
595 
600  public override int GetHashCode()
601  {
602  var v = Value;
603  return v != null ? base.GetHashCode() ^ v.GetHashCode() : base.GetHashCode();
604  }
605 
611  public override string ToString()
612  {
613  if (IsDisposed)
614  {
615  throw new ObjectDisposedException(Utils.Strings.ErrorObjectDisposed);
616  }
617 
618  if (IsNull)
619  {
620  return string.Empty;
621  }
622 
623  unsafe
624  {
625  var length = Convert.ToInt32(GetSize().ToUInt32()) - 1;
626  if (length <= 0)
627  {
628  return string.Empty;
629  }
630  return Utils.ToString(NativeMethods.Datalayer.DLR_variantGetSTRING(_nativePtr), length);
631  }
632  }
633 
640  public static bool operator ==(Variant x, Variant y)
641  {
642  //x not null
643  if (x is Variant)
644  {
645  return x.Equals(y);
646  }
647 
648  //y not null
649  if (y is Variant)
650  {
651  return y.Equals(x);
652  }
653 
654  //Both null
655  return true;
656  }
657 
664  public static bool operator !=(Variant x, Variant y)
665  {
666  //x not null
667  if (x is Variant)
668  {
669  return !x.Equals(y);
670  }
671 
672  //y not null
673  if (y is Variant)
674  {
675  return !y.Equals(x);
676  }
677 
678  //Both null
679  return false;
680  }
681 
682  #endregion
683 
684  #region Public Statics
685 
689  public static readonly int DefaultFlatbuffersInitialSize = 1024;
690 
694  public static readonly Variant Null = new();
695 
699  public static readonly Variant Zero = new(0);
700 
704  public static readonly Variant One = new(1);
705 
709  public static readonly Variant Empty = new(string.Empty);
710 
714  public static readonly Variant True = new(true);
715 
719  public static readonly Variant False = new(false);
720 
721  #endregion
722 
723  #region Public Getters
724 
729  public DateTime Timestamp
730  {
731  get
732  {
733  if (IsDisposed)
734  {
735  throw new ObjectDisposedException(Utils.Strings.ErrorObjectDisposed);
736  }
737 
738  return _timestamp;
739  }
740  }
741 
746  public object Value
747  {
748  get
749  {
750  if (IsDisposed)
751  {
752  throw new ObjectDisposedException(Utils.Strings.ErrorObjectDisposed);
753  }
754 
755  return DataType switch
756  {
757  DLR_VARIANT_TYPE.DLR_VARIANT_TYPE_BOOL8 => ToBool(),
758  DLR_VARIANT_TYPE.DLR_VARIANT_TYPE_INT8 => ToSByte(),
759  DLR_VARIANT_TYPE.DLR_VARIANT_TYPE_UINT8 => ToByte(),
760  DLR_VARIANT_TYPE.DLR_VARIANT_TYPE_INT16 => ToInt16(),
761  DLR_VARIANT_TYPE.DLR_VARIANT_TYPE_UINT16 => ToUInt16(),
762  DLR_VARIANT_TYPE.DLR_VARIANT_TYPE_INT32 => ToInt32(),
763  DLR_VARIANT_TYPE.DLR_VARIANT_TYPE_UINT32 => ToUInt32(),
764  DLR_VARIANT_TYPE.DLR_VARIANT_TYPE_INT64 => ToInt64(),
765  DLR_VARIANT_TYPE.DLR_VARIANT_TYPE_UINT64 => ToUInt64(),
766  DLR_VARIANT_TYPE.DLR_VARIANT_TYPE_FLOAT32 => ToFloat(),
767  DLR_VARIANT_TYPE.DLR_VARIANT_TYPE_FLOAT64 => ToDouble(),
768  DLR_VARIANT_TYPE.DLR_VARIANT_TYPE_STRING => ToString(),
769  DLR_VARIANT_TYPE.DLR_VARIANT_TYPE_ARRAY_OF_BOOL8 => ToBoolArray(),
770  DLR_VARIANT_TYPE.DLR_VARIANT_TYPE_ARRAY_OF_INT8 => ToSByteArray(),
771  DLR_VARIANT_TYPE.DLR_VARIANT_TYPE_ARRAY_OF_UINT8 => ToByteArray(),
772  DLR_VARIANT_TYPE.DLR_VARIANT_TYPE_ARRAY_OF_INT16 => ToInt16Array(),
773  DLR_VARIANT_TYPE.DLR_VARIANT_TYPE_ARRAY_OF_UINT16 => ToUInt16Array(),
774  DLR_VARIANT_TYPE.DLR_VARIANT_TYPE_ARRAY_OF_INT32 => ToInt32Array(),
775  DLR_VARIANT_TYPE.DLR_VARIANT_TYPE_ARRAY_OF_UINT32 => ToUInt32Array(),
776  DLR_VARIANT_TYPE.DLR_VARIANT_TYPE_ARRAY_OF_INT64 => ToInt64Array(),
777  DLR_VARIANT_TYPE.DLR_VARIANT_TYPE_ARRAY_OF_UINT64 => ToUInt64Array(),
778  DLR_VARIANT_TYPE.DLR_VARIANT_TYPE_ARRAY_OF_FLOAT32 => ToFloatArray(),
779  DLR_VARIANT_TYPE.DLR_VARIANT_TYPE_ARRAY_OF_FLOAT64 => ToDoubleArray(),
780  DLR_VARIANT_TYPE.DLR_VARIANT_TYPE_ARRAY_OF_STRING => ToStringArray(),
781  DLR_VARIANT_TYPE.DLR_VARIANT_TYPE_RAW => ToRawByteArray(),
782  DLR_VARIANT_TYPE.DLR_VARIANT_TYPE_FLATBUFFERS => ToFlatbuffers(),
783  DLR_VARIANT_TYPE.DLR_VARIANT_TYPE_UNKNOWN => null,
784  _ => null,
785  };
786  }
787  }
788 
793  public bool IsNull
794  {
795  get
796  {
797  if (IsDisposed)
798  {
799  throw new ObjectDisposedException(Utils.Strings.ErrorObjectDisposed);
800  }
801 
802  return IsNullPtr || DataType == DLR_VARIANT_TYPE.DLR_VARIANT_TYPE_UNKNOWN;
803  }
804  }
805 
810  public bool IsArray
811  {
812  get
813  {
814  if (IsDisposed)
815  {
816  throw new ObjectDisposedException(Utils.Strings.ErrorObjectDisposed);
817  }
818 
819  return Utils.IsArray(DataType);
820  }
821  }
822 
827  public bool IsString
828  {
829  get
830  {
831  if (IsDisposed)
832  {
833  throw new ObjectDisposedException(Utils.Strings.ErrorObjectDisposed);
834  }
835 
836  return DataType == DLR_VARIANT_TYPE.DLR_VARIANT_TYPE_STRING;
837  }
838  }
839 
844  public bool IsBool
845  {
846  get
847  {
848  if (IsDisposed)
849  {
850  throw new ObjectDisposedException(Utils.Strings.ErrorObjectDisposed);
851  }
852 
853  return DataType == DLR_VARIANT_TYPE.DLR_VARIANT_TYPE_BOOL8;
854  }
855  }
856 
862  public bool IsNumber
863  {
864  get
865  {
866  if (IsDisposed)
867  {
868  throw new ObjectDisposedException(Utils.Strings.ErrorObjectDisposed);
869  }
870 
871  return Utils.IsNumber(DataType);
872  }
873  }
874 
879  public bool IsFlatbuffers
880  {
881  get
882  {
883  if (IsDisposed)
884  {
885  throw new ObjectDisposedException(Utils.Strings.ErrorObjectDisposed);
886  }
887 
888  return DataType == DLR_VARIANT_TYPE.DLR_VARIANT_TYPE_FLATBUFFERS;
889  }
890  }
891 
897  public bool ToBool()
898  {
899  if (IsDisposed)
900  {
901  throw new ObjectDisposedException(Utils.Strings.ErrorObjectDisposed);
902  }
903 
904  if (IsNull)
905  {
906  return false;
907  }
908 
909  unsafe
910  {
911  return NativeMethods.Datalayer.DLR_variantGetBOOL8(_nativePtr);
912  }
913  }
914 
920  public sbyte ToSByte()
921  {
922  if (IsDisposed)
923  {
924  throw new ObjectDisposedException(Utils.Strings.ErrorObjectDisposed);
925  }
926 
927  if (IsNull)
928  {
929  return 0;
930  }
931 
932  unsafe
933  {
934  return NativeMethods.Datalayer.DLR_variantGetINT8(_nativePtr);
935  }
936  }
937 
943  public byte ToByte()
944  {
945  if (IsDisposed)
946  {
947  throw new ObjectDisposedException(Utils.Strings.ErrorObjectDisposed);
948  }
949 
950  if (IsNull)
951  {
952  return 0;
953  }
954 
955  unsafe
956  {
957  return NativeMethods.Datalayer.DLR_variantGetUINT8(_nativePtr);
958  }
959  }
960 
966  public short ToInt16()
967  {
968  if (IsDisposed)
969  {
970  throw new ObjectDisposedException(Utils.Strings.ErrorObjectDisposed);
971  }
972 
973  if (IsNull)
974  {
975  return 0;
976  }
977 
978  unsafe
979  {
980  return NativeMethods.Datalayer.DLR_variantGetINT16(_nativePtr);
981  }
982  }
983 
989  public ushort ToUInt16()
990  {
991  if (IsDisposed)
992  {
993  throw new ObjectDisposedException(Utils.Strings.ErrorObjectDisposed);
994  }
995 
996  if (IsNull)
997  {
998  return 0;
999  }
1000 
1001  unsafe
1002  {
1003  return NativeMethods.Datalayer.DLR_variantGetUINT16(_nativePtr);
1004  }
1005  }
1006 
1012  public int ToInt32()
1013  {
1014  if (IsDisposed)
1015  {
1016  throw new ObjectDisposedException(Utils.Strings.ErrorObjectDisposed);
1017  }
1018 
1019  if (IsNull)
1020  {
1021  return 0;
1022  }
1023 
1024  unsafe
1025  {
1026  return NativeMethods.Datalayer.DLR_variantGetINT32(_nativePtr);
1027  }
1028  }
1029 
1035  public uint ToUInt32()
1036  {
1037  if (IsDisposed)
1038  {
1039  throw new ObjectDisposedException(Utils.Strings.ErrorObjectDisposed);
1040  }
1041 
1042  if (IsNull)
1043  {
1044  return 0;
1045  }
1046 
1047  unsafe
1048  {
1049  return NativeMethods.Datalayer.DLR_variantGetUINT32(_nativePtr);
1050  }
1051  }
1052 
1058  public long ToInt64()
1059  {
1060  if (IsDisposed)
1061  {
1062  throw new ObjectDisposedException(Utils.Strings.ErrorObjectDisposed);
1063  }
1064 
1065  if (IsNull)
1066  {
1067  return 0;
1068  }
1069 
1070  unsafe
1071  {
1072  return NativeMethods.Datalayer.DLR_variantGetINT64(_nativePtr);
1073  }
1074  }
1075 
1081  public ulong ToUInt64()
1082  {
1083  if (IsDisposed)
1084  {
1085  throw new ObjectDisposedException(Utils.Strings.ErrorObjectDisposed);
1086  }
1087 
1088  if (IsNull)
1089  {
1090  return 0;
1091  }
1092 
1093  unsafe
1094  {
1095  return NativeMethods.Datalayer.DLR_variantGetUINT64(_nativePtr);
1096  }
1097  }
1098 
1104  public float ToFloat()
1105  {
1106  if (IsDisposed)
1107  {
1108  throw new ObjectDisposedException(Utils.Strings.ErrorObjectDisposed);
1109  }
1110 
1111  if (IsNull)
1112  {
1113  return 0;
1114  }
1115 
1116  unsafe
1117  {
1118  return NativeMethods.Datalayer.DLR_variantGetFLOAT32(_nativePtr);
1119  }
1120  }
1121 
1127  public double ToDouble()
1128  {
1129  if (IsDisposed)
1130  {
1131  throw new ObjectDisposedException(Utils.Strings.ErrorObjectDisposed);
1132  }
1133 
1134  if (IsNull)
1135  {
1136  return 0;
1137  }
1138 
1139  unsafe
1140  {
1141  return NativeMethods.Datalayer.DLR_variantGetFLOAT64(_nativePtr);
1142  }
1143  }
1144 
1150  public bool[] ToBoolArray()
1151  {
1152  if (IsDisposed)
1153  {
1154  throw new ObjectDisposedException(Utils.Strings.ErrorObjectDisposed);
1155  }
1156 
1157  if (IsNull)
1158  {
1159  return null;
1160  }
1161 
1162  unsafe
1163  {
1164  bool* p = NativeMethods.Datalayer.DLR_variantGetArrayOfBOOL8(_nativePtr);
1165  if (p == null)
1166  {
1167  return null;
1168  }
1169 
1170  var count = GetCount().ToUInt32();
1171  var array = new bool[count];
1172  for (var i = 0; i < count; i++)
1173  {
1174  array[i] = p[i];
1175  }
1176  return array;
1177  }
1178  }
1179 
1185  public sbyte[] ToSByteArray()
1186  {
1187  if (IsDisposed)
1188  {
1189  throw new ObjectDisposedException(Utils.Strings.ErrorObjectDisposed);
1190  }
1191 
1192  if (IsNull)
1193  {
1194  return null;
1195  }
1196 
1197  unsafe
1198  {
1199  sbyte* p = NativeMethods.Datalayer.DLR_variantGetArrayOfINT8(_nativePtr);
1200  if (p == null)
1201  {
1202  return null;
1203  }
1204 
1205  var count = GetCount().ToUInt32();
1206  var array = new sbyte[count];
1207  for (var i = 0; i < count; i++)
1208  {
1209  array[i] = p[i];
1210  }
1211  return array;
1212  }
1213  }
1214 
1220  public byte[] ToByteArray()
1221  {
1222  if (IsDisposed)
1223  {
1224  throw new ObjectDisposedException(Utils.Strings.ErrorObjectDisposed);
1225  }
1226 
1227  if (IsNull)
1228  {
1229  return null;
1230  }
1231 
1232  unsafe
1233  {
1234  byte* p = NativeMethods.Datalayer.DLR_variantGetArrayOfUINT8(_nativePtr);
1235  if (p == null)
1236  {
1237  return null;
1238  }
1239 
1240  var count = GetCount().ToUInt32();
1241  var array = new byte[count];
1242  for (var i = 0; i < count; i++)
1243  {
1244  array[i] = p[i];
1245  }
1246  return array;
1247  }
1248  }
1249 
1255  public short[] ToInt16Array()
1256  {
1257  if (IsDisposed)
1258  {
1259  throw new ObjectDisposedException(Utils.Strings.ErrorObjectDisposed);
1260  }
1261 
1262  if (IsNull)
1263  {
1264  return null;
1265  }
1266 
1267  unsafe
1268  {
1269  short* p = NativeMethods.Datalayer.DLR_variantGetArrayOfINT16(_nativePtr);
1270  if (p == null)
1271  {
1272  return null;
1273  }
1274 
1275  var count = GetCount().ToUInt32();
1276  var array = new short[count];
1277  for (var i = 0; i < count; i++)
1278  {
1279  array[i] = p[i];
1280  }
1281  return array;
1282  }
1283  }
1284 
1290  public ushort[] ToUInt16Array()
1291  {
1292  if (IsDisposed)
1293  {
1294  throw new ObjectDisposedException(Utils.Strings.ErrorObjectDisposed);
1295  }
1296 
1297  if (IsNull)
1298  {
1299  return null;
1300  }
1301 
1302  unsafe
1303  {
1304  ushort* p = NativeMethods.Datalayer.DLR_variantGetArrayOfUINT16(_nativePtr);
1305  if (p == null)
1306  {
1307  return null;
1308  }
1309 
1310  var count = GetCount().ToUInt32();
1311  var array = new ushort[count];
1312  for (var i = 0; i < count; i++)
1313  {
1314  array[i] = p[i];
1315  }
1316  return array;
1317  }
1318  }
1319 
1325  public int[] ToInt32Array()
1326  {
1327  if (IsDisposed)
1328  {
1329  throw new ObjectDisposedException(Utils.Strings.ErrorObjectDisposed);
1330  }
1331 
1332  if (IsNull)
1333  {
1334  return null;
1335  }
1336 
1337  unsafe
1338  {
1339  int* p = NativeMethods.Datalayer.DLR_variantGetArrayOfINT32(_nativePtr);
1340  if (p == null)
1341  {
1342  return null;
1343  }
1344 
1345  var count = GetCount().ToUInt32();
1346  var array = new int[count];
1347  for (var i = 0; i < count; i++)
1348  {
1349  array[i] = p[i];
1350  }
1351  return array;
1352  }
1353  }
1354 
1360  public uint[] ToUInt32Array()
1361  {
1362  if (IsDisposed)
1363  {
1364  throw new ObjectDisposedException(Utils.Strings.ErrorObjectDisposed);
1365  }
1366 
1367  if (IsNull)
1368  {
1369  return null;
1370  }
1371 
1372  unsafe
1373  {
1374  uint* p = NativeMethods.Datalayer.DLR_variantGetArrayOfUINT32(_nativePtr);
1375  if (p == null)
1376  {
1377  return null;
1378  }
1379 
1380  var count = GetCount().ToUInt32();
1381  var array = new uint[count];
1382  for (var i = 0; i < count; i++)
1383  {
1384  array[i] = p[i];
1385  }
1386  return array;
1387  }
1388  }
1389 
1395  public long[] ToInt64Array()
1396  {
1397  if (IsDisposed)
1398  {
1399  throw new ObjectDisposedException(Utils.Strings.ErrorObjectDisposed);
1400  }
1401 
1402  if (IsNull)
1403  {
1404  return null;
1405  }
1406 
1407  unsafe
1408  {
1409  long* p = NativeMethods.Datalayer.DLR_variantGetArrayOfINT64(_nativePtr);
1410  if (p == null)
1411  {
1412  return null;
1413  }
1414 
1415  var count = GetCount().ToUInt32();
1416  var array = new long[count];
1417  for (var i = 0; i < count; i++)
1418  {
1419  array[i] = p[i];
1420  }
1421  return array;
1422  }
1423  }
1424 
1430  public ulong[] ToUInt64Array()
1431  {
1432  if (IsDisposed)
1433  {
1434  throw new ObjectDisposedException(Utils.Strings.ErrorObjectDisposed);
1435  }
1436 
1437  if (IsNull)
1438  {
1439  return null;
1440  }
1441 
1442  unsafe
1443  {
1444  ulong* p = NativeMethods.Datalayer.DLR_variantGetArrayOfUINT64(_nativePtr);
1445  if (p == null)
1446  {
1447  return null;
1448  }
1449 
1450  var count = GetCount().ToUInt32();
1451  var array = new ulong[count];
1452  for (var i = 0; i < count; i++)
1453  {
1454  array[i] = p[i];
1455  }
1456  return array;
1457  }
1458  }
1459 
1465  public float[] ToFloatArray()
1466  {
1467  if (IsDisposed)
1468  {
1469  throw new ObjectDisposedException(Utils.Strings.ErrorObjectDisposed);
1470  }
1471 
1472  if (IsNull)
1473  {
1474  return null;
1475  }
1476 
1477  unsafe
1478  {
1479  float* p = NativeMethods.Datalayer.DLR_variantGetArrayOfFLOAT32(_nativePtr);
1480  if (p == null)
1481  {
1482  return null;
1483  }
1484 
1485  var count = GetCount().ToUInt32();
1486  var array = new float[count];
1487  for (var i = 0; i < count; i++)
1488  {
1489  array[i] = p[i];
1490  }
1491  return array;
1492  }
1493  }
1494 
1500  public double[] ToDoubleArray()
1501  {
1502  if (IsDisposed)
1503  {
1504  throw new ObjectDisposedException(Utils.Strings.ErrorObjectDisposed);
1505  }
1506 
1507  if (IsNull)
1508  {
1509  return null;
1510  }
1511 
1512  unsafe
1513  {
1514  double* p = NativeMethods.Datalayer.DLR_variantGetArrayOfFLOAT64(_nativePtr);
1515  if (p == null)
1516  {
1517  return null;
1518  }
1519 
1520  var count = GetCount().ToUInt32();
1521  var array = new double[count];
1522  for (var i = 0; i < count; i++)
1523  {
1524  array[i] = p[i];
1525  }
1526  return array;
1527  }
1528  }
1529 
1535  public string[] ToStringArray()
1536  {
1537  if (IsDisposed)
1538  {
1539  throw new ObjectDisposedException(Utils.Strings.ErrorObjectDisposed);
1540  }
1541 
1542  if (IsNull)
1543  {
1544  return null;
1545  }
1546 
1547  unsafe
1548  {
1549  sbyte** p = NativeMethods.Datalayer.DLR_variantGetArrayOfSTRING(_nativePtr);
1550  if (p == null)
1551  {
1552  return null;
1553  }
1554 
1555  var count = GetCount().ToUInt32();
1556  var array = new string[count];
1557  for (var i = 0; i < count; i++)
1558  {
1559  array[i] = Utils.ToString(p[i]);
1560  }
1561  return array;
1562  }
1563  }
1564 
1569  public DLR_VARIANT_TYPE DataType
1570  {
1571  get
1572  {
1573  if (IsDisposed)
1574  {
1575  throw new ObjectDisposedException(Utils.Strings.ErrorObjectDisposed);
1576  }
1577 
1578  if (IsNullPtr)
1579  {
1580  return DLR_VARIANT_TYPE.DLR_VARIANT_TYPE_UNKNOWN;
1581  }
1582 
1583  unsafe
1584  {
1585  return NativeMethods.Datalayer.DLR_variantGetType(_nativePtr);
1586  }
1587  }
1588  }
1589 
1594  public string JsonDataType
1595  {
1596  get
1597  {
1598  if (IsDisposed)
1599  {
1600  throw new ObjectDisposedException(Utils.Strings.ErrorObjectDisposed);
1601  }
1602 
1603  return Utils.ToJsonDataType(DataType);
1604  }
1605  }
1606 
1612  public ByteBuffer ToFlatbuffers()
1613  {
1614  if (IsDisposed)
1615  {
1616  throw new ObjectDisposedException(Utils.Strings.ErrorObjectDisposed);
1617  }
1618 
1619  if (IsNull)
1620  {
1621  return null;
1622  }
1623 
1624  if (!IsFlatbuffers)
1625  {
1626  return null;
1627  }
1628 
1629  unsafe
1630  {
1631  byte* p = NativeMethods.Datalayer.DLR_variantGetData(_nativePtr);
1632  if (p == null)
1633  {
1634  return null;
1635  }
1636 
1637  var count = GetCount().ToUInt32();
1638  var array = new byte[count];
1639  for (var i = 0; i < count; i++)
1640  {
1641  array[i] = p[i];
1642  }
1643  return new ByteBuffer(array);
1644  }
1645  }
1646 
1647 
1653  public byte[] ToRawByteArray()
1654  {
1655  if (IsDisposed)
1656  {
1657  throw new ObjectDisposedException(Utils.Strings.ErrorObjectDisposed);
1658  }
1659 
1660  if (IsNull)
1661  {
1662  return null;
1663  }
1664 
1665  unsafe
1666  {
1667  byte* p = NativeMethods.Datalayer.DLR_variantGetData(_nativePtr);
1668  if (p == null)
1669  {
1670  return null;
1671  }
1672 
1673  var value = Marshal.PtrToStringUTF8((IntPtr)p, Convert.ToInt32(GetSize().ToUInt32()));
1674  return Encoding.UTF8.GetBytes(value);
1675  }
1676  }
1677 
1678  #endregion
1679 
1680  #region Public Methods
1681 
1687  public Variant Clone()
1688  {
1689  if (IsDisposed)
1690  {
1691  throw new ObjectDisposedException(Utils.Strings.ErrorObjectDisposed);
1692  }
1693 
1694  if (IsNullPtr)
1695  {
1696  return new Variant();
1697  }
1698 
1699  unsafe
1700  {
1701  var clone = new Variant();
1702  if (NativeMethods.Datalayer.DLR_variantCopy(clone.ToNativePtr(), this.ToNativePtr()).IsBad())
1703  {
1704  throw new InvalidOperationException(Utils.Strings.ErrorObjectNotCloneable);
1705  }
1706 
1707  return clone;
1708  }
1709  }
1710 
1718  {
1719  if (IsDisposed)
1720  {
1721  throw new ObjectDisposedException(Utils.Strings.ErrorObjectDisposed);
1722  }
1723 
1724  if (IsNull)
1725  {
1726  return DLR_RESULT.DL_TYPE_MISMATCH;
1727  }
1728 
1729  unsafe
1730  {
1731  return NativeMethods.Datalayer.DLR_variantCheckConvert(_nativePtr, type);
1732  }
1733  }
1734 
1735  #endregion
1736 
1737  #region Public Implicit Operators
1738 
1742  public static implicit operator Variant(bool source)
1743  {
1744  return new Variant(source);
1745  }
1746 
1750  public static implicit operator Variant(bool[] source)
1751  {
1752  return new Variant(source);
1753  }
1754 
1758  public static implicit operator Variant(sbyte source)
1759  {
1760  return new Variant(source);
1761  }
1762 
1766  public static implicit operator Variant(sbyte[] source)
1767  {
1768  return new Variant(source);
1769  }
1770 
1774  public static implicit operator Variant(byte source)
1775  {
1776  return new Variant(source);
1777  }
1778 
1782  public static implicit operator Variant(byte[] source)
1783  {
1784  return new Variant(source);
1785  }
1786 
1790  public static implicit operator Variant(short source)
1791  {
1792  return new Variant(source);
1793  }
1794 
1798  public static implicit operator Variant(short[] source)
1799  {
1800  return new Variant(source);
1801  }
1802 
1806  public static implicit operator Variant(ushort source)
1807  {
1808  return new Variant(source);
1809  }
1810 
1814  public static implicit operator Variant(ushort[] source)
1815  {
1816  return new Variant(source);
1817  }
1818 
1822  public static implicit operator Variant(int source)
1823  {
1824  return new Variant(source);
1825  }
1826 
1830  public static implicit operator Variant(int[] source)
1831  {
1832  return new Variant(source);
1833  }
1834 
1838  public static implicit operator Variant(uint source)
1839  {
1840  return new Variant(source);
1841  }
1842 
1846  public static implicit operator Variant(uint[] source)
1847  {
1848  return new Variant(source);
1849  }
1850 
1854  public static implicit operator Variant(long source)
1855  {
1856  return new Variant(source);
1857  }
1858 
1862  public static implicit operator Variant(long[] source)
1863  {
1864  return new Variant(source);
1865  }
1866 
1870  public static implicit operator Variant(ulong source)
1871  {
1872  return new Variant(source);
1873  }
1874 
1878  public static implicit operator Variant(ulong[] source)
1879  {
1880  return new Variant(source);
1881  }
1882 
1886  public static implicit operator Variant(float source)
1887  {
1888  return new Variant(source);
1889  }
1890 
1894  public static implicit operator Variant(float[] source)
1895  {
1896  return new Variant(source);
1897  }
1898 
1902  public static implicit operator Variant(double source)
1903  {
1904  return new Variant(source);
1905  }
1906 
1910  public static implicit operator Variant(double[] source)
1911  {
1912  return new Variant(source);
1913  }
1914 
1918  public static implicit operator Variant(string source)
1919  {
1920  return new Variant(source);
1921  }
1922 
1926  public static implicit operator Variant(string[] source)
1927  {
1928  return new Variant(source);
1929  }
1930 
1934  public static implicit operator Variant(FlatBufferBuilder builder)
1935  {
1936  return new Variant(builder);
1937  }
1938 
1942  public static implicit operator Variant(ByteBuffer flatBuffers)
1943  {
1944  return new Variant(flatBuffers);
1945  }
1946 
1947  #endregion
1948 
1949  #region Private Setter
1950 
1956  private DLR_RESULT SetBool(bool value)
1957  {
1958  unsafe
1959  {
1960  return NativeMethods.Datalayer.DLR_variantSetBOOL8(_nativePtr, value);
1961  }
1962  }
1963 
1969  private DLR_RESULT SetInt8(sbyte value)
1970  {
1971  unsafe
1972  {
1973  return NativeMethods.Datalayer.DLR_variantSetINT8(_nativePtr, value);
1974  }
1975  }
1976 
1982  private DLR_RESULT SetUInt8(byte value)
1983  {
1984  unsafe
1985  {
1986  return NativeMethods.Datalayer.DLR_variantSetUINT8(_nativePtr, value);
1987  }
1988  }
1989 
1995  private DLR_RESULT SetInt16(short value)
1996  {
1997  unsafe
1998  {
1999  return NativeMethods.Datalayer.DLR_variantSetINT16(_nativePtr, value);
2000  }
2001  }
2002 
2008  private DLR_RESULT SetUInt16(ushort value)
2009  {
2010  unsafe
2011  {
2012  return NativeMethods.Datalayer.DLR_variantSetUINT16(_nativePtr, value);
2013  }
2014  }
2015 
2021  private DLR_RESULT SetInt32(int value)
2022  {
2023  unsafe
2024  {
2025  return NativeMethods.Datalayer.DLR_variantSetINT32(_nativePtr, value);
2026  }
2027  }
2028 
2034  private DLR_RESULT SetUInt32(uint value)
2035  {
2036  unsafe
2037  {
2038  return NativeMethods.Datalayer.DLR_variantSetUINT32(_nativePtr, value);
2039  }
2040  }
2041 
2047  private DLR_RESULT SetInt64(long value)
2048  {
2049  unsafe
2050  {
2051  return NativeMethods.Datalayer.DLR_variantSetINT64(_nativePtr, value);
2052  }
2053  }
2054 
2060  private DLR_RESULT SetUInt64(ulong value)
2061  {
2062  unsafe
2063  {
2064  return NativeMethods.Datalayer.DLR_variantSetUINT64(_nativePtr, value);
2065  }
2066  }
2067 
2073  private DLR_RESULT SetFloat32(float value)
2074  {
2075  unsafe
2076  {
2077  return NativeMethods.Datalayer.DLR_variantSetFLOAT32(_nativePtr, value);
2078  }
2079  }
2080 
2086  private DLR_RESULT SetFloat64(double value)
2087  {
2088  unsafe
2089  {
2090  return NativeMethods.Datalayer.DLR_variantSetFLOAT64(_nativePtr, value);
2091  }
2092  }
2093 
2100  private DLR_RESULT SetString(string value)
2101  {
2102  if (value == null)
2103  {
2104  throw new ArgumentNullException(nameof(value));
2105  }
2106 
2107  unsafe
2108  {
2109  return NativeMethods.Datalayer.DLR_variantSetSTRING(_nativePtr, value.ToSBytePtr());
2110  }
2111  }
2112 
2119  private DLR_RESULT SetArrayOfBool(bool[] value)
2120  {
2121  if (value == null)
2122  {
2123  throw new ArgumentNullException(nameof(value));
2124  }
2125 
2126  unsafe
2127  {
2128  fixed (bool* p = value)
2129  {
2130  return NativeMethods.Datalayer.DLR_variantSetARRAY_OF_BOOL8(_nativePtr, p, new UIntPtr(Convert.ToUInt32(value.Length)));
2131  }
2132  }
2133  }
2134 
2141  private DLR_RESULT SetArrayOfInt8(sbyte[] value)
2142  {
2143  if (value == null)
2144  {
2145  throw new ArgumentNullException(nameof(value));
2146  }
2147 
2148  unsafe
2149  {
2150  fixed (sbyte* p = value)
2151  {
2152  return NativeMethods.Datalayer.DLR_variantSetARRAY_OF_INT8(_nativePtr, p, new UIntPtr(Convert.ToUInt32(value.Length)));
2153  }
2154  }
2155  }
2156 
2163  private DLR_RESULT SetArrayOfUInt8(byte[] value)
2164  {
2165  if (value == null)
2166  {
2167  throw new ArgumentNullException(nameof(value));
2168  }
2169 
2170  unsafe
2171  {
2172  fixed (byte* p = value)
2173  {
2174  return NativeMethods.Datalayer.DLR_variantSetARRAY_OF_UINT8(_nativePtr, p, new UIntPtr(Convert.ToUInt32(value.Length)));
2175  }
2176  }
2177  }
2178 
2185  private DLR_RESULT SetArrayOfInt16(short[] value)
2186  {
2187  if (value == null)
2188  {
2189  throw new ArgumentNullException(nameof(value));
2190  }
2191 
2192  unsafe
2193  {
2194  fixed (short* p = value)
2195  {
2196  return NativeMethods.Datalayer.DLR_variantSetARRAY_OF_INT16(_nativePtr, p, new UIntPtr(Convert.ToUInt32(value.Length)));
2197  }
2198  }
2199  }
2200 
2207  private DLR_RESULT SetArrayOfUInt16(ushort[] value)
2208  {
2209  if (value == null)
2210  {
2211  throw new ArgumentNullException(nameof(value));
2212  }
2213 
2214  unsafe
2215  {
2216  fixed (ushort* p = value)
2217  {
2218  return NativeMethods.Datalayer.DLR_variantSetARRAY_OF_UINT16(_nativePtr, p, new UIntPtr(Convert.ToUInt32(value.Length)));
2219  }
2220  }
2221  }
2222 
2229  private DLR_RESULT SetArrayOfInt32(int[] value)
2230  {
2231  if (value == null)
2232  {
2233  throw new ArgumentNullException(nameof(value));
2234  }
2235 
2236  unsafe
2237  {
2238  fixed (int* p = value)
2239  {
2240  return NativeMethods.Datalayer.DLR_variantSetARRAY_OF_INT32(_nativePtr, p, new UIntPtr(Convert.ToUInt32(value.Length)));
2241  }
2242  }
2243  }
2244 
2251  private DLR_RESULT SetArrayOfUInt32(uint[] value)
2252  {
2253  if (value == null)
2254  {
2255  throw new ArgumentNullException(nameof(value));
2256  }
2257 
2258  unsafe
2259  {
2260  fixed (uint* p = value)
2261  {
2262  return NativeMethods.Datalayer.DLR_variantSetARRAY_OF_UINT32(_nativePtr, p, new UIntPtr(Convert.ToUInt32(value.Length)));
2263  }
2264  }
2265  }
2266 
2273  private DLR_RESULT SetArrayOfInt64(long[] value)
2274  {
2275  if (value == null)
2276  {
2277  throw new ArgumentNullException(nameof(value));
2278  }
2279 
2280  unsafe
2281  {
2282  fixed (long* p = value)
2283  {
2284  return NativeMethods.Datalayer.DLR_variantSetARRAY_OF_INT64(_nativePtr, p, new UIntPtr(Convert.ToUInt32(value.Length)));
2285  }
2286  }
2287  }
2288 
2295  private DLR_RESULT SetArrayOfUInt64(ulong[] value)
2296  {
2297  if (value == null)
2298  {
2299  throw new ArgumentNullException(nameof(value));
2300  }
2301 
2302  unsafe
2303  {
2304  fixed (ulong* p = value)
2305  {
2306  return NativeMethods.Datalayer.DLR_variantSetARRAY_OF_UINT64(_nativePtr, p, new UIntPtr(Convert.ToUInt32(value.Length)));
2307  }
2308  }
2309  }
2310 
2317  private DLR_RESULT SetArrayOfFloat32(float[] value)
2318  {
2319  if (value == null)
2320  {
2321  throw new ArgumentNullException(nameof(value));
2322  }
2323 
2324  unsafe
2325  {
2326  fixed (float* p = value)
2327  {
2328  return NativeMethods.Datalayer.DLR_variantSetARRAY_OF_FLOAT32(_nativePtr, p, new UIntPtr(Convert.ToUInt32(value.Length)));
2329  }
2330  }
2331  }
2332 
2339  private DLR_RESULT SetArrayOfFloat64(double[] value)
2340  {
2341  if (value == null)
2342  {
2343  throw new ArgumentNullException(nameof(value));
2344  }
2345 
2346  unsafe
2347  {
2348  fixed (double* p = value)
2349  {
2350  return NativeMethods.Datalayer.DLR_variantSetARRAY_OF_FLOAT64(_nativePtr, p, new UIntPtr(Convert.ToUInt32(value.Length)));
2351  }
2352  }
2353  }
2354 
2361  private DLR_RESULT SetArrayOfString(string[] value)
2362  {
2363  if (value == null)
2364  {
2365  throw new ArgumentNullException(nameof(value));
2366  }
2367 
2368  unsafe
2369  {
2370  var array = new sbyte*[value.Length];
2371  for (var i = 0; i < value.Length; i++)
2372  {
2373  array[i] = value[i].ToSBytePtr();
2374  }
2375 
2376  fixed (sbyte** p = array)
2377  {
2378  return NativeMethods.Datalayer.DLR_variantSetARRAY_OF_STRING(_nativePtr, p, new UIntPtr(Convert.ToUInt32(value.Length)));
2379  }
2380  }
2381  }
2382 
2389  private DLR_RESULT SetFlatbuffers(ByteBuffer value)
2390  {
2391  if (value == null)
2392  {
2393  throw new ArgumentNullException(nameof(value));
2394  }
2395 
2396  var sbyteArray = Array.ConvertAll(value.ToSizedArray(), b => unchecked((sbyte)b));
2397 
2398  unsafe
2399  {
2400  fixed (sbyte* p = sbyteArray)
2401  {
2402  return NativeMethods.Datalayer.DLR_variantSetFlatbuffers(_nativePtr, p, new UIntPtr(Convert.ToUInt32(sbyteArray.Length)));
2403  }
2404  }
2405  }
2406 
2407  #endregion
2408 
2409  #region Private Methods
2410 
2415  internal UIntPtr GetSize()
2416  {
2417  if (IsNull)
2418  {
2419  return UIntPtr.Zero;
2420  }
2421 
2422  unsafe
2423  {
2424  return NativeMethods.Datalayer.DLR_variantGetSize(_nativePtr);
2425  }
2426  }
2427 
2432  internal UIntPtr GetCount()
2433  {
2434  if (IsNull)
2435  {
2436  return UIntPtr.Zero;
2437  }
2438 
2439  unsafe
2440  {
2441  return NativeMethods.Datalayer.DLR_variantGetCount(_nativePtr);
2442  }
2443  }
2444 
2445  #endregion
2446  }
2447 }
Datalayer.Variant.Variant
Variant(byte[] value)
Creates a Variant
Definition: Variant.cs:423
Datalayer.Variant.Empty
static readonly Variant Empty
Gets a Variant with empty string value
Definition: Variant.cs:709
Datalayer.Variant.ToString
override string ToString()
Gets the value as string
Definition: Variant.cs:611
Datalayer.Variant.Variant
Variant(FlatBufferBuilder builder)
Creates a Variant
Definition: Variant.cs:528
Datalayer.Variant.Variant
Variant(double[] value)
Creates a Variant
Definition: Variant.cs:498
Datalayer.Variant.Dispose
virtual void Dispose(bool disposing)
Dispose the object
Definition: Variant.cs:68
Datalayer.Variant.Variant
Variant(short value)
Creates a Variant
Definition: Variant.cs:206
Datalayer.Variant.Variant
Variant(string[] value)
Creates a Variant
Definition: Variant.cs:348
Datalayer.Variant.ToInt16Array
short[] ToInt16Array()
Gets the value as short array
Definition: Variant.cs:1255
Datalayer.Variant.True
static readonly Variant True
Gets a Variant with boolean value 'true'
Definition: Variant.cs:714
Datalayer.Variant.IsBool
bool IsBool
Indicates whether the Variant contains a boolean value
Definition: Variant.cs:845
Datalayer.Variant.IsString
bool IsString
Indicates whether the Variant contains a string value
Definition: Variant.cs:828
Datalayer.Variant.Variant
Variant(ulong[] value)
Creates a Variant
Definition: Variant.cs:468
Datalayer.Variant.IsNull
bool IsNull
Indicates whether the Variant is null
Definition: Variant.cs:794
Datalayer.Variant.False
static readonly Variant False
Gets a Variant with boolean value 'false'
Definition: Variant.cs:719
Datalayer.Variant.Variant
Variant(long value)
Creates a Variant
Definition: Variant.cs:234
Datalayer.Variant.ToUInt32Array
uint[] ToUInt32Array()
Gets the value as uint array
Definition: Variant.cs:1360
Datalayer.Variant.Variant
Variant(string value)
Creates a Variant
Definition: Variant.cs:178
Datalayer.Variant.Variant
Variant(float[] value)
Creates a Variant
Definition: Variant.cs:483
Datalayer.Variant.ToUInt64Array
ulong[] ToUInt64Array()
Definition: Variant.cs:1430
Datalayer.Variant.Variant
Variant(bool value)
Creates a Variant
Definition: Variant.cs:163
Datalayer.DLR_VARIANT_TYPE
DLR_VARIANT_TYPE
DLR_VARIANT_TYPE
Definition: Enums.cs:218
Datalayer.Variant.GetHashCode
override int GetHashCode()
Gets the HashCode of this Variant
Definition: Variant.cs:600
Datalayer.Variant.ToInt64Array
long[] ToInt64Array()
Gets the value as long array
Definition: Variant.cs:1395
Datalayer.Variant.Null
static readonly Variant Null
Gets a Variant with no value of data type 'DLR_VARIANT_TYPE_UNKNOWN'
Definition: Variant.cs:694
Datalayer.Variant.ToInt64
long ToInt64()
Gets the value as long
Definition: Variant.cs:1058
Datalayer.Variant.DefaultFlatbuffersInitialSize
static readonly int DefaultFlatbuffersInitialSize
Gets the default Flatbuffers initial size in bytes
Definition: Variant.cs:689
Datalayer.Variant.operator==
static bool operator==(Variant x, Variant y)
Equality Operator
Definition: Variant.cs:640
Datalayer.Variant.Variant
Variant(long[] value)
Creates a Variant
Definition: Variant.cs:408
Datalayer.Variant.IsDisposed
bool IsDisposed
Object is disposed
Definition: Variant.cs:62
Datalayer.Variant.ToUInt32
uint ToUInt32()
Gets the value as uint
Definition: Variant.cs:1035
Datalayer.DLR_RESULT
DLR_RESULT
DLR_RESULT
Definition: Enums.cs:63
Datalayer.Variant.Variant
Variant(ByteBuffer flatBuffers)
Creates a Variant
Definition: Variant.cs:513
Datalayer.Variant.ToUInt16
ushort ToUInt16()
Gets the value as ushort
Definition: Variant.cs:989
Datalayer.Variant
Variant class
Definition: Variant.cs:15
Datalayer.Variant.ToInt32
int ToInt32()
Gets the value as int
Definition: Variant.cs:1012
Datalayer.Variant.Variant
Variant(IVariant other)
Creates a Variant
Definition: Variant.cs:141
Datalayer.Variant.IsFlatbuffers
bool IsFlatbuffers
Indicates whether the Variant contains Flatbuffers
Definition: Variant.cs:880
Datalayer.Variant.ToUInt64
ulong ToUInt64()
Gets the value as ulong
Definition: Variant.cs:1081
Datalayer.Variant.Clone
Variant Clone()
Clones the Variant
Definition: Variant.cs:1687
Datalayer.Variant.CheckConvert
DLR_RESULT CheckConvert(DLR_VARIANT_TYPE type)
Checks if the Variant is convertable to given data type
Definition: Variant.cs:1717
Datalayer.Variant.ToBoolArray
bool[] ToBoolArray()
Gets the value as bool array
Definition: Variant.cs:1150
Datalayer.Variant.Value
object Value
Gets the value
Definition: Variant.cs:747
Datalayer.Variant.DataType
DLR_VARIANT_TYPE DataType
Gets the data type of the Variant
Definition: Variant.cs:1570
Datalayer.Variant.Zero
static readonly Variant Zero
Gets a Variant with value '0' of data type 'int' (Int32)
Definition: Variant.cs:699
Datalayer.Variant.ToDoubleArray
double[] ToDoubleArray()
Gets the value as double array
Definition: Variant.cs:1500
Datalayer.Variant.ToSByteArray
sbyte[] ToSByteArray()
Gets the value as sbyte array
Definition: Variant.cs:1185
Datalayer.Variant.Variant
Variant(bool[] value)
Creates a Variant
Definition: Variant.cs:333
Datalayer.Variant.ToUInt16Array
ushort[] ToUInt16Array()
Gets the value as ushort array
Definition: Variant.cs:1290
Datalayer.Variant.Dispose
void Dispose()
Dispose
Definition: Variant.cs:114
Datalayer.Variant.Variant
Variant(ushort value)
Creates a Variant
Definition: Variant.cs:262
Datalayer.Variant.ToInt16
short ToInt16()
Gets the value as short
Definition: Variant.cs:966
Datalayer.Variant.ToDouble
double ToDouble()
Gets the value as double
Definition: Variant.cs:1127
Datalayer.Variant.ToFloatArray
float[] ToFloatArray()
Gets the value as float array
Definition: Variant.cs:1465
Datalayer.Variant.Variant
Variant(sbyte value)
Creates a Variant
Definition: Variant.cs:192
Datalayer.Variant.Variant
Variant(byte value)
Creates a Variant
Definition: Variant.cs:248
Datalayer.Variant.operator!=
static bool operator!=(Variant x, Variant y)
s Unequality Operator
Definition: Variant.cs:664
Datalayer.Variant.JsonDataType
string JsonDataType
Gets the Json data type of the Variant
Definition: Variant.cs:1595
Datalayer.Variant.ToFloat
float ToFloat()
Gets the value as float
Definition: Variant.cs:1104
Datalayer
Definition: DatalayerSystem.cs:5
Datalayer.Variant.Variant
Variant(uint[] value)
Creates a Variant
Definition: Variant.cs:453
Datalayer.Variant.Variant
Variant(double value)
Creates a Variant
Definition: Variant.cs:318
Datalayer.Variant.ToBool
bool ToBool()
Gets the value as bool
Definition: Variant.cs:897
Datalayer.Variant.IsArray
bool IsArray
Indicates whether the Variant is an array
Definition: Variant.cs:811
Datalayer.Variant.Equals
override bool Equals(object obj)
Returns true if this Variant equals given object
Definition: Variant.cs:551
Datalayer.Variant.IsNumber
bool IsNumber
Indicates whether the Variant contains a numeric value Returns false for numeric arrays and booleans
Definition: Variant.cs:863
Datalayer.Variant.Variant
Variant(int value)
Creates a Variant
Definition: Variant.cs:220
Datalayer.Variant.Variant
Variant(ulong value)
Creates a Variant
Definition: Variant.cs:290
Datalayer.Variant.One
static readonly Variant One
Gets a Variant with value '1' of data type 'int' (Int32)
Definition: Variant.cs:704
Datalayer.Variant.Variant
Variant(short[] value)
Creates a Variant
Definition: Variant.cs:378
Datalayer.Variant.ToInt32Array
int[] ToInt32Array()
Gets the value as int array
Definition: Variant.cs:1325
Datalayer.Variant.ToStringArray
string[] ToStringArray()
Gets the value as string array
Definition: Variant.cs:1535
Datalayer.Variant.Timestamp
DateTime Timestamp
Gets the Timestamp
Definition: Variant.cs:730
Datalayer.Variant.Variant
Variant(ushort[] value)
Creates a Variant
Definition: Variant.cs:438
Datalayer.IVariant
The variant interface.
Definition: IVariant.cs:9
Datalayer.Variant.Variant
Variant(int[] value)
Creates a Variant
Definition: Variant.cs:393
Datalayer.Variant.ToSByte
sbyte ToSByte()
Gets the value as sbyte
Definition: Variant.cs:920
Datalayer.Variant.ToRawByteArray
byte[] ToRawByteArray()
Gets the value as raw byte array (UTF8)
Definition: Variant.cs:1653
Datalayer.Variant.Variant
Variant(uint value)
Creates a Variant
Definition: Variant.cs:276
Datalayer.Variant.ToFlatbuffers
ByteBuffer ToFlatbuffers()
Gets the value as Flatbuffers
Definition: Variant.cs:1612
Datalayer.Variant.Variant
Variant()
Creates a Variant
Definition: Variant.cs:128
Datalayer.Variant.ToByte
byte ToByte()
Gets the value as byte
Definition: Variant.cs:943
Datalayer.Variant.ToByteArray
byte[] ToByteArray()
Gets the value as byte array
Definition: Variant.cs:1220
Datalayer.Variant.Variant
Variant(float value)
Creates a Variant
Definition: Variant.cs:304
Datalayer.Variant.Equals
bool Equals(Variant other)
Returns true if this Variant equals given Variant
Definition: Variant.cs:562
Datalayer.Variant.Variant
Variant(sbyte[] value)
Creates a Variant
Definition: Variant.cs:363