private void LoadConfiguration()
{
string content = null;
try
{
var entryAssembly = Assembly.GetEntryAssembly();
var customAttribute = entryAssembly.GetCustomAttribute <AssemblyProductAttribute>();
var customAttribute2 = entryAssembly.GetCustomAttribute <AssemblyCompanyAttribute>();
var text = customAttribute == null?entryAssembly.GetName().Name : customAttribute.Product;
var text2 = customAttribute2 == null?entryAssembly.GetName().Name : customAttribute2.Company;
var path = Path.Combine(InstallationUtils.GetApplicationDataPath(), text2, text, "framework", "configuration.xml");
this.configFile = File.Exists(path) ? path : Path.Combine(Installation.ConfigDir.FullName, "configuration.xml");
content = File.ReadAllText(this.configFile);
}
catch (Exception)
{
// ignored
}
if (content != null)
{
using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(content)))
{
var serializer = new XmlSerializer(typeof(Configuration));
Configuration = (Configuration)serializer.Deserialize(stream);
if (string.IsNullOrEmpty(Configuration.InstrumentFileName))
{
Configuration.SetDefaultInstrumentConfiguration();
}
if (string.IsNullOrEmpty(Configuration.DataFileName))
{
Configuration.SetDefaultDataConfiguration();
}
if (string.IsNullOrEmpty(Configuration.OrderFileName))
{
Configuration.SetDefaultOrderConfiguration();
}
if (string.IsNullOrEmpty(Configuration.PortfolioFileName))
{
Configuration.SetDefaultPortfolioConfiguration();
}
if (Configuration.Streamers.Count == 0)
{
Configuration.AddDefaultStreamers();
}
if (Configuration.Providers.Count == 0)
{
Configuration.AddDefaultProviders();
}
return;
}
}
Configuration = Configuration.DefaultConfiguaration();
}