public static IndoorMapEntity FromInterop(IndoorMapEntityInterop interop)
        {
            var indoorMapEntity = new IndoorMapEntity(
                Marshal.PtrToStringAnsi(interop.indoorMapEntityId, interop.indoorMapEntityIdBufferSize - 1),
                interop.indoorMapFloorId,
                interop.position.ToLatLong()
                );

            return(indoorMapEntity);
        }
        private bool TryUpdateIndoorMapEntityInformation(IndoorMapEntityInformation indoorMapEntityInformation)
        {
            // fetch from native
            var indoorMapEntities = new List <IndoorMapEntity>();

            var interop = new IndoorMapEntityInformationInterop
            {
                indoorMapEntityInformationModelId = indoorMapEntityInformation.Id
            };

            var success = NativeIndoorMapEntityInformationApi_TryGetIndoorMapEntityInformationBufferSizes(NativePluginRunner.API, ref interop);

            if (!success)
            {
                return(false);
            }

            var indoorMapEntityIdsBuffer         = new int[interop.indoorMapEntityModelIdsBufferSize];
            var indoorMapEntityIdsBufferGCHandle = GCHandle.Alloc(indoorMapEntityIdsBuffer, GCHandleType.Pinned);

            interop.indoorMapEntityModelIds = indoorMapEntityIdsBufferGCHandle.AddrOfPinnedObject();

            success = NativeIndoorMapEntityInformationApi_TryGetIndoorMapEntityInformation(NativePluginRunner.API, ref interop);
            if (success)
            {
                foreach (var indoorMapEntityId in indoorMapEntityIdsBuffer)
                {
                    var indoorMapEntityInterop = new IndoorMapEntityInterop
                    {
                        indoorMapEntityModelId = indoorMapEntityId
                    };
                    success = NativeIndoorMapEntityInformationApi_TryGetIndoorMapEntityBufferSizes(NativePluginRunner.API, ref indoorMapEntityInterop);
                    if (!success)
                    {
                        break;
                    }


                    var indoorMapEntityIdBuffer         = new byte[indoorMapEntityInterop.indoorMapEntityIdBufferSize];
                    var indoorMapEntityIdBufferGCHandle = GCHandle.Alloc(indoorMapEntityIdBuffer, GCHandleType.Pinned);
                    indoorMapEntityInterop.indoorMapEntityId = indoorMapEntityIdBufferGCHandle.AddrOfPinnedObject();

                    success = NativeIndoorMapEntityInformationApi_TryGetIndoorMapEntity(NativePluginRunner.API, ref indoorMapEntityInterop);
                    if (!success)
                    {
                        indoorMapEntityIdBufferGCHandle.Free();
                        break;
                    }

                    var indoorMapEntity = FromInterop(indoorMapEntityInterop);
                    indoorMapEntities.Add(indoorMapEntity);
                    indoorMapEntityIdBufferGCHandle.Free();
                }
            }

            if (success)
            {
                indoorMapEntityInformation.SetEntityInformation(indoorMapEntities, interop.indoorMapEntityLoadState);

                if (OnIndoorMapEntityInformationUpdated != null)
                {
                    OnIndoorMapEntityInformationUpdated(indoorMapEntityInformation);
                }
            }

            indoorMapEntityIdsBufferGCHandle.Free();

            return(success);
        }
 private static extern bool NativeIndoorMapEntityInformationApi_TryGetIndoorMapEntity(IntPtr ptr, ref IndoorMapEntityInterop inout_indoorMapEntityInterop);