Exemple #1
0
        public void Selected(ILogLineColumnizerCallback callback)
        {
            var fileInfo = new FileInfo(callback.GetFileName());

            this.name = BitConverter.ToString(new MD5CryptoServiceProvider()
                                              .ComputeHash(Encoding.Unicode.GetBytes(fileInfo.FullName)))
                        .Replace("-", "")
                        .ToLower();

            var configPath = this.ConfigDir + @"\Regexcolumnizer-" + this.name + "." + ".dat";

            if (!File.Exists(configPath))
            {
                this.config = new RegexColumnizerConfig();
            }
            else
            {
                using (var fs = File.OpenRead(configPath))
                {
                    try
                    {
                        var formatter = new BinaryFormatter();

                        var configuration = (RegexColumnizerConfig)formatter.Deserialize(fs);

                        if (configuration.IsValid())
                        {
                            this.config = configuration;
                        }
                    }
                    catch (SerializationException e)
                    {
                        MessageBox.Show(e.Message, "Deserialize");
                        this.config = new RegexColumnizerConfig();
                    }
                }
            }
        }