Beispiel #1
0
        // Method to marshal from native to managed struct
        internal unsafe void __MarshalFrom(ref __Native @ref)
        {
            this.Size = @ref.Size;
            this.Flags = @ref.Flags;
            this.Duration = @ref.Duration;
            this.SamplePeriod = @ref.SamplePeriod;
            this.Gain = @ref.Gain;
            this.TriggerButton = @ref.TriggerButton;
            this.TriggerRepeatInterval = @ref.TriggerRepeatInterval;
            this.AxeCount = @ref.AxeCount;
            this.StartDelay = @ref.StartDelay;

            // Marshal Axes and Directions
            if (AxeCount > 0)
            {
                if (@ref.AxePointer != IntPtr.Zero)
                {
                    Axes = new int[AxeCount];
                    Marshal.Copy(@ref.AxePointer, Axes, 0, AxeCount);
                }

                if (@ref.DirectionPointer != IntPtr.Zero)
                {
                    Directions = new int[AxeCount];
                    Marshal.Copy(@ref.DirectionPointer, Directions, 0, AxeCount);
                }
            }

            // Marshal Envelope
            if (@ref.EnvelopePointer != IntPtr.Zero)
            {
                var envelopeNative = *((Envelope.__Native*) @ref.EnvelopePointer);
                Envelope = new Envelope();
                Envelope.__MarshalFrom(ref envelopeNative);
            }

            // Marshal TypeSpecificParameters
            if (@ref.TypeSpecificParamCount > 0 && @ref.TypeSpecificParamPointer != IntPtr.Zero)
                Parameters = new TypeSpecificParameters(@ref.TypeSpecificParamCount, @ref.TypeSpecificParamPointer);

        }