in WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/HoloLens/PerceptionSimulationRecording.cs [89:139]
public async Task<byte[]> StopHolographicSimulationRecordingAsync()
{
if (!Utilities.IsHoloLens(this.Platform, this.DeviceFamily))
{
throw new NotSupportedException("This method is only supported on HoloLens.");
}
Uri uri = Utilities.BuildEndpoint(
this.deviceConnection.Connection,
StopHolographicSimulationRecordingApi);
byte[] dataBytes = null;
using (Stream dataStream = await this.GetAsync(uri))
{
if (dataStream != null)
{
using (MemoryStream outStream = new MemoryStream())
{
dataStream.CopyTo(outStream);
if (outStream.Length != 0)
{
outStream.Seek(0, SeekOrigin.Begin);
DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(HolographicSimulationError));
HolographicSimulationError error = null;
try
{
// Try to get / interpret an error response.
error = (HolographicSimulationError)serializer.ReadObject(outStream);
}
catch
{
}
if (error != null)
{
// We received an error response.
throw new InvalidOperationException(error.Reason);
}
// Getting here indicates that we have file data to return.
dataBytes = new byte[outStream.Length];
await outStream.ReadAsync(dataBytes, 0, dataBytes.Length);
}
}
}
}
return dataBytes;
}