public static void AddValue(FlatBufferBuilder builder, float value)
 {
     builder.AddFloat(1, value, 0);
 }
 public static VectorOffset CreateStartPtVector(FlatBufferBuilder builder, float[] data)
 {
     builder.StartVector(4, data.Length, 4); for (int i = data.Length - 1; i >= 0; i--) builder.AddFloat(data[i]); return builder.EndVector();
 }
        /// <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);
        }
Beispiel #4
0
 public static void AddStatus(FlatBufferBuilder builder, float status)
 {
     builder.AddFloat(1, status, 0);
 }
 public static void AddOpacity(FlatBufferBuilder builder, float opacity)
 {
     builder.AddFloat(1, opacity, 0);
 }