How do i get access to the IEventAggregator from a class?
using AssetofThings.Events;
using Prism.Events;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Timers;
namespace AssetofThings.Models
{
public class DeviceInfo : INotifyPropertyChanged
{
IEventAggregator ea;
public DeviceInfo()
{
App.Current.
ea = Container.Resolve<IEventAggregator>();//****** ERROR..doesnt work
aTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent);
DeviceInfo.Current.aTimer.Interval = 5000;
DeviceInfo.Current.aTimer.Enabled = true;
}
private void OnTimedEvent(object sender, ElapsedEventArgs e)
{
ea.GetEvent<RequestGeoUpdateEvent>().Publish("RequestGeoUpdateEvent");//*******WANT TO publish an event
}
// Singleton
public static DeviceInfo Current = new DeviceInfo();
public System.Timers.Timer aTimer = new System.Timers.Timer();
private int _updateseconds=60;
public int updateseconds //seconds
{
get
{
return _updateseconds;
}
set
{
if (value != updateseconds)
{
_updateseconds = value;
OnPropertyChanged("updateseconds");
}
}
}
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged(string propertyName)
{
if (PropertyChanged == null)
return;
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
}