/// <summary> /// Загрузить настройки. /// </summary> /// <param name="storage">Хранилище настроек.</param> public override void Load(SettingsStorage storage) { InnerSessions.Clear(); Portfolios.Clear(); storage .GetValue <IEnumerable <SettingsStorage> >("InnerSessions") .ForEach(s => { var sessionHolder = s.GetValue <Type>("type").CreateInstanceArgs <IMessageSessionHolder>(new object[] { TransactionIdGenerator }); sessionHolder.Load(s.GetValue <SettingsStorage>("settings")); InnerSessions.Add(sessionHolder, s.GetValue <int>("Priority")); var portfolios = s.GetValue <IEnumerable <string> >("Portfolios"); if (portfolios != null) { foreach (var portfolio in portfolios) { Portfolios[portfolio] = sessionHolder; } } }); base.Load(storage); }
/// <summary> /// Сохранить настройки. /// </summary> /// <param name="storage">Хранилище настроек.</param> public override void Save(SettingsStorage storage) { storage.SetValue("InnerSessions", InnerSessions.Select(s => { var settings = s.SaveEntire(true); settings.SetValue("Priority", InnerSessions[s]); //settings.SetValue("Portfolios", Portfolios.Where(p => p.Value == s).Select(p => p.Key).ToArray()); return(settings); }).ToArray()); base.Save(storage); }