public static Configuration DefaultConfiguaration() { var c = new Configuration(); c.IsInstrumentFileLocal = true; c.InstrumentFileHost = "127.0.0.1"; c.InstrumentFileName = Path.Combine(Installation.DataDir.FullName, "instruments.quant"); c.IsDataFileLocal = true; c.DataFileHost = "127.0.0.1"; c.DataFileName = Path.Combine(Installation.DataDir.FullName, "data.quant"); c.IsOrderFileLocal = true; c.OrderFileHost = "127.0.0.1"; c.OrderFilePort = 1000; c.OrderFileName = Path.Combine(Installation.DataDir.FullName, "orders.quant"); c.DefaultCurrency = "USD"; c.DefaultExchange = "SMART"; c.DefaultDataProvider = "QuantRouter"; c.DefaultExecutionProvider = "QuantRouter"; c.ProviderManagerFileName = Path.Combine(Installation.ConfigDir.FullName, "providermanager.xml"); c.Streamers = new List <StreamerPlugin>(); c.AddDefaultStreamers(); c.Providers = new List <ProviderPlugin>(); c.AddDefaultProviders(); c.ServerFactoryType = "DefaultServerFactory"; return(c); }
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(); }
//public void AddDefaultStreamers() //{ // var types = new string[] {}; // foreach (var name in types) // { // Type t = Type.GetType(name); // if (t != null) // Streamers.Add(new StreamerPlugin(t.FullName)); // } //} //public void AddDefaultProviders() //{ // //var types = new Dictionary<string, bool>(); // //foreach (var pair in types) // //{ // // Type t = Type.GetType(pair.Key); // // if (t != null) // // Providers.Add(new ProviderPlugin(t.FullName, pair.Value)); // //} //} public static Configuration DefaultConfiguaration() { var c = new Configuration(); c.IsInstrumentFileLocal = true; c.InstrumentFileHost = "127.0.0.1"; c.InstrumentFileName = Path.Combine(Installation.DataDir.FullName, "instruments.quant"); c.IsDataFileLocal = true; c.DataFileHost = "127.0.0.1"; c.DataFileName = Path.Combine(Installation.DataDir.FullName, "data.quant"); c.IsOrderFileLocal = true; c.OrderFileHost = "127.0.0.1"; c.OrderFilePort = 1000; c.OrderFileName = Path.Combine(Installation.DataDir.FullName, "orders.quant"); c.DefaultCurrency = "USD"; c.DefaultExchange = "SMART"; c.DefaultDataProvider = "QuantRouter"; c.DefaultExecutionProvider = "QuantRouter"; c.ProviderManagerFileName = Path.Combine(Installation.ConfigDir.FullName, "providermanager.xml"); c.Streamers = new List<StreamerPlugin>(); c.AddDefaultStreamers(); c.Providers = new List<ProviderPlugin>(); c.AddDefaultProviders(); c.ServerFactoryType = "DefaultServerFactory"; return c; }