Beispiel #1
0
        public void TestSerializeSessions()
        {
            ITimingSession timingSession = new TimingSession();
            var            json          = ImportSerializer.SerializeSessions(new[] { timingSession });

            var deserializedSession = ImportSerializer.DeserializeSessions(json).First();
        }
        private void ImportSessionsFromUrl(string importUrl)
        {
            IEnumerable <ITimingSession> sessions = null;

            var request = WebRequest.Create(importUrl);

            request.Timeout = 30000;
            using (var response = request.GetResponse() as HttpWebResponse)
                using (var stream = new StreamReader(response.GetResponseStream()))
                {
                    if (response.StatusCode == HttpStatusCode.OK)
                    {
                        var content = stream.ReadToEnd();
                        sessions = ImportSerializer.DeserializeSessions(content);
                    }
                }

            if (sessions == null)
            {
                return;
            }

            if (ProfilingSession.CircularBuffer == null)
            {
                return;
            }

            var existingIds = ProfilingSession.CircularBuffer.Select(session => session.Id).ToList();

            foreach (var session in sessions)
            {
                if (!existingIds.Contains(session.Id))
                {
                    ProfilingSession.CircularBuffer.Add(session);
                }
            }
        }
Beispiel #3
0
        private async Task ImportSessionsFromUrl(string importUrl)
        {
            IEnumerable <ITimingSession> sessions = null;

            using (var httpClient = new HttpClient())
            {
                var response = await httpClient.GetAsync(importUrl);

                if (response.StatusCode == HttpStatusCode.OK)
                {
                    var content = await response.Content.ReadAsStringAsync();

                    sessions = ImportSerializer.DeserializeSessions(content);
                }
            }

            if (sessions == null)
            {
                return;
            }

            if (ProfilingSession.CircularBuffer == null)
            {
                return;
            }

            var existingIds = ProfilingSession.CircularBuffer.Select(session => session.Id).ToList();

            foreach (var session in sessions)
            {
                if (!existingIds.Contains(session.Id))
                {
                    ProfilingSession.CircularBuffer.Add(session);
                }
            }
        }