Ejemplo n.º 1
0
        private Offset <KeyFrameData>?SerializeKeyFrame(FlatBufferBuilder fbb, KeyFrame frame)
        {
            #region Linear

            if (frame is LinearKeyFrame_Int16)
            {
                var oFrame = LinearKeyFrameData_Int16.CreateLinearKeyFrameData_Int16(fbb, frame.Time, (short)frame.Value);

                return(KeyFrameData.CreateKeyFrameData(fbb, KeyFrameUnion.LinearKeyFrameData_Int16, oFrame.Value));
            }

            if (frame is LinearKeyFrame_Int32)
            {
                var oFrame = LinearKeyFrameData_Int32.CreateLinearKeyFrameData_Int32(fbb, frame.Time, (int)frame.Value);

                return(KeyFrameData.CreateKeyFrameData(fbb, KeyFrameUnion.LinearKeyFrameData_Int32, oFrame.Value));
            }

            if (frame is LinearKeyFrame_Int64)
            {
                var oFrame = LinearKeyFrameData_Int64.CreateLinearKeyFrameData_Int64(fbb, frame.Time, (long)frame.Value);

                return(KeyFrameData.CreateKeyFrameData(fbb, KeyFrameUnion.LinearKeyFrameData_Int64, oFrame.Value));
            }

            if (frame is LinearKeyFrame_Float)
            {
                var oFrame = LinearKeyFrameData_Float.CreateLinearKeyFrameData_Float(fbb, frame.Time, (float)frame.Value);

                return(KeyFrameData.CreateKeyFrameData(fbb, KeyFrameUnion.LinearKeyFrameData_Float, oFrame.Value));
            }

            #endregion

            #region Pulse

            if (frame is PulseKeyFrame <short> )
            {
                var oFrame = PulseKeyFrameData_Int16.CreatePulseKeyFrameData_Int16(fbb, frame.Time, (short)frame.Value);

                return(KeyFrameData.CreateKeyFrameData(fbb, KeyFrameUnion.PulseKeyFrameData_Int16, oFrame.Value));
            }

            if (frame is PulseKeyFrame <int> )
            {
                var oFrame = PulseKeyFrameData_Int32.CreatePulseKeyFrameData_Int32(fbb, frame.Time, (int)frame.Value);

                return(KeyFrameData.CreateKeyFrameData(fbb, KeyFrameUnion.PulseKeyFrameData_Int32, oFrame.Value));
            }

            if (frame is PulseKeyFrame <long> )
            {
                var oFrame = PulseKeyFrameData_Int64.CreatePulseKeyFrameData_Int64(fbb, frame.Time, (long)frame.Value);

                return(KeyFrameData.CreateKeyFrameData(fbb, KeyFrameUnion.PulseKeyFrameData_Int64, oFrame.Value));
            }

            if (frame is PulseKeyFrame <float> )
            {
                var oFrame = PulseKeyFrameData_Float.CreatePulseKeyFrameData_Float(fbb, frame.Time, (float)frame.Value);

                return(KeyFrameData.CreateKeyFrameData(fbb, KeyFrameUnion.PulseKeyFrameData_Float, oFrame.Value));
            }

            #endregion

            #region Step

            if (frame is StepKeyFrame <bool> )
            {
                var oFrame = StepKeyFrameData_Boolean.CreateStepKeyFrameData_Boolean(fbb, frame.Time, (bool)frame.Value);

                return(KeyFrameData.CreateKeyFrameData(fbb, KeyFrameUnion.StepKeyFrameData_Boolean, oFrame.Value));
            }

            if (frame is StepKeyFrame <short> )
            {
                var oFrame = StepKeyFrameData_Int16.CreateStepKeyFrameData_Int16(fbb, frame.Time, (short)frame.Value);

                return(KeyFrameData.CreateKeyFrameData(fbb, KeyFrameUnion.StepKeyFrameData_Int16, oFrame.Value));
            }

            if (frame is StepKeyFrame <int> )
            {
                var oFrame = StepKeyFrameData_Int32.CreateStepKeyFrameData_Int32(fbb, frame.Time, (int)frame.Value);

                return(KeyFrameData.CreateKeyFrameData(fbb, KeyFrameUnion.StepKeyFrameData_Int32, oFrame.Value));
            }

            if (frame is StepKeyFrame <long> )
            {
                var oFrame = StepKeyFrameData_Int64.CreateStepKeyFrameData_Int64(fbb, frame.Time, (long)frame.Value);

                return(KeyFrameData.CreateKeyFrameData(fbb, KeyFrameUnion.StepKeyFrameData_Int64, oFrame.Value));
            }

            if (frame is StepKeyFrame <float> )
            {
                var oFrame = StepKeyFrameData_Float.CreateStepKeyFrameData_Float(fbb, frame.Time, (float)frame.Value);

                return(KeyFrameData.CreateKeyFrameData(fbb, KeyFrameUnion.StepKeyFrameData_Float, oFrame.Value));
            }

            #endregion

            throw new NotSupportedException("KeyFrameType");
        }