Skip to content

Commit

Permalink
some code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
LiorBanai committed Oct 23, 2020
1 parent b11779a commit c929bd3
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 195 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Analogy.LogViewer.Log4jXml.IAnalogy
public class DataProvidersFactory : LogViewer.Template.DataProvidersFactory
{
public override Guid FactoryId { get; set; } = PrimaryFactory.Id;
public override string Title { get; set; } = "Log Parser";
public override string Title { get; set; } = "Log4jXml Log Parser";
public override IEnumerable<IAnalogyDataProvider> DataProviders { get; set; } = new List<IAnalogyDataProvider> { new OfflineDataProvider() };
}
}
100 changes: 50 additions & 50 deletions Analogy.LogViewer.Log4jXml/Managers/UserSettingsManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,54 +5,54 @@

namespace Analogy.LogViewer.Log4jXml.Managers
{
public class UserSettingsManager
{
private static readonly Lazy<UserSettingsManager> _instance =
new Lazy<UserSettingsManager>(() => new UserSettingsManager());
public static UserSettingsManager UserSettings { get; set; } = _instance.Value;
public string AffirmationsFileSetting { get; private set; } = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Analogy.LogViewer", "AnalogyLog4jXmlSettings.json");
public Log4jXmlSettings Settings { get; set; }


public UserSettingsManager()
{
if (File.Exists(AffirmationsFileSetting))
{
try
{
var settings = new JsonSerializerSettings
{
ObjectCreationHandling = ObjectCreationHandling.Replace
};
string data = File.ReadAllText(AffirmationsFileSetting);
Settings = JsonConvert.DeserializeObject<Log4jXmlSettings>(data, settings)!;
}
catch (Exception ex)
{
LogManager.Instance.LogException("Error loading user setting file", ex, "Analogy Serilog Parser");
Settings = new Log4jXmlSettings();

}
}
else
{
Settings = new Log4jXmlSettings();
}

}

public void Save()
{
try
{
File.WriteAllText(AffirmationsFileSetting, JsonConvert.SerializeObject(Settings));
}
catch (Exception e)
{
LogManager.Instance.LogException("Error saving settings: " + e.Message, e, "Analogy Serilog Parser");
}


}
}
//public class UserSettingsManager
//{
// private static readonly Lazy<UserSettingsManager> _instance =
// new Lazy<UserSettingsManager>(() => new UserSettingsManager());
// public static UserSettingsManager UserSettings { get; set; } = _instance.Value;
// public string AffirmationsFileSetting { get; private set; } = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Analogy.LogViewer", "AnalogyLog4jXmlSettings.json");
// public Log4jXmlSettings Settings { get; set; }


// public UserSettingsManager()
// {
// if (File.Exists(AffirmationsFileSetting))
// {
// try
// {
// var settings = new JsonSerializerSettings
// {
// ObjectCreationHandling = ObjectCreationHandling.Replace
// };
// string data = File.ReadAllText(AffirmationsFileSetting);
// Settings = JsonConvert.DeserializeObject<Log4jXmlSettings>(data, settings)!;
// }
// catch (Exception ex)
// {
// LogManager.Instance.LogException("Error loading user setting file", ex, "Analogy Serilog Parser");
// Settings = new Log4jXmlSettings();

// }
// }
// else
// {
// Settings = new Log4jXmlSettings();
// }

// }

// public void Save()
// {
// try
// {
// File.WriteAllText(AffirmationsFileSetting, JsonConvert.SerializeObject(Settings));
// }
// catch (Exception e)
// {
// LogManager.Instance.LogException("Error saving settings: " + e.Message, e, "Analogy Serilog Parser");
// }


// }
//}
}
36 changes: 0 additions & 36 deletions Analogy.LogViewer.Log4jXml/Parser/PlainLogFileParser.cs

This file was deleted.

108 changes: 0 additions & 108 deletions Analogy.LogViewer.Log4jXml/Parser/PlainTextLogFileLoader.cs

This file was deleted.

0 comments on commit c929bd3

Please sign in to comment.