├── samples
└── CodeBehind
│ ├── Pages
│ ├── _Imports.razor
│ ├── CounterListener.razor
│ ├── Counter.razor
│ ├── Index.razor
│ ├── Counter.razor.cs
│ ├── CounterListener.razor.cs
│ ├── _Host.cshtml
│ └── FetchData.razor
│ ├── wwwroot
│ ├── favicon.ico
│ └── css
│ │ ├── open-iconic
│ │ ├── font
│ │ │ ├── fonts
│ │ │ │ ├── open-iconic.eot
│ │ │ │ ├── open-iconic.otf
│ │ │ │ ├── open-iconic.ttf
│ │ │ │ ├── open-iconic.woff
│ │ │ │ └── open-iconic.svg
│ │ │ └── css
│ │ │ │ └── open-iconic-bootstrap.min.css
│ │ ├── ICON-LICENSE
│ │ ├── README.md
│ │ └── FONT-LICENSE
│ │ └── site.css
│ ├── appsettings.Development.json
│ ├── _Imports.razor
│ ├── appsettings.json
│ ├── Data
│ ├── WeatherForecast.cs
│ └── WeatherForecastService.cs
│ ├── Shared
│ ├── MainLayout.razor
│ └── NavMenu.razor
│ ├── CodeBehind.csproj
│ ├── App.razor
│ ├── Program.cs
│ └── Startup.cs
├── global.json
├── releases
├── EventAggregator.Blazor.1.0.0.nupkg
├── EventAggregator.Blazor.1.1.0.nupkg
├── EventAggregator.Blazor.1.2.0.nupkg
├── EventAggregator.Blazor.1.3.0.nupkg
├── EventAggregator.Blazor.1.4.0.nupkg
├── EventAggregator.Blazor.1.5.0.nupkg
└── EventAggregator.Blazor.2.0.0.nupkg
├── src
├── EventAggregatorOptions.cs
├── IHandle.cs
├── ServiceCollectionExtensions.cs
├── IEventAggregator.cs
├── Blazor.EventAggregator.sln
├── EventAggregator.Blazor.csproj
└── EventAggregator.cs
├── LICENSE
├── readme.md
└── .gitignore
/samples/CodeBehind/Pages/_Imports.razor:
--------------------------------------------------------------------------------
1 | @layout MainLayout
2 |
--------------------------------------------------------------------------------
/global.json:
--------------------------------------------------------------------------------
1 | {
2 | "sdk": {
3 | "version": "3.1.100",
4 | "rollForward": "latestFeature"
5 | }
6 | }
--------------------------------------------------------------------------------
/samples/CodeBehind/wwwroot/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mikoskinen/Blazor.EventAggregator/HEAD/samples/CodeBehind/wwwroot/favicon.ico
--------------------------------------------------------------------------------
/releases/EventAggregator.Blazor.1.0.0.nupkg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mikoskinen/Blazor.EventAggregator/HEAD/releases/EventAggregator.Blazor.1.0.0.nupkg
--------------------------------------------------------------------------------
/releases/EventAggregator.Blazor.1.1.0.nupkg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mikoskinen/Blazor.EventAggregator/HEAD/releases/EventAggregator.Blazor.1.1.0.nupkg
--------------------------------------------------------------------------------
/releases/EventAggregator.Blazor.1.2.0.nupkg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mikoskinen/Blazor.EventAggregator/HEAD/releases/EventAggregator.Blazor.1.2.0.nupkg
--------------------------------------------------------------------------------
/releases/EventAggregator.Blazor.1.3.0.nupkg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mikoskinen/Blazor.EventAggregator/HEAD/releases/EventAggregator.Blazor.1.3.0.nupkg
--------------------------------------------------------------------------------
/releases/EventAggregator.Blazor.1.4.0.nupkg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mikoskinen/Blazor.EventAggregator/HEAD/releases/EventAggregator.Blazor.1.4.0.nupkg
--------------------------------------------------------------------------------
/releases/EventAggregator.Blazor.1.5.0.nupkg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mikoskinen/Blazor.EventAggregator/HEAD/releases/EventAggregator.Blazor.1.5.0.nupkg
--------------------------------------------------------------------------------
/releases/EventAggregator.Blazor.2.0.0.nupkg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mikoskinen/Blazor.EventAggregator/HEAD/releases/EventAggregator.Blazor.2.0.0.nupkg
--------------------------------------------------------------------------------
/samples/CodeBehind/Pages/CounterListener.razor:
--------------------------------------------------------------------------------
1 | @page "/counterListener"
2 | @inherits CounterListenerComponent
3 |
4 |
Counter Listener
5 |
6 | Current count: @currentCount
--------------------------------------------------------------------------------
/samples/CodeBehind/wwwroot/css/open-iconic/font/fonts/open-iconic.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mikoskinen/Blazor.EventAggregator/HEAD/samples/CodeBehind/wwwroot/css/open-iconic/font/fonts/open-iconic.eot
--------------------------------------------------------------------------------
/samples/CodeBehind/wwwroot/css/open-iconic/font/fonts/open-iconic.otf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mikoskinen/Blazor.EventAggregator/HEAD/samples/CodeBehind/wwwroot/css/open-iconic/font/fonts/open-iconic.otf
--------------------------------------------------------------------------------
/samples/CodeBehind/wwwroot/css/open-iconic/font/fonts/open-iconic.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mikoskinen/Blazor.EventAggregator/HEAD/samples/CodeBehind/wwwroot/css/open-iconic/font/fonts/open-iconic.ttf
--------------------------------------------------------------------------------
/samples/CodeBehind/wwwroot/css/open-iconic/font/fonts/open-iconic.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mikoskinen/Blazor.EventAggregator/HEAD/samples/CodeBehind/wwwroot/css/open-iconic/font/fonts/open-iconic.woff
--------------------------------------------------------------------------------
/samples/CodeBehind/appsettings.Development.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "LogLevel": {
4 | "Default": "Debug",
5 | "System": "Information",
6 | "Microsoft": "Information"
7 | }
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/samples/CodeBehind/Pages/Counter.razor:
--------------------------------------------------------------------------------
1 | @page "/counter"
2 | @inherits CounterComponent
3 |
4 | Counter
5 |
6 | Current count: @currentCount
7 |
8 | Click me
--------------------------------------------------------------------------------
/samples/CodeBehind/_Imports.razor:
--------------------------------------------------------------------------------
1 | @using System.Net.Http
2 | @using Microsoft.AspNetCore.Components.Forms
3 | @using Microsoft.AspNetCore.Components.Routing
4 | @using Microsoft.JSInterop
5 | @using CodeBehind.Shared
6 | @using Microsoft.AspNetCore.Components.Web
--------------------------------------------------------------------------------
/samples/CodeBehind/Pages/Index.razor:
--------------------------------------------------------------------------------
1 | @page "/"
2 |
3 | EventAggregator.Blazor using code behind
4 |
5 | Counter publisher
6 |
7 |
8 | Counter subscriber
9 |
10 |
--------------------------------------------------------------------------------
/samples/CodeBehind/appsettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "LogLevel": {
4 | "Default": "Information",
5 | "Microsoft": "Warning",
6 | "Microsoft.Hosting.Lifetime": "Information"
7 | }
8 | },
9 | "AllowedHosts": "*"
10 | }
11 |
--------------------------------------------------------------------------------
/samples/CodeBehind/Data/WeatherForecast.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace CodeBehind.Data
4 | {
5 | public class WeatherForecast
6 | {
7 | public DateTime Date { get; set; }
8 |
9 | public int TemperatureC { get; set; }
10 |
11 | public int TemperatureF { get; set; }
12 |
13 | public string Summary { get; set; }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/samples/CodeBehind/Shared/MainLayout.razor:
--------------------------------------------------------------------------------
1 | @inherits LayoutComponentBase
2 |
3 |
6 |
7 |
8 |
11 |
12 |
13 | @Body
14 |
15 |
16 |
--------------------------------------------------------------------------------
/src/EventAggregatorOptions.cs:
--------------------------------------------------------------------------------
1 | namespace Microsoft.Extensions.DependencyInjection
2 | {
3 | public class EventAggregatorOptions
4 | {
5 | ///
6 | /// If true, Event Aggregator tries to run ComponentBase.StateHasChanged for the target component after
7 | /// it has handled the message.
8 | ///
9 | public bool AutoRefresh { get; set; }
10 | }
11 | }
--------------------------------------------------------------------------------
/samples/CodeBehind/CodeBehind.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netcoreapp3.1
5 | 7.3
6 | true
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/samples/CodeBehind/App.razor:
--------------------------------------------------------------------------------
1 | @*
2 | The Router component displays whichever component has a @page
3 | directive matching the current URI.
4 | *@
5 |
6 |
7 |
8 |
9 |
10 | Page not found
11 | Sorry, but there's nothing here!
12 |
13 |
--------------------------------------------------------------------------------
/src/IHandle.cs:
--------------------------------------------------------------------------------
1 | using System.Threading.Tasks;
2 |
3 | namespace EventAggregator.Blazor
4 | {
5 | ///
6 | /// Describes a class which can handle a particular type of message.
7 | ///
8 | /// The type of message to handle.
9 | public interface IHandle
10 | {
11 | ///
12 | /// Handles the message.
13 | ///
14 | /// The message.
15 | /// A task that represents the operation.
16 | Task HandleAsync(TMessage message);
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/samples/CodeBehind/Pages/Counter.razor.cs:
--------------------------------------------------------------------------------
1 | using EventAggregator.Blazor;
2 | using Microsoft.AspNetCore.Components;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Linq;
6 | using System.Threading.Tasks;
7 |
8 | namespace CodeBehind.Pages
9 | {
10 | public class CounterComponent : ComponentBase
11 | {
12 | [Inject]
13 | private IEventAggregator _eventAggregator { get; set; }
14 |
15 | public int currentCount = 0;
16 |
17 | public async Task IncrementCountAsync()
18 | {
19 | currentCount++;
20 | await _eventAggregator.PublishAsync(new CounterIncreasedMessage());
21 | }
22 | }
23 |
24 | public class CounterIncreasedMessage
25 | {
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/samples/CodeBehind/Pages/CounterListener.razor.cs:
--------------------------------------------------------------------------------
1 | using EventAggregator.Blazor;
2 | using Microsoft.AspNetCore.Components;
3 | using System.Threading.Tasks;
4 |
5 | namespace CodeBehind.Pages
6 | {
7 | public class CounterListenerComponent : ComponentBase, IHandle
8 | {
9 | [Inject]
10 | private IEventAggregator _eventAggregator { get; set; }
11 |
12 | public int currentCount = 0;
13 |
14 | protected override void OnInitialized()
15 | {
16 | _eventAggregator.Subscribe(this);
17 | }
18 |
19 | public Task HandleAsync(CounterIncreasedMessage message)
20 | {
21 | currentCount += 1;
22 | return Task.CompletedTask;
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/samples/CodeBehind/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Threading.Tasks;
6 | using Microsoft.AspNetCore;
7 | using Microsoft.AspNetCore.Hosting;
8 | using Microsoft.Extensions.Configuration;
9 | using Microsoft.Extensions.Hosting;
10 | using Microsoft.Extensions.Logging;
11 |
12 | namespace CodeBehind
13 | {
14 | public class Program
15 | {
16 | public static void Main(string[] args)
17 | {
18 | CreateHostBuilder(args).Build().Run();
19 | }
20 |
21 | public static IHostBuilder CreateHostBuilder(string[] args) =>
22 | Host.CreateDefaultBuilder(args)
23 | .ConfigureWebHostDefaults(webBuilder =>
24 | {
25 | webBuilder.UseStartup();
26 | });
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/samples/CodeBehind/Data/WeatherForecastService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using System.Threading.Tasks;
4 |
5 | namespace CodeBehind.Data
6 | {
7 | public class WeatherForecastService
8 | {
9 | private static string[] Summaries = new[]
10 | {
11 | "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
12 | };
13 |
14 | public Task GetForecastAsync(DateTime startDate)
15 | {
16 | var rng = new Random();
17 | return Task.FromResult(Enumerable.Range(1, 5).Select(index => new WeatherForecast
18 | {
19 | Date = startDate.AddDays(index),
20 | TemperatureC = rng.Next(-20, 55),
21 | Summary = Summaries[rng.Next(Summaries.Length)]
22 | }).ToArray());
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/ServiceCollectionExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using EventAggregator.Blazor;
3 |
4 | // ReSharper disable once CheckNamespace
5 | namespace Microsoft.Extensions.DependencyInjection
6 | {
7 | public static class ServiceCollectionExtensions
8 | {
9 | ///
10 | /// Adds IEventAggregator as a singleton
11 | ///
12 | /// Service collection
13 | /// Service collection
14 | public static IServiceCollection AddEventAggregator(this IServiceCollection services, Action configure = null)
15 | {
16 | services.AddSingleton();
17 |
18 | if (configure != null)
19 | {
20 | services.Configure(configure);
21 | }
22 |
23 | return services;
24 | }
25 | }
26 | }
--------------------------------------------------------------------------------
/src/IEventAggregator.cs:
--------------------------------------------------------------------------------
1 | using System.Threading.Tasks;
2 |
3 | namespace EventAggregator.Blazor
4 | {
5 | public interface IEventAggregator
6 | {
7 | ///
8 | /// Subscribes an instance to all events declared through implementations of
9 | ///
10 | /// The instance to subscribe for event publication.
11 | void Subscribe(object subscriber);
12 |
13 | ///
14 | /// Unsubscribes the instance from all events.
15 | ///
16 | /// The instance to unsubscribe.
17 | void Unsubscribe(object subscriber);
18 |
19 | ///
20 | /// Publishes a message.
21 | ///
22 | /// The message instance.
23 | /// A task that represents the asynchronous operation.
24 | Task PublishAsync(object message);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2019 Mikael Koskinen
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/samples/CodeBehind/wwwroot/css/open-iconic/ICON-LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2014 Waybury
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
--------------------------------------------------------------------------------
/samples/CodeBehind/Pages/_Host.cshtml:
--------------------------------------------------------------------------------
1 | @page "/"
2 | @namespace CodeBehind.Pages
3 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
4 |
5 |
6 |
7 |
8 |
9 |
10 | CodeBehind
11 |
12 |
13 |
14 |
15 |
16 |
21 |
22 |
23 |
24 |
25 | @(await Html.RenderComponentAsync(RenderMode.Server))
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/samples/CodeBehind/Pages/FetchData.razor:
--------------------------------------------------------------------------------
1 | @page "/fetchdata"
2 | @using CodeBehind.Data
3 | @inject WeatherForecastService ForecastService
4 |
5 | Weather forecast
6 |
7 | This component demonstrates fetching data from a service.
8 |
9 | @if (forecasts == null)
10 | {
11 | Loading...
12 | }
13 | else
14 | {
15 |
16 |
17 |
18 | Date
19 | Temp. (C)
20 | Temp. (F)
21 | Summary
22 |
23 |
24 |
25 | @foreach (var forecast in forecasts)
26 | {
27 |
28 | @forecast.Date.ToShortDateString()
29 | @forecast.TemperatureC
30 | @forecast.TemperatureF
31 | @forecast.Summary
32 |
33 | }
34 |
35 |
36 | }
37 |
38 | @functions {
39 | WeatherForecast[] forecasts;
40 |
41 | protected override async Task OnInitializedAsync()
42 | {
43 | forecasts = await ForecastService.GetForecastAsync(DateTime.Now);
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/samples/CodeBehind/Shared/NavMenu.razor:
--------------------------------------------------------------------------------
1 |
7 |
8 |
27 |
28 | @functions {
29 | bool collapseNavMenu = true;
30 |
31 | string NavMenuCssClass => collapseNavMenu ? "collapse" : null;
32 |
33 | void ToggleNavMenu()
34 | {
35 | collapseNavMenu = !collapseNavMenu;
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/samples/CodeBehind/Startup.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 | using Microsoft.AspNetCore.Builder;
6 | using Microsoft.AspNetCore.Hosting;
7 | using Microsoft.AspNetCore.Http;
8 | using Microsoft.AspNetCore.HttpsPolicy;
9 | using Microsoft.Extensions.DependencyInjection;
10 | using Microsoft.Extensions.Hosting;
11 | using CodeBehind.Data;
12 | using EventAggregator.Blazor;
13 |
14 | namespace CodeBehind
15 | {
16 | public class Startup
17 | {
18 | // This method gets called by the runtime. Use this method to add services to the container.
19 | // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
20 | public void ConfigureServices(IServiceCollection services)
21 | {
22 | services.AddRazorPages();
23 | services.AddServerSideBlazor();
24 | services.AddSingleton();
25 |
26 | services.AddEventAggregator(options => options.AutoRefresh = true);
27 | }
28 |
29 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
30 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
31 | {
32 | if (env.IsDevelopment())
33 | {
34 | app.UseDeveloperExceptionPage();
35 | }
36 | else
37 | {
38 | // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
39 | app.UseHsts();
40 | }
41 |
42 | app.UseHttpsRedirection();
43 |
44 | app.UseStaticFiles();
45 |
46 | app.UseRouting();
47 |
48 | app.UseEndpoints(endpoints =>
49 | {
50 | endpoints.MapBlazorHub();
51 | endpoints.MapFallbackToPage("/_Host");
52 | });
53 | }
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/src/Blazor.EventAggregator.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.28527.54
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EventAggregator.Blazor", "EventAggregator.Blazor.csproj", "{C6623EF9-380D-44CF-A495-39461E78C3EF}"
7 | EndProject
8 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{E87D2F2C-D4A3-4144-BA7A-000B87A2705D}"
9 | EndProject
10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeBehind", "..\samples\CodeBehind\CodeBehind.csproj", "{AA15D944-29D1-4E8F-9AD1-FCBF087A27E2}"
11 | EndProject
12 | Global
13 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
14 | Debug|Any CPU = Debug|Any CPU
15 | Release|Any CPU = Release|Any CPU
16 | EndGlobalSection
17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
18 | {C6623EF9-380D-44CF-A495-39461E78C3EF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
19 | {C6623EF9-380D-44CF-A495-39461E78C3EF}.Debug|Any CPU.Build.0 = Debug|Any CPU
20 | {C6623EF9-380D-44CF-A495-39461E78C3EF}.Release|Any CPU.ActiveCfg = Release|Any CPU
21 | {C6623EF9-380D-44CF-A495-39461E78C3EF}.Release|Any CPU.Build.0 = Release|Any CPU
22 | {AA15D944-29D1-4E8F-9AD1-FCBF087A27E2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
23 | {AA15D944-29D1-4E8F-9AD1-FCBF087A27E2}.Debug|Any CPU.Build.0 = Debug|Any CPU
24 | {AA15D944-29D1-4E8F-9AD1-FCBF087A27E2}.Release|Any CPU.ActiveCfg = Release|Any CPU
25 | {AA15D944-29D1-4E8F-9AD1-FCBF087A27E2}.Release|Any CPU.Build.0 = Release|Any CPU
26 | EndGlobalSection
27 | GlobalSection(SolutionProperties) = preSolution
28 | HideSolutionNode = FALSE
29 | EndGlobalSection
30 | GlobalSection(NestedProjects) = preSolution
31 | {AA15D944-29D1-4E8F-9AD1-FCBF087A27E2} = {E87D2F2C-D4A3-4144-BA7A-000B87A2705D}
32 | EndGlobalSection
33 | GlobalSection(ExtensibilityGlobals) = postSolution
34 | SolutionGuid = {93F1D308-8BE3-4EBE-9BB9-DE3F2DB15D73}
35 | EndGlobalSection
36 | EndGlobal
37 |
--------------------------------------------------------------------------------
/src/EventAggregator.Blazor.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.1
5 | 3.0
6 | true
7 | 7.3
8 | true
9 | Mikael Koskinen
10 |
11 | Lightweight Event Aggregator for Blazor.
12 | https://github.com/mikoskinen/Blazor.EventAggregator
13 | EventAggregator.Blazor
14 | EventAggregator.Blazor
15 | EventAggregator.Blazor
16 | EventAggregator.Blazor
17 | MIT
18 | v
19 | 2.0
20 | Library
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 | $(PublishDir)
32 | $(MSBuildThisFileDirectory)$(PublishDir)
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/samples/CodeBehind/wwwroot/css/site.css:
--------------------------------------------------------------------------------
1 | @import url('open-iconic/font/css/open-iconic-bootstrap.min.css');
2 |
3 | html, body {
4 | font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
5 | }
6 |
7 | app {
8 | position: relative;
9 | display: flex;
10 | flex-direction: column;
11 | }
12 |
13 | .top-row {
14 | height: 3.5rem;
15 | display: flex;
16 | align-items: center;
17 | }
18 |
19 | .main {
20 | flex: 1;
21 | }
22 |
23 | .main .top-row {
24 | background-color: #e6e6e6;
25 | border-bottom: 1px solid #d6d5d5;
26 | }
27 |
28 | .sidebar {
29 | background-image: linear-gradient(180deg, rgb(5, 39, 103) 0%, #3a0647 70%);
30 | }
31 |
32 | .sidebar .top-row {
33 | background-color: rgba(0,0,0,0.4);
34 | }
35 |
36 | .sidebar .navbar-brand {
37 | font-size: 1.1rem;
38 | }
39 |
40 | .sidebar .oi {
41 | width: 2rem;
42 | font-size: 1.1rem;
43 | vertical-align: text-top;
44 | top: -2px;
45 | }
46 |
47 | .nav-item {
48 | font-size: 0.9rem;
49 | padding-bottom: 0.5rem;
50 | }
51 |
52 | .nav-item:first-of-type {
53 | padding-top: 1rem;
54 | }
55 |
56 | .nav-item:last-of-type {
57 | padding-bottom: 1rem;
58 | }
59 |
60 | .nav-item a {
61 | color: #d7d7d7;
62 | border-radius: 4px;
63 | height: 3rem;
64 | display: flex;
65 | align-items: center;
66 | line-height: 3rem;
67 | }
68 |
69 | .nav-item a.active {
70 | background-color: rgba(255,255,255,0.25);
71 | color: white;
72 | }
73 |
74 | .nav-item a:hover {
75 | background-color: rgba(255,255,255,0.1);
76 | color: white;
77 | }
78 |
79 | .content {
80 | padding-top: 1.1rem;
81 | }
82 |
83 | .navbar-toggler {
84 | background-color: rgba(255, 255, 255, 0.1);
85 | }
86 |
87 | .valid.modified:not([type=checkbox]) {
88 | outline: 1px solid #26b050;
89 | }
90 |
91 | .invalid {
92 | outline: 1px solid red;
93 | }
94 |
95 | .validation-message {
96 | color: red;
97 | }
98 |
99 | @media (max-width: 767.98px) {
100 | .main .top-row {
101 | display: none;
102 | }
103 | }
104 |
105 | @media (min-width: 768px) {
106 | app {
107 | flex-direction: row;
108 | }
109 |
110 | .sidebar {
111 | width: 250px;
112 | height: 100vh;
113 | position: sticky;
114 | top: 0;
115 | }
116 |
117 | .main .top-row {
118 | position: sticky;
119 | top: 0;
120 | }
121 |
122 | .main > div {
123 | padding-left: 2rem !important;
124 | padding-right: 1.5rem !important;
125 | }
126 |
127 | .navbar-toggler {
128 | display: none;
129 | }
130 |
131 | .sidebar .collapse {
132 | /* Never collapse the sidebar for wide screens */
133 | display: block;
134 | }
135 | }
136 |
--------------------------------------------------------------------------------
/samples/CodeBehind/wwwroot/css/open-iconic/README.md:
--------------------------------------------------------------------------------
1 | [Open Iconic v1.1.1](http://useiconic.com/open)
2 | ===========
3 |
4 | ### Open Iconic is the open source sibling of [Iconic](http://useiconic.com). It is a hyper-legible collection of 223 icons with a tiny footprint—ready to use with Bootstrap and Foundation. [View the collection](http://useiconic.com/open#icons)
5 |
6 |
7 |
8 | ## What's in Open Iconic?
9 |
10 | * 223 icons designed to be legible down to 8 pixels
11 | * Super-light SVG files - 61.8 for the entire set
12 | * SVG sprite—the modern replacement for icon fonts
13 | * Webfont (EOT, OTF, SVG, TTF, WOFF), PNG and WebP formats
14 | * Webfont stylesheets (including versions for Bootstrap and Foundation) in CSS, LESS, SCSS and Stylus formats
15 | * PNG and WebP raster images in 8px, 16px, 24px, 32px, 48px and 64px.
16 |
17 |
18 | ## Getting Started
19 |
20 | #### For code samples and everything else you need to get started with Open Iconic, check out our [Icons](http://useiconic.com/open#icons) and [Reference](http://useiconic.com/open#reference) sections.
21 |
22 | ### General Usage
23 |
24 | #### Using Open Iconic's SVGs
25 |
26 | We like SVGs and we think they're the way to display icons on the web. Since Open Iconic are just basic SVGs, we suggest you display them like you would any other image (don't forget the `alt` attribute).
27 |
28 | ```
29 |
30 | ```
31 |
32 | #### Using Open Iconic's SVG Sprite
33 |
34 | Open Iconic also comes in a SVG sprite which allows you to display all the icons in the set with a single request. It's like an icon font, without being a hack.
35 |
36 | Adding an icon from an SVG sprite is a little different than what you're used to, but it's still a piece of cake. *Tip: To make your icons easily style able, we suggest adding a general class to the* `` *tag and a unique class name for each different icon in the* `` *tag.*
37 |
38 | ```
39 |
40 |
41 |
42 | ```
43 |
44 | Sizing icons only needs basic CSS. All the icons are in a square format, so just set the `` tag with equal width and height dimensions.
45 |
46 | ```
47 | .icon {
48 | width: 16px;
49 | height: 16px;
50 | }
51 | ```
52 |
53 | Coloring icons is even easier. All you need to do is set the `fill` rule on the `` tag.
54 |
55 | ```
56 | .icon-account-login {
57 | fill: #f00;
58 | }
59 | ```
60 |
61 | To learn more about SVG Sprites, read [Chris Coyier's guide](http://css-tricks.com/svg-sprites-use-better-icon-fonts/).
62 |
63 | #### Using Open Iconic's Icon Font...
64 |
65 |
66 | ##### …with Bootstrap
67 |
68 | You can find our Bootstrap stylesheets in `font/css/open-iconic-bootstrap.{css, less, scss, styl}`
69 |
70 |
71 | ```
72 |
73 | ```
74 |
75 |
76 | ```
77 |
78 | ```
79 |
80 | ##### …with Foundation
81 |
82 | You can find our Foundation stylesheets in `font/css/open-iconic-foundation.{css, less, scss, styl}`
83 |
84 | ```
85 |
86 | ```
87 |
88 |
89 | ```
90 |
91 | ```
92 |
93 | ##### …on its own
94 |
95 | You can find our default stylesheets in `font/css/open-iconic.{css, less, scss, styl}`
96 |
97 | ```
98 |
99 | ```
100 |
101 | ```
102 |
103 | ```
104 |
105 |
106 | ## License
107 |
108 | ### Icons
109 |
110 | All code (including SVG markup) is under the [MIT License](http://opensource.org/licenses/MIT).
111 |
112 | ### Fonts
113 |
114 | All fonts are under the [SIL Licensed](http://scripts.sil.org/cms/scripts/page.php?item_id=OFL_web).
115 |
--------------------------------------------------------------------------------
/samples/CodeBehind/wwwroot/css/open-iconic/FONT-LICENSE:
--------------------------------------------------------------------------------
1 | SIL OPEN FONT LICENSE Version 1.1
2 |
3 | Copyright (c) 2014 Waybury
4 |
5 | PREAMBLE
6 | The goals of the Open Font License (OFL) are to stimulate worldwide
7 | development of collaborative font projects, to support the font creation
8 | efforts of academic and linguistic communities, and to provide a free and
9 | open framework in which fonts may be shared and improved in partnership
10 | with others.
11 |
12 | The OFL allows the licensed fonts to be used, studied, modified and
13 | redistributed freely as long as they are not sold by themselves. The
14 | fonts, including any derivative works, can be bundled, embedded,
15 | redistributed and/or sold with any software provided that any reserved
16 | names are not used by derivative works. The fonts and derivatives,
17 | however, cannot be released under any other type of license. The
18 | requirement for fonts to remain under this license does not apply
19 | to any document created using the fonts or their derivatives.
20 |
21 | DEFINITIONS
22 | "Font Software" refers to the set of files released by the Copyright
23 | Holder(s) under this license and clearly marked as such. This may
24 | include source files, build scripts and documentation.
25 |
26 | "Reserved Font Name" refers to any names specified as such after the
27 | copyright statement(s).
28 |
29 | "Original Version" refers to the collection of Font Software components as
30 | distributed by the Copyright Holder(s).
31 |
32 | "Modified Version" refers to any derivative made by adding to, deleting,
33 | or substituting -- in part or in whole -- any of the components of the
34 | Original Version, by changing formats or by porting the Font Software to a
35 | new environment.
36 |
37 | "Author" refers to any designer, engineer, programmer, technical
38 | writer or other person who contributed to the Font Software.
39 |
40 | PERMISSION & CONDITIONS
41 | Permission is hereby granted, free of charge, to any person obtaining
42 | a copy of the Font Software, to use, study, copy, merge, embed, modify,
43 | redistribute, and sell modified and unmodified copies of the Font
44 | Software, subject to the following conditions:
45 |
46 | 1) Neither the Font Software nor any of its individual components,
47 | in Original or Modified Versions, may be sold by itself.
48 |
49 | 2) Original or Modified Versions of the Font Software may be bundled,
50 | redistributed and/or sold with any software, provided that each copy
51 | contains the above copyright notice and this license. These can be
52 | included either as stand-alone text files, human-readable headers or
53 | in the appropriate machine-readable metadata fields within text or
54 | binary files as long as those fields can be easily viewed by the user.
55 |
56 | 3) No Modified Version of the Font Software may use the Reserved Font
57 | Name(s) unless explicit written permission is granted by the corresponding
58 | Copyright Holder. This restriction only applies to the primary font name as
59 | presented to the users.
60 |
61 | 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
62 | Software shall not be used to promote, endorse or advertise any
63 | Modified Version, except to acknowledge the contribution(s) of the
64 | Copyright Holder(s) and the Author(s) or with their explicit written
65 | permission.
66 |
67 | 5) The Font Software, modified or unmodified, in part or in whole,
68 | must be distributed entirely under this license, and must not be
69 | distributed under any other license. The requirement for fonts to
70 | remain under this license does not apply to any document created
71 | using the Font Software.
72 |
73 | TERMINATION
74 | This license becomes null and void if any of the above conditions are
75 | not met.
76 |
77 | DISCLAIMER
78 | THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
79 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
80 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
81 | OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
82 | COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
83 | INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
84 | DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
85 | FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
86 | OTHER DEALINGS IN THE FONT SOFTWARE.
87 |
--------------------------------------------------------------------------------
/readme.md:
--------------------------------------------------------------------------------
1 | # Blazor.EventAggregator
2 |
3 | Blazor.EventAggregator is a lightweight Event Aggregator for Blazor.
4 |
5 | * 3/2020: Updated to work with .NET Core v3.1.0
6 |
7 | Event aggregator is used for indirect component to component communication. In event aggregator pattern you have message/event publishers and subscribers. In the case of Blazor, component can publish its events and other component(s) can react to those events.
8 |
9 | [](https://www.nuget.org/packages/EventAggregator.Blazor/)
10 |
11 | ### Note:
12 |
13 | Blazor.EventAggregator is completely based on the work done in Caliburn.Micro. The source code was copied from it and then altered to work with Blazor.
14 |
15 | Also note that the library has only been tested with the server-side version of Blazor. There's no known issues with the WebAssembly-version of Blazor.
16 |
17 | ## Getting Started
18 |
19 | First register EventAggregator in app’s ConfigureServices:
20 | ```
21 | public void ConfigureServices(IServiceCollection services)
22 | {
23 | services.AddEventAggregator();
24 | }
25 | ```
26 |
27 | The rest depends on if you’re using components with code-behinds (inheritance) or without inheritance. The following guidance is for code-behind scenarios.
28 |
29 | ### Creating the publisher
30 |
31 | To create an event publishing component, first inject IEventAggregator:
32 |
33 | ```
34 | [Inject]
35 | private IEventAggregator _eventAggregator { get; set; }
36 | ```
37 |
38 | Then publish the message when something interesting happens:
39 |
40 | ```
41 | await _eventAggregator.PublishAsync(new CounterIncreasedMessage());
42 | ```
43 |
44 | Here’s a full example of a publisher:
45 | ```
46 | public class CounterComponent : ComponentBase
47 | {
48 | [Inject]
49 | private IEventAggregator _eventAggregator { get; set; }
50 |
51 | public int currentCount = 0;
52 |
53 | public async Task IncrementCountAsync()
54 | {
55 | currentCount++;
56 | await _eventAggregator.PublishAsync(new CounterIncreasedMessage());
57 | }
58 | }
59 |
60 | public class CounterIncreasedMessage
61 | {
62 | }
63 | ```
64 |
65 | ### Creating the subscriber
66 |
67 | To create an event subscriber, also start by injecting IEventAggregator:
68 |
69 | ```
70 | [Inject]
71 | private IEventAggregator _eventAggregator { get; set; }
72 | ```
73 | Then make sure to add and implement the IHandle interface for all the event’s your component is interested in:
74 |
75 | ```
76 | public class CounterListenerComponent : ComponentBase, IHandle
77 | ...
78 | public Task HandleAsync(CounterIncreasedMessage message)
79 | {
80 | currentCount += 1;
81 | return Task.CompletedTask;
82 | }
83 | ```
84 |
85 | Here’s full example of a subscriber:
86 |
87 | ```
88 | public class CounterListenerComponent : ComponentBase, IHandle
89 | {
90 | [Inject]
91 | private IEventAggregator _eventAggregator { get; set; }
92 |
93 | public int currentCount = 0;
94 |
95 | protected override void OnInit()
96 | {
97 | _eventAggregator.Subscribe(this);
98 | }
99 |
100 | public Task HandleAsync(CounterIncreasedMessage message)
101 | {
102 | currentCount += 1;
103 | return Task.CompletedTask;
104 | }
105 | }
106 | ```
107 |
108 | ## Note about auto refresh
109 |
110 | The library can try to automatically call subscriber component's StateHasChanged after it has handled the event. By default this functionality is disabled. You can enable it through options:
111 |
112 | ```
113 | services.AddEventAggregator(options => options.AutoRefresh = true);
114 | ```
115 |
116 | Auto refresh is based on reflection and it assumes that the subscriber inherits from ComponentBase.
117 |
118 | ## Samples
119 |
120 | The project site contains a full working sample of the code-behind model in the samples-folder.
121 |
122 | ## Requirements
123 | The library has been developed and tested using the following tools:
124 |
125 | * .NET Core 3.1
126 | * Visual Studio 2019
127 |
128 | ## Acknowledgements
129 | Work is based on the code available in Caliburn.Micro.
130 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 | ##
4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
5 |
6 | # User-specific files
7 | *.suo
8 | *.user
9 | *.userosscache
10 | *.sln.docstates
11 |
12 | # User-specific files (MonoDevelop/Xamarin Studio)
13 | *.userprefs
14 |
15 | # Build results
16 | [Dd]ebug/
17 | [Dd]ebugPublic/
18 | [Rr]elease/
19 | [Rr]eleases/
20 | x64/
21 | x86/
22 | bld/
23 | [Bb]in/
24 | [Oo]bj/
25 | [Ll]og/
26 |
27 | # Visual Studio 2015 cache/options directory
28 | .vs/
29 | # Uncomment if you have tasks that create the project's static files in wwwroot
30 | #wwwroot/
31 |
32 | # MSTest test Results
33 | [Tt]est[Rr]esult*/
34 | [Bb]uild[Ll]og.*
35 |
36 | # NUNIT
37 | *.VisualState.xml
38 | TestResult.xml
39 |
40 | # Build Results of an ATL Project
41 | [Dd]ebugPS/
42 | [Rr]eleasePS/
43 | dlldata.c
44 |
45 | # .NET Core
46 | project.lock.json
47 | project.fragment.lock.json
48 | artifacts/
49 | **/Properties/launchSettings.json
50 |
51 | *_i.c
52 | *_p.c
53 | *_i.h
54 | *.ilk
55 | *.meta
56 | *.obj
57 | *.pch
58 | *.pdb
59 | *.pgc
60 | *.pgd
61 | *.rsp
62 | *.sbr
63 | *.tlb
64 | *.tli
65 | *.tlh
66 | *.tmp
67 | *.tmp_proj
68 | *.log
69 | *.vspscc
70 | *.vssscc
71 | .builds
72 | *.pidb
73 | *.svclog
74 | *.scc
75 |
76 | # Chutzpah Test files
77 | _Chutzpah*
78 |
79 | # Visual C++ cache files
80 | ipch/
81 | *.aps
82 | *.ncb
83 | *.opendb
84 | *.opensdf
85 | *.sdf
86 | *.cachefile
87 | *.VC.db
88 | *.VC.VC.opendb
89 |
90 | # Visual Studio profiler
91 | *.psess
92 | *.vsp
93 | *.vspx
94 | *.sap
95 |
96 | # TFS 2012 Local Workspace
97 | $tf/
98 |
99 | # Guidance Automation Toolkit
100 | *.gpState
101 |
102 | # ReSharper is a .NET coding add-in
103 | _ReSharper*/
104 | *.[Rr]e[Ss]harper
105 | *.DotSettings.user
106 |
107 | # JustCode is a .NET coding add-in
108 | .JustCode
109 |
110 | # TeamCity is a build add-in
111 | _TeamCity*
112 |
113 | # DotCover is a Code Coverage Tool
114 | *.dotCover
115 |
116 | # Visual Studio code coverage results
117 | *.coverage
118 | *.coveragexml
119 |
120 | # NCrunch
121 | _NCrunch_*
122 | .*crunch*.local.xml
123 | nCrunchTemp_*
124 |
125 | # MightyMoose
126 | *.mm.*
127 | AutoTest.Net/
128 |
129 | # Web workbench (sass)
130 | .sass-cache/
131 |
132 | # Installshield output folder
133 | [Ee]xpress/
134 |
135 | # DocProject is a documentation generator add-in
136 | DocProject/buildhelp/
137 | DocProject/Help/*.HxT
138 | DocProject/Help/*.HxC
139 | DocProject/Help/*.hhc
140 | DocProject/Help/*.hhk
141 | DocProject/Help/*.hhp
142 | DocProject/Help/Html2
143 | DocProject/Help/html
144 |
145 | # Click-Once directory
146 | publish/
147 |
148 | # Publish Web Output
149 | *.[Pp]ublish.xml
150 | *.azurePubxml
151 | # TODO: Comment the next line if you want to checkin your web deploy settings
152 | # but database connection strings (with potential passwords) will be unencrypted
153 | *.pubxml
154 | *.publishproj
155 |
156 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
157 | # checkin your Azure Web App publish settings, but sensitive information contained
158 | # in these scripts will be unencrypted
159 | PublishScripts/
160 |
161 | # NuGet Packages
162 | *.nupkg
163 | # The packages folder can be ignored because of Package Restore
164 | **/packages/*
165 | # except build/, which is used as an MSBuild target.
166 | !**/packages/build/
167 | # Uncomment if necessary however generally it will be regenerated when needed
168 | #!**/packages/repositories.config
169 | # NuGet v3's project.json files produces more ignorable files
170 | *.nuget.props
171 | *.nuget.targets
172 |
173 | # Microsoft Azure Build Output
174 | csx/
175 | *.build.csdef
176 |
177 | # Microsoft Azure Emulator
178 | ecf/
179 | rcf/
180 |
181 | # Windows Store app package directories and files
182 | AppPackages/
183 | BundleArtifacts/
184 | Package.StoreAssociation.xml
185 | _pkginfo.txt
186 |
187 | # Visual Studio cache files
188 | # files ending in .cache can be ignored
189 | *.[Cc]ache
190 | # but keep track of directories ending in .cache
191 | !*.[Cc]ache/
192 |
193 | # Others
194 | ClientBin/
195 | ~$*
196 | *~
197 | *.dbmdl
198 | *.dbproj.schemaview
199 | *.jfm
200 | *.pfx
201 | *.publishsettings
202 | orleans.codegen.cs
203 |
204 | # Since there are multiple workflows, uncomment next line to ignore bower_components
205 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
206 | #bower_components/
207 |
208 | # RIA/Silverlight projects
209 | Generated_Code/
210 |
211 | # Backup & report files from converting an old project file
212 | # to a newer Visual Studio version. Backup files are not needed,
213 | # because we have git ;-)
214 | _UpgradeReport_Files/
215 | UpgradeLog*.XML
216 | UpgradeLog*.htm
217 |
218 | # SQL Server files
219 | *.mdf
220 | *.ldf
221 | *.ndf
222 |
223 | # Business Intelligence projects
224 | *.rdl.data
225 | *.bim.layout
226 | *.bim_*.settings
227 |
228 | # Microsoft Fakes
229 | FakesAssemblies/
230 |
231 | # GhostDoc plugin setting file
232 | *.GhostDoc.xml
233 |
234 | # Node.js Tools for Visual Studio
235 | .ntvs_analysis.dat
236 | node_modules/
237 |
238 | # Typescript v1 declaration files
239 | typings/
240 |
241 | # Visual Studio 6 build log
242 | *.plg
243 |
244 | # Visual Studio 6 workspace options file
245 | *.opt
246 |
247 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
248 | *.vbw
249 |
250 | # Visual Studio LightSwitch build output
251 | **/*.HTMLClient/GeneratedArtifacts
252 | **/*.DesktopClient/GeneratedArtifacts
253 | **/*.DesktopClient/ModelManifest.xml
254 | **/*.Server/GeneratedArtifacts
255 | **/*.Server/ModelManifest.xml
256 | _Pvt_Extensions
257 |
258 | # Paket dependency manager
259 | .paket/paket.exe
260 | paket-files/
261 |
262 | # FAKE - F# Make
263 | .fake/
264 |
265 | # JetBrains Rider
266 | .idea/
267 | *.sln.iml
268 |
269 | # CodeRush
270 | .cr/
271 |
272 | # Python Tools for Visual Studio (PTVS)
273 | __pycache__/
274 | *.pyc
275 |
276 | # Cake - Uncomment if you are using it
277 | # tools/**
278 | # !tools/packages.config
279 |
280 | # Telerik's JustMock configuration file
281 | *.jmconfig
282 |
283 | # BizTalk build output
284 | *.btp.cs
285 | *.btm.cs
286 | *.odx.cs
287 | *.xsd.cs
288 |
--------------------------------------------------------------------------------
/src/EventAggregator.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Components;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Reflection;
6 | using System.Threading.Tasks;
7 | using Microsoft.Extensions.DependencyInjection;
8 | using Microsoft.Extensions.Options;
9 |
10 | namespace EventAggregator.Blazor
11 | {
12 | public class EventAggregator : IEventAggregator
13 | {
14 | private readonly EventAggregatorOptions _options;
15 | private readonly List _handlers = new List();
16 |
17 | public EventAggregator(IOptions options)
18 | {
19 | _options = options.Value;
20 | }
21 |
22 | ///
23 | public virtual void Subscribe(object subscriber)
24 | {
25 | if (subscriber == null)
26 | {
27 | throw new ArgumentNullException(nameof(subscriber));
28 | }
29 |
30 | lock (_handlers)
31 | {
32 | if (_handlers.Any(x => x.Matches(subscriber)))
33 | {
34 | return;
35 | }
36 |
37 | _handlers.Add(new Handler(subscriber));
38 | }
39 | }
40 |
41 | ///
42 | public virtual void Unsubscribe(object subscriber)
43 | {
44 | if (subscriber == null)
45 | {
46 | throw new ArgumentNullException(nameof(subscriber));
47 | }
48 |
49 | lock (_handlers)
50 | {
51 | var handlersFound = _handlers.FirstOrDefault(x => x.Matches(subscriber));
52 |
53 | if (handlersFound != null)
54 | {
55 | _handlers.Remove(handlersFound);
56 | }
57 | }
58 | }
59 |
60 | public virtual async Task PublishAsync(object message)
61 | {
62 | if (message == null)
63 | {
64 | throw new ArgumentNullException(nameof(message));
65 | }
66 |
67 | Handler[] handlersToNotify;
68 |
69 | lock (_handlers)
70 | {
71 | handlersToNotify = _handlers.ToArray();
72 | }
73 |
74 | var messageType = message.GetType();
75 |
76 | var tasks = handlersToNotify.Select(h => h.Handle(messageType, message));
77 |
78 | await Task.WhenAll(tasks);
79 |
80 | if (_options.AutoRefresh)
81 | {
82 | foreach (var handler in handlersToNotify.Where(x => !x.IsDead))
83 | {
84 | if (!(handler.Reference.Target is ComponentBase component))
85 | {
86 | continue;
87 | }
88 |
89 | var invoker = component.GetType().GetMethods(BindingFlags.Instance | BindingFlags.NonPublic)
90 | .FirstOrDefault(x =>
91 | string.Equals(x.Name, "InvokeAsync") &&
92 | x.GetParameters().FirstOrDefault()?.ParameterType == typeof(Action));
93 |
94 | if (invoker == null)
95 | {
96 | continue;
97 | }
98 |
99 | var stateHasChangedMethod = component.GetType()
100 | .GetMethod("StateHasChanged", BindingFlags.Instance | BindingFlags.NonPublic);
101 |
102 | if (stateHasChangedMethod == null)
103 | {
104 | continue;
105 | }
106 |
107 | var args = new object[] { new Action(() => stateHasChangedMethod.Invoke(component, null)) };
108 | var tOut = (Task) invoker.Invoke(component, args);
109 |
110 | await tOut;
111 | }
112 | }
113 |
114 | var deadHandlers = handlersToNotify.Where(h => h.IsDead).ToList();
115 |
116 | if (deadHandlers.Any())
117 | {
118 | lock (_handlers)
119 | {
120 | foreach (var item in deadHandlers)
121 | {
122 | _handlers.Remove(item);
123 | }
124 | }
125 | }
126 | }
127 |
128 | private class Handler
129 | {
130 | private readonly WeakReference _reference;
131 | private readonly Dictionary _supportedHandlers = new Dictionary();
132 |
133 | public Handler(object handler)
134 | {
135 | _reference = new WeakReference(handler);
136 |
137 | var interfaces = handler.GetType().GetTypeInfo().ImplementedInterfaces
138 | .Where(x => x.GetTypeInfo().IsGenericType && x.GetGenericTypeDefinition() == typeof(IHandle<>));
139 |
140 | foreach (var handleInterface in interfaces)
141 | {
142 | var type = handleInterface.GetTypeInfo().GenericTypeArguments[0];
143 | var method = handleInterface.GetRuntimeMethod("HandleAsync", new[] {type});
144 |
145 | if (method != null)
146 | {
147 | _supportedHandlers[type] = method;
148 | }
149 | }
150 | }
151 |
152 | public bool IsDead => _reference.Target == null;
153 |
154 | public WeakReference Reference => _reference;
155 |
156 | public bool Matches(object instance)
157 | {
158 | return _reference.Target == instance;
159 | }
160 |
161 | public Task Handle(Type messageType, object message)
162 | {
163 | var target = _reference.Target;
164 |
165 | if (target == null)
166 | {
167 | return Task.FromResult(false);
168 | }
169 |
170 | var tasks = _supportedHandlers
171 | .Where(handler => handler.Key.GetTypeInfo().IsAssignableFrom(messageType.GetTypeInfo()))
172 | .Select(pair => pair.Value.Invoke(target, new[] {message}))
173 | .Select(result => (Task) result)
174 | .ToList();
175 |
176 | return Task.WhenAll(tasks);
177 | }
178 |
179 | public bool Handles(Type messageType)
180 | {
181 | return _supportedHandlers.Any(
182 | pair => pair.Key.GetTypeInfo().IsAssignableFrom(messageType.GetTypeInfo()));
183 | }
184 | }
185 | }
186 | }
--------------------------------------------------------------------------------
/samples/CodeBehind/wwwroot/css/open-iconic/font/css/open-iconic-bootstrap.min.css:
--------------------------------------------------------------------------------
1 | @font-face{font-family:Icons;src:url(../fonts/open-iconic.eot);src:url(../fonts/open-iconic.eot?#iconic-sm) format('embedded-opentype'),url(../fonts/open-iconic.woff) format('woff'),url(../fonts/open-iconic.ttf) format('truetype'),url(../fonts/open-iconic.otf) format('opentype'),url(../fonts/open-iconic.svg#iconic-sm) format('svg');font-weight:400;font-style:normal}.oi{position:relative;top:1px;display:inline-block;speak:none;font-family:Icons;font-style:normal;font-weight:400;line-height:1;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.oi:empty:before{width:1em;text-align:center;box-sizing:content-box}.oi.oi-align-center:before{text-align:center}.oi.oi-align-left:before{text-align:left}.oi.oi-align-right:before{text-align:right}.oi.oi-flip-horizontal:before{-webkit-transform:scale(-1,1);-ms-transform:scale(-1,1);transform:scale(-1,1)}.oi.oi-flip-vertical:before{-webkit-transform:scale(1,-1);-ms-transform:scale(-1,1);transform:scale(1,-1)}.oi.oi-flip-horizontal-vertical:before{-webkit-transform:scale(-1,-1);-ms-transform:scale(-1,1);transform:scale(-1,-1)}.oi-account-login:before{content:'\e000'}.oi-account-logout:before{content:'\e001'}.oi-action-redo:before{content:'\e002'}.oi-action-undo:before{content:'\e003'}.oi-align-center:before{content:'\e004'}.oi-align-left:before{content:'\e005'}.oi-align-right:before{content:'\e006'}.oi-aperture:before{content:'\e007'}.oi-arrow-bottom:before{content:'\e008'}.oi-arrow-circle-bottom:before{content:'\e009'}.oi-arrow-circle-left:before{content:'\e00a'}.oi-arrow-circle-right:before{content:'\e00b'}.oi-arrow-circle-top:before{content:'\e00c'}.oi-arrow-left:before{content:'\e00d'}.oi-arrow-right:before{content:'\e00e'}.oi-arrow-thick-bottom:before{content:'\e00f'}.oi-arrow-thick-left:before{content:'\e010'}.oi-arrow-thick-right:before{content:'\e011'}.oi-arrow-thick-top:before{content:'\e012'}.oi-arrow-top:before{content:'\e013'}.oi-audio-spectrum:before{content:'\e014'}.oi-audio:before{content:'\e015'}.oi-badge:before{content:'\e016'}.oi-ban:before{content:'\e017'}.oi-bar-chart:before{content:'\e018'}.oi-basket:before{content:'\e019'}.oi-battery-empty:before{content:'\e01a'}.oi-battery-full:before{content:'\e01b'}.oi-beaker:before{content:'\e01c'}.oi-bell:before{content:'\e01d'}.oi-bluetooth:before{content:'\e01e'}.oi-bold:before{content:'\e01f'}.oi-bolt:before{content:'\e020'}.oi-book:before{content:'\e021'}.oi-bookmark:before{content:'\e022'}.oi-box:before{content:'\e023'}.oi-briefcase:before{content:'\e024'}.oi-british-pound:before{content:'\e025'}.oi-browser:before{content:'\e026'}.oi-brush:before{content:'\e027'}.oi-bug:before{content:'\e028'}.oi-bullhorn:before{content:'\e029'}.oi-calculator:before{content:'\e02a'}.oi-calendar:before{content:'\e02b'}.oi-camera-slr:before{content:'\e02c'}.oi-caret-bottom:before{content:'\e02d'}.oi-caret-left:before{content:'\e02e'}.oi-caret-right:before{content:'\e02f'}.oi-caret-top:before{content:'\e030'}.oi-cart:before{content:'\e031'}.oi-chat:before{content:'\e032'}.oi-check:before{content:'\e033'}.oi-chevron-bottom:before{content:'\e034'}.oi-chevron-left:before{content:'\e035'}.oi-chevron-right:before{content:'\e036'}.oi-chevron-top:before{content:'\e037'}.oi-circle-check:before{content:'\e038'}.oi-circle-x:before{content:'\e039'}.oi-clipboard:before{content:'\e03a'}.oi-clock:before{content:'\e03b'}.oi-cloud-download:before{content:'\e03c'}.oi-cloud-upload:before{content:'\e03d'}.oi-cloud:before{content:'\e03e'}.oi-cloudy:before{content:'\e03f'}.oi-code:before{content:'\e040'}.oi-cog:before{content:'\e041'}.oi-collapse-down:before{content:'\e042'}.oi-collapse-left:before{content:'\e043'}.oi-collapse-right:before{content:'\e044'}.oi-collapse-up:before{content:'\e045'}.oi-command:before{content:'\e046'}.oi-comment-square:before{content:'\e047'}.oi-compass:before{content:'\e048'}.oi-contrast:before{content:'\e049'}.oi-copywriting:before{content:'\e04a'}.oi-credit-card:before{content:'\e04b'}.oi-crop:before{content:'\e04c'}.oi-dashboard:before{content:'\e04d'}.oi-data-transfer-download:before{content:'\e04e'}.oi-data-transfer-upload:before{content:'\e04f'}.oi-delete:before{content:'\e050'}.oi-dial:before{content:'\e051'}.oi-document:before{content:'\e052'}.oi-dollar:before{content:'\e053'}.oi-double-quote-sans-left:before{content:'\e054'}.oi-double-quote-sans-right:before{content:'\e055'}.oi-double-quote-serif-left:before{content:'\e056'}.oi-double-quote-serif-right:before{content:'\e057'}.oi-droplet:before{content:'\e058'}.oi-eject:before{content:'\e059'}.oi-elevator:before{content:'\e05a'}.oi-ellipses:before{content:'\e05b'}.oi-envelope-closed:before{content:'\e05c'}.oi-envelope-open:before{content:'\e05d'}.oi-euro:before{content:'\e05e'}.oi-excerpt:before{content:'\e05f'}.oi-expand-down:before{content:'\e060'}.oi-expand-left:before{content:'\e061'}.oi-expand-right:before{content:'\e062'}.oi-expand-up:before{content:'\e063'}.oi-external-link:before{content:'\e064'}.oi-eye:before{content:'\e065'}.oi-eyedropper:before{content:'\e066'}.oi-file:before{content:'\e067'}.oi-fire:before{content:'\e068'}.oi-flag:before{content:'\e069'}.oi-flash:before{content:'\e06a'}.oi-folder:before{content:'\e06b'}.oi-fork:before{content:'\e06c'}.oi-fullscreen-enter:before{content:'\e06d'}.oi-fullscreen-exit:before{content:'\e06e'}.oi-globe:before{content:'\e06f'}.oi-graph:before{content:'\e070'}.oi-grid-four-up:before{content:'\e071'}.oi-grid-three-up:before{content:'\e072'}.oi-grid-two-up:before{content:'\e073'}.oi-hard-drive:before{content:'\e074'}.oi-header:before{content:'\e075'}.oi-headphones:before{content:'\e076'}.oi-heart:before{content:'\e077'}.oi-home:before{content:'\e078'}.oi-image:before{content:'\e079'}.oi-inbox:before{content:'\e07a'}.oi-infinity:before{content:'\e07b'}.oi-info:before{content:'\e07c'}.oi-italic:before{content:'\e07d'}.oi-justify-center:before{content:'\e07e'}.oi-justify-left:before{content:'\e07f'}.oi-justify-right:before{content:'\e080'}.oi-key:before{content:'\e081'}.oi-laptop:before{content:'\e082'}.oi-layers:before{content:'\e083'}.oi-lightbulb:before{content:'\e084'}.oi-link-broken:before{content:'\e085'}.oi-link-intact:before{content:'\e086'}.oi-list-rich:before{content:'\e087'}.oi-list:before{content:'\e088'}.oi-location:before{content:'\e089'}.oi-lock-locked:before{content:'\e08a'}.oi-lock-unlocked:before{content:'\e08b'}.oi-loop-circular:before{content:'\e08c'}.oi-loop-square:before{content:'\e08d'}.oi-loop:before{content:'\e08e'}.oi-magnifying-glass:before{content:'\e08f'}.oi-map-marker:before{content:'\e090'}.oi-map:before{content:'\e091'}.oi-media-pause:before{content:'\e092'}.oi-media-play:before{content:'\e093'}.oi-media-record:before{content:'\e094'}.oi-media-skip-backward:before{content:'\e095'}.oi-media-skip-forward:before{content:'\e096'}.oi-media-step-backward:before{content:'\e097'}.oi-media-step-forward:before{content:'\e098'}.oi-media-stop:before{content:'\e099'}.oi-medical-cross:before{content:'\e09a'}.oi-menu:before{content:'\e09b'}.oi-microphone:before{content:'\e09c'}.oi-minus:before{content:'\e09d'}.oi-monitor:before{content:'\e09e'}.oi-moon:before{content:'\e09f'}.oi-move:before{content:'\e0a0'}.oi-musical-note:before{content:'\e0a1'}.oi-paperclip:before{content:'\e0a2'}.oi-pencil:before{content:'\e0a3'}.oi-people:before{content:'\e0a4'}.oi-person:before{content:'\e0a5'}.oi-phone:before{content:'\e0a6'}.oi-pie-chart:before{content:'\e0a7'}.oi-pin:before{content:'\e0a8'}.oi-play-circle:before{content:'\e0a9'}.oi-plus:before{content:'\e0aa'}.oi-power-standby:before{content:'\e0ab'}.oi-print:before{content:'\e0ac'}.oi-project:before{content:'\e0ad'}.oi-pulse:before{content:'\e0ae'}.oi-puzzle-piece:before{content:'\e0af'}.oi-question-mark:before{content:'\e0b0'}.oi-rain:before{content:'\e0b1'}.oi-random:before{content:'\e0b2'}.oi-reload:before{content:'\e0b3'}.oi-resize-both:before{content:'\e0b4'}.oi-resize-height:before{content:'\e0b5'}.oi-resize-width:before{content:'\e0b6'}.oi-rss-alt:before{content:'\e0b7'}.oi-rss:before{content:'\e0b8'}.oi-script:before{content:'\e0b9'}.oi-share-boxed:before{content:'\e0ba'}.oi-share:before{content:'\e0bb'}.oi-shield:before{content:'\e0bc'}.oi-signal:before{content:'\e0bd'}.oi-signpost:before{content:'\e0be'}.oi-sort-ascending:before{content:'\e0bf'}.oi-sort-descending:before{content:'\e0c0'}.oi-spreadsheet:before{content:'\e0c1'}.oi-star:before{content:'\e0c2'}.oi-sun:before{content:'\e0c3'}.oi-tablet:before{content:'\e0c4'}.oi-tag:before{content:'\e0c5'}.oi-tags:before{content:'\e0c6'}.oi-target:before{content:'\e0c7'}.oi-task:before{content:'\e0c8'}.oi-terminal:before{content:'\e0c9'}.oi-text:before{content:'\e0ca'}.oi-thumb-down:before{content:'\e0cb'}.oi-thumb-up:before{content:'\e0cc'}.oi-timer:before{content:'\e0cd'}.oi-transfer:before{content:'\e0ce'}.oi-trash:before{content:'\e0cf'}.oi-underline:before{content:'\e0d0'}.oi-vertical-align-bottom:before{content:'\e0d1'}.oi-vertical-align-center:before{content:'\e0d2'}.oi-vertical-align-top:before{content:'\e0d3'}.oi-video:before{content:'\e0d4'}.oi-volume-high:before{content:'\e0d5'}.oi-volume-low:before{content:'\e0d6'}.oi-volume-off:before{content:'\e0d7'}.oi-warning:before{content:'\e0d8'}.oi-wifi:before{content:'\e0d9'}.oi-wrench:before{content:'\e0da'}.oi-x:before{content:'\e0db'}.oi-yen:before{content:'\e0dc'}.oi-zoom-in:before{content:'\e0dd'}.oi-zoom-out:before{content:'\e0de'}
--------------------------------------------------------------------------------
/samples/CodeBehind/wwwroot/css/open-iconic/font/fonts/open-iconic.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
7 |
8 | Created by FontForge 20120731 at Tue Jul 1 20:39:22 2014
9 | By P.J. Onori
10 | Created by P.J. Onori with FontForge 2.0 (http://fontforge.sf.net)
11 |
12 |
13 |
14 |
27 |
28 |
30 |
32 |
34 |
36 |
38 |
40 |
42 |
45 |
47 |
49 |
51 |
53 |
55 |
57 |
59 |
61 |
63 |
65 |
67 |
69 |
71 |
74 |
76 |
79 |
81 |
84 |
86 |
88 |
91 |
93 |
95 |
98 |
100 |
102 |
104 |
106 |
109 |
112 |
115 |
117 |
121 |
123 |
125 |
127 |
130 |
132 |
134 |
136 |
138 |
141 |
143 |
145 |
147 |
149 |
151 |
153 |
155 |
157 |
159 |
162 |
165 |
167 |
169 |
172 |
174 |
177 |
179 |
181 |
183 |
185 |
189 |
191 |
194 |
196 |
198 |
200 |
202 |
205 |
207 |
209 |
211 |
213 |
215 |
218 |
220 |
222 |
224 |
226 |
228 |
230 |
232 |
234 |
236 |
238 |
241 |
243 |
245 |
247 |
249 |
251 |
253 |
256 |
259 |
261 |
263 |
265 |
267 |
269 |
272 |
274 |
276 |
280 |
282 |
285 |
287 |
289 |
292 |
295 |
298 |
300 |
302 |
304 |
306 |
309 |
312 |
314 |
316 |
318 |
320 |
322 |
324 |
326 |
330 |
334 |
338 |
340 |
343 |
345 |
347 |
349 |
351 |
353 |
355 |
358 |
360 |
363 |
365 |
367 |
369 |
371 |
373 |
375 |
377 |
379 |
381 |
383 |
386 |
388 |
390 |
392 |
394 |
396 |
399 |
401 |
404 |
406 |
408 |
410 |
412 |
414 |
416 |
419 |
421 |
423 |
425 |
428 |
431 |
435 |
438 |
440 |
442 |
444 |
446 |
448 |
451 |
453 |
455 |
457 |
460 |
462 |
464 |
466 |
468 |
471 |
473 |
477 |
479 |
481 |
483 |
486 |
488 |
490 |
492 |
494 |
496 |
499 |
501 |
504 |
506 |
509 |
512 |
515 |
517 |
520 |
522 |
524 |
526 |
529 |
532 |
534 |
536 |
539 |
542 |
543 |
544 |
--------------------------------------------------------------------------------