예제 #1
0
        /// <summary>
        /// Load the profile from the given path.
        /// </summary>
        private async Task LoadProfile(string path)
        {
            try
            {
                LogProfile profile;
                if (path.EndsWith(".json.profile"))
                {
                    using (Stream stream = File.OpenRead(path))
                    {
                        LogProfileReader reader = new LogProfileReader(stream);
                        profile = await reader.ReadAsync();
                    }

                    string newPath = Path.GetFileNameWithoutExtension(Path.GetFileNameWithoutExtension(path)) + ".xml.profile";
                    using (Stream xml = File.OpenWrite(newPath))
                    {
                        LogProfileXmlWriter writer = new LogProfileXmlWriter(xml);
                        writer.Write(profile);
                    }
                }
                else if (path.EndsWith(".xml.profile"))
                {
                    using (Stream stream = File.OpenRead(path))
                    {
                        LogProfileXmlReader reader = new LogProfileXmlReader(stream);
                        profile = reader.Read();
                    }
                }
                else
                {
                    return;
                }

                this.profilePath.Text = path;
                this.profileName      = Path.GetFileNameWithoutExtension(this.profilePath.Text);

                MathValueConfigurationLoader loader = new MathValueConfigurationLoader(this);
                loader.Initialize();
                this.profileAndMath             = new LogProfileAndMath(profile, loader.Configuration);
                this.logValues.Text             = string.Join(Environment.NewLine, this.profileAndMath.GetColumnNames());
                LoggerConfiguration.ProfilePath = path;
            }
            catch (Exception exception)
            {
                this.logValues.Text = exception.Message;
                this.AddDebugMessage(exception.ToString());
                this.profilePath.Text = "[no profile loaded]";
                this.profileName      = null;
            }
        }
예제 #2
0
        /// <summary>
        /// Load the profile from the given path.
        /// </summary>
        private async Task LoadProfile(string path)
        {
            try
            {
                using (Stream stream = File.OpenRead(path))
                {
                    LogProfileReader reader = new LogProfileReader(stream);
                    this.profile = await reader.ReadAsync();
                }

                this.profilePath.Text           = path;
                this.profileName                = Path.GetFileNameWithoutExtension(this.profilePath.Text);
                this.logValues.Text             = this.profile.GetParameterNames(Environment.NewLine);
                LoggerConfiguration.ProfilePath = path;
            }
            catch (Exception exception)
            {
                this.logValues.Text = exception.Message;
                this.AddDebugMessage(exception.ToString());
                this.profilePath.Text = "[no profile loaded]";
                this.profileName      = null;
            }
        }