Beispiel #1
0
        /// <summary>
        /// Perform basic initialization. Check for file existance, read properties etc.
        /// </summary>
        /// <remarks>
        /// Trace Data is not loaded at this moment. It's done in <code>Load</code> method.
        /// </remarks>
        /// <param name="path">Path to the session properties file.</param>
        protected virtual void Initialize(string path)
        {
            if (string.IsNullOrEmpty(path))
            {
                throw new ArgumentNullException(nameof(path));
            }

            SessionFolder = Path.GetDirectoryName(path);

            if (SessionFolder == null || !File.Exists(Path.GetFullPath(path)))
            {
                throw new Exception($"Session file {path} not found");
            }

            SessionFile = Path.GetFullPath(path);

            _sessionProperties = new SessionProperties(SessionFile);
            _sessionProperties.Load();

            CreatedAt = TimeStampHelper.UnixEpochTime
                        .AddMilliseconds(Convert.ToDouble(
                                             _sessionProperties.GetProperty("Time", "value")
                                             .Replace(',', '.'), //Temporary fix to read sessions created before changing the format
                                             CultureInfo.InvariantCulture));

            ProjectName = _sessionProperties.GetProperty("ProjectName", "value");

            foreach (var property in new List <string> {
                "CoreClrProfilerReport", "Proc"
            })
            {
                if (!_sessionProperties.PropertyExists(property))
                {
                    throw new Exception($"{property} session property not found");
                }
            }
        }