/// <summary>
        /// Serializes a value as inline
        /// </summary>
        private int SerializeInlineValue(object obj, TypeModel typeModel)
        {
            switch (typeModel.BaseType)
            {
            case BaseType.Bool:
            {
                _builder.AddBool((bool)obj);
                break;
            }

            case BaseType.Char:
            {
                _builder.AddSbyte((sbyte)obj);
                break;
            }

            case BaseType.UChar:
            {
                _builder.AddByte((byte)obj);
                break;
            }

            case BaseType.Short:
            {
                _builder.AddShort((short)obj);
                break;
            }

            case BaseType.UShort:
            {
                _builder.AddUshort((ushort)obj);
                break;
            }

            case BaseType.Int:
            {
                _builder.AddInt((int)obj);
                break;
            }

            case BaseType.UInt:
            {
                _builder.AddUint((uint)obj);
                break;
            }

            case BaseType.Long:
            {
                _builder.AddLong((long)obj);
                break;
            }

            case BaseType.ULong:
            {
                _builder.AddUlong((ulong)obj);
                break;
            }

            case BaseType.Float:
            {
                _builder.AddFloat((float)obj);
                break;
            }

            case BaseType.Double:
            {
                _builder.AddDouble((double)obj);
                break;
            }

            case BaseType.Struct:
            {
                return(SerializeStruct(obj, typeModel));
            }

            default:
            {
                throw new InvalidOperationException();
            }
            }
            return(_builder.Offset);
        }
Пример #2
0
 public static void AddZ(FlatBufferBuilder builder, double z)
 {
     builder.AddDouble(2, z, 0);
 }
Пример #3
0
 public static void AddX(FlatBufferBuilder builder, double x)
 {
     builder.AddDouble(0, x, 0);
 }
Пример #4
0
 public static void AddY(FlatBufferBuilder builder, double y)
 {
     builder.AddDouble(1, y, 0);
 }
Пример #5
0
 public static void AddW(FlatBufferBuilder builder, double w)
 {
     builder.AddDouble(3, w, 0);
 }