Esempio n. 1
0
 public PropertiesManager(LocomotiveModel Locomotive, ILocoBaseSource dbSource)
 {
     this.Locomotive = Locomotive;
     using (var db = dbSource.GetContext())
     {
         LoadLocomotive(Locomotive, db);
     }
 }
        public LocomotiveSelectorViewModel(ILocoBaseSource DatabaseSource, IEventAggregator EventAggregator, ILocoBaseSource DbSource,
                                           ILocomotiveKindViewModelFactory KindViewModelFactory)
        {
            _eventAggregator = EventAggregator;
            _dbSource = DbSource;
            _kindViewModelFactory = KindViewModelFactory;

            _kinds = new Lazy<IList<LocomotiveKindViewModel>>(
                () => DatabaseSource.GetContext().DicLocomotiveKind.Select(kind => _kindViewModelFactory.GetViewModel(kind)).ToList());

            _eventAggregator.GetEvent<CardCreatedEvent>().Subscribe(OnCardCreated);
            _eventAggregator.GetEvent<LocomotiveAutodetectedEvent>().Subscribe(OnAutodetected);
        }
Esempio n. 3
0
 public void Export(string OutputFileName, ILocoBaseSource BaseSource)
 {
     using (var ms = new MemoryStream())
     {
         XDocument doc;
         using (LocoDataContext db = BaseSource.GetContext())
         {
             doc = GetDocument(db);
         }
         doc.Save(ms);
         using (var outputStream = GetOutputStream(OutputFileName))
         {
             ms.Seek(0, SeekOrigin.Begin);
             ms.CopyTo(outputStream);
         }
     }
 }