本文整理汇总了C#中IEventAggregator.Publish方法的典型用法代码示例。如果您正苦于以下问题:C# IEventAggregator.Publish方法的具体用法?C# IEventAggregator.Publish怎么用?C# IEventAggregator.Publish使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IEventAggregator
的用法示例。
在下文中一共展示了IEventAggregator.Publish方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateStats
public virtual void UpdateStats(BaseCaracterStats statData, IEventAggregator messenger)
{
MaxLife += statData.MaxLife;
Life += statData.Life;
if (MaxLife < Life) Life = MaxLife;
if (Life <= 0)
{
Life = 0;
messenger.Publish(new StopMessage());
messenger.Publish(new PlayerDeathMessage());
}
RedHearts += statData.RedHearts;
BlueHearts += statData.BlueHearts;
YellowHearts += statData.YellowHearts;
Attack += statData.Attack;
BaseSpeed += statData.BaseSpeed;
CurrentSpeed = BaseSpeed;
AttackCadence += statData.AttackCadence;
if (statData.OldTools)
{
OldTools = statData.OldTools;
}
messenger.Publish(new UpdateGuiMessage(this));
}
示例2: OkCancelPanelViewModel
public OkCancelPanelViewModel(IEventAggregator eventAggregator)
{
this.OkCommand = new DelegateCommand<object>(
o => eventAggregator.Publish(new CleanUpFilesMessage()));
this.CancelCommand = new DelegateCommand<object>(o =>
eventAggregator.Publish(new ClearFileSelectionMessage()));
}
示例3: MenuViewModel
//, Func<ProjectExplorerViewModel> projectExplorerViewModelBuilder, Func<EventAggregatorDebugViewModel> eventsDebugBuilder,)
public MenuViewModel(IEventAggregator eventAggregator, Func<TeapotViewModel> teapotBuilder, IScriptRunner script, ProjectManager manager)
{
_eventAggregator = eventAggregator;
Items = new BindableCollection<MenuItemViewModel> {
new MenuItemViewModel {
Header = "_FILE",
Items = new BindableCollection<MenuItemViewModel> {
new MenuItemViewModel {
Header = "_Open",
Items = new BindableCollection<MenuItemViewModel> {
new MenuItemViewModel {
Header = "_Project",
Action = () => _eventAggregator.Publish(new OpenProjectDialog())
},
new MenuItemViewModel {
Header = "Teapot",
Action = () => _eventAggregator.Publish(new AddTabViewCommand {Model = teapotBuilder()})
},
}
},
new MenuItemViewModel {
Header = "Close",
Action = () => _eventAggregator.Publish(new DebugCommand("close"))
}
}
},
new MenuItemViewModel {
Header = "_EDIT"
},
new MenuItemViewModel {
Header = "_VIEW"
},
new MenuItemViewModel {
Header = "_BUILD",
Items = new BindableCollection<MenuItemViewModel> {
new MenuItemViewModel {
Header = "_Build Project",
Action = () => script.Execute(manager.Project)
},
new MenuItemViewModel {
Header = "Teapot",
Action = () => _eventAggregator.Publish(new AddTabViewCommand {Model = teapotBuilder()})
},
}
},
new MenuItemViewModel {
Header = "_WINDOW"
},
new MenuItemViewModel {
Header = "_HELP"
}
};
}
示例4: MenuViewModel
public MenuViewModel(IEventAggregator eventAggregator,
Func<ProjectExplorerViewModel> projectExplorerViewModelBuilder,
Func<EventAggregatorDebugViewModel> eventsDebugBuilder,
Func<TeapotViewModel> teapotBuilder)
{
_eventAggregator = eventAggregator;
Items = new BindableCollection<MenuItemViewModel> {
new MenuItemViewModel {
Header = "_FILE",
Items = new BindableCollection<MenuItemViewModel> {
new MenuItemViewModel {
Header = "Open Teapot",
Action = () =>
_eventAggregator.Publish(new AddTabViewCommand {Model = teapotBuilder()})
},
new MenuItemViewModel {
Header = "Open Events Tool",
Action = () =>
_eventAggregator.Publish(new AddToolViewCommand {Model = eventsDebugBuilder()})
},
new MenuItemViewModel {
Header = "Open Project Explorer",
Action = () =>
_eventAggregator.Publish(new AddToolViewCommand {Model = projectExplorerViewModelBuilder()})
},
new MenuItemViewModel {
Header = "Add part",
Action = () => _eventAggregator.Publish(new AddPartCommand {Part = new JsonPartMeta {FilePath = @"C:\temp\OpenCad\temp.cadpart"}})
},
new MenuItemViewModel {
Header = "Open Part",
Action = () =>
_eventAggregator.Publish(new AddTabViewCommand {Model = new PartViewModel()})
}
}
},
new MenuItemViewModel {
Header = "_EDIT"
},
new MenuItemViewModel {
Header = "_VIEW"
},
new MenuItemViewModel {
Header = "_WINDOW"
},
new MenuItemViewModel {
Header = "_HELP"
}
};
}
示例5: ExpensesFilterVM
public ExpensesFilterVM(IEventAggregator eventAggregator)
{
//CashFlows = new BindableCollectionExt<ExpensesFilterEntityVM>();
//CashFlowGroups = new BindableCollectionExt<ExpensesFilterEntityVM>();
PropertyChanged += (s, e) => { eventAggregator.Publish(this); };
}
示例6: PublishChange
private static void PublishChange(IEventAggregator aggregator)
{
Task.Factory.StartNew(() =>
{
var message = new NetworkStatusChanged();
aggregator.Publish(message);
});
}
示例7: SpeakerViewModel
public SpeakerViewModel(IEventAggregator eventAggregator, IWindowManager windowManager, ILoggingService loggingService)
{
EventAggregator = eventAggregator;
_windowManager = windowManager;
_loggingService = loggingService;
EventAggregator.Publish(this);
GetEventPresentationsForSpeaker(Int32.Parse(App.EventId), Int32.Parse(App.PersonId));
}
示例8: MessageListViewModel
public MessageListViewModel(IEventAggregator eventAggregator)
{
ServiceControl.Instance.Messages()
.SubscribeOnBackground()
.Subscribe(ms => Messages = ms.DeserializeCollection<Message>());
this.ChangedProperty<Message>(nameof(SelectedMessage))
.Subscribe(m => eventAggregator.Publish(new MessageSelected() { Id = m.After?.Id }));
}
示例9: CardReader
public CardReader(ILog log, IEventAggregator eventAggregator)
{
Log = log;
EventAggregator = eventAggregator;
Log.Debug("CardReader constructed");
Connect();
KeepAliveTimer = new Timer(s => EventAggregator.Publish(new KeepAlive()), null, KeepAliveInterval, KeepAliveInterval);
}
示例10: TopNavigationViewModel
public TopNavigationViewModel(ImageGetter getter, IEventAggregator events)
{
_Events = events;
Commands = new List<CommandItem>
{
new CommandItem { Image = getter.Home, DoCommand = () => {_Events.Publish(new NavigationMessage { Action = NavigationCommand.Home });} },
new CommandItem { Image = getter.ArrowLeft, DoCommand = () => {throw new NotImplementedException("Left command is not implemented yet");} },
new CommandItem { Image = getter.ArrowRight, DoCommand = () => {throw new NotImplementedException("Right command is not implemented yet");} },
new CommandItem { Image = getter.Settings, DoCommand = () => {throw new NotImplementedException("Settings command is not implemented yet");} },
new CommandItem { Image = getter.Help, DoCommand = () => {throw new NotImplementedException("Help command is not implemented yet");} }
};
}
示例11: CarsRemoverCommand
public CarsRemoverCommand( IMouseInformation mouseInformation, Factories.Factories factories, IEventAggregator eventAggregator )
{
Contract.Requires( mouseInformation != null );
Contract.Requires( factories != null );
Contract.Requires( eventAggregator != null );
this._mouseInformation = mouseInformation;
this._mouseInformation.LeftButtonPressed.Subscribe( s =>
{
var carInserter = new CarsRemover( factories, s.Location );
eventAggregator.Publish( new AddControlToRoadLayer( carInserter ) );
} );
}
示例12: EditResource
public static void EditResource(IResourceModel resource, IEventAggregator eventAggregator)
{
if(eventAggregator == null)
{
throw new ArgumentNullException("eventAggregator");
}
if(resource != null)
{
switch(resource.ResourceType)
{
case ResourceType.WorkflowService:
eventAggregator.Publish(new AddWorkSurfaceMessage(resource));
break;
case ResourceType.Service:
eventAggregator.Publish(new ShowEditResourceWizardMessage(resource));
break;
case ResourceType.Source:
eventAggregator.Publish(new ShowEditResourceWizardMessage(resource));
break;
}
}
}
示例13: AlbumViewModel
public AlbumViewModel(Album album)
{
_events = IoC.Get<IEventAggregator>();
_windowManager = IoC.Get<IWindowManager>();
Model = album;
Tracks = new ReactiveList<TrackViewModel>();
Tracks.AddRange(album.Tracks.Select(x => new TrackViewModel(x)));
AddAlbumToPlaylistCommand = new ReactiveCommand();
AddAlbumToPlaylistCommand.Subscribe(param => _events.Publish(Tracks.Select(x => x.Track).ToList()));
EditorEditAlbumsCommand = new ReactiveCommand();
EditorEditAlbumsCommand.Subscribe(
param => _windowManager.ShowDialog(new AlbumTagEditorViewModel(Tracks.Select(x => x.Track.Model).ToList())));
}
示例14: ArtistViewModel
public ArtistViewModel(Artist artist)
{
Model = artist;
Albums = artist.Albums;
_events = IoC.Get<IEventAggregator>();
_windowManager = IoC.Get<IWindowManager>();
AddArtistToPlaylistCommand = new ReactiveCommand();
AddArtistToPlaylistCommand.Subscribe(
param => _events.Publish(Albums.SelectMany(x => x.Tracks).Select(x => x).ToList()));
EditorEditArtistsCommand = new ReactiveCommand();
EditorEditArtistsCommand.Subscribe(param => _windowManager.ShowDialog(
new ArtistTagEditorViewModel(Albums.SelectMany(x => x.Tracks).Select(x => x.Model).ToList())));
}
示例15: LoadAsync
/// <summary>
/// Loads the given URI by using an asynchronous request.
/// </summary>
/// <param name="requesters">The requesters to try.</param>
/// <param name="request">The data of the request to send.</param>
/// <param name="events">The event aggregator.</param>
/// <param name="cancel">
/// The token which can be used to cancel the request.
/// </param>
/// <returns>
/// The task which will eventually return the response.
/// </returns>
public static async Task<IResponse> LoadAsync(this IEnumerable<IRequester> requesters, IRequest request, IEventAggregator events, CancellationToken cancel)
{
foreach (var requester in requesters)
{
if (requester.SupportsProtocol(request.Address.Scheme))
{
using (var evt = new RequestStartEvent(requester, request))
{
if (events != null)
events.Publish(evt);
return await requester.RequestAsync(request, cancel).ConfigureAwait(false);
}
}
}
return default(IResponse);
}