예제 #1
0
        public void Merge(InputTraceRecorder recorder, long timeAsZeroOffset)
        {
            MergeDeferredTraces();

            if (timeAsZeroOffset > 0)
            {
                if (recorder.timeAsZero > timeAsZeroOffset)
                {
                    long timeOffset = recorder.timeAsZero - timeAsZeroOffset;
                    foreach (var trace in recorder.traces)
                    {
                        trace.Timestamp += timeOffset;
                    }
                }
                else
                {
                    long timeOffset = timeAsZeroOffset - recorder.timeAsZero;
                    foreach (var trace in this.traces)
                    {
                        trace.Timestamp += timeOffset;
                    }
                }
            }

            Add(recorder.traces);
        }
예제 #2
0
        /// <summary>
        ///  保存を行う.
        /// </summary>
        /// <param name="traceRecorder"></param>
        /// <returns></returns>
        public async Task SerializeAsync(InputTraceRecorder traceRecorder)
        {
            await Task.Run(async() =>
            {
                var file = await this.TargetFolder.CreateFileAsync("play.log", CreationCollisionOption.ReplaceExisting);
                if (file == null)
                {
                    return;
                }
                using (var stream = await file.OpenAsync(FileAccessMode.ReadWrite))
                {
                    using (var writer = new DataWriter(stream))
                    {
                        writer.UnicodeEncoding = Windows.Storage.Streams.UnicodeEncoding.Utf16LE;

                        JsonArray jsonArray = new JsonArray();
                        foreach (var trace in traceRecorder.Traces)
                        {
                            if (IsTraceWithFile(trace))
                            {
                                if (!await SaveFileForTraceAsync(trace as IInputTraceWithFile))
                                {
                                    continue;
                                }
                            }
                            jsonArray.Clear();
                            trace.SaveAsJson(jsonArray);
                            writer.WriteString(jsonArray.Stringify());
                            writer.WriteString(Environment.NewLine);
                        }

                        await writer.StoreAsync();
                        await writer.FlushAsync();
                    }
                }
            });
        }