diff --git a/Blazor.sln b/Blazor.sln
index 01b0045712..7ac8f8f225 100644
--- a/Blazor.sln
+++ b/Blazor.sln
@@ -66,6 +66,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AngleSharpBuilder", "src\an
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Blazor.Razor.Extensions", "src\Microsoft.AspNetCore.Blazor.Razor.Extensions\Microsoft.AspNetCore.Blazor.Razor.Extensions.csproj", "{D652A019-B765-4922-B7B8-3AB1C58338D7}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNetCore.Blazor.Browser.Test", "test\Microsoft.AspNetCore.Blazor.Browser.Test\Microsoft.AspNetCore.Blazor.Browser.Test.csproj", "{EC2A38BF-6E77-4A8E-A731-15929544F29C}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -160,6 +162,10 @@ Global
{D652A019-B765-4922-B7B8-3AB1C58338D7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D652A019-B765-4922-B7B8-3AB1C58338D7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D652A019-B765-4922-B7B8-3AB1C58338D7}.Release|Any CPU.Build.0 = Release|Any CPU
+ {EC2A38BF-6E77-4A8E-A731-15929544F29C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {EC2A38BF-6E77-4A8E-A731-15929544F29C}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {EC2A38BF-6E77-4A8E-A731-15929544F29C}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {EC2A38BF-6E77-4A8E-A731-15929544F29C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -192,6 +198,7 @@ Global
{4E3BD19A-6159-4548-A88F-700443E6D934} = {B867E038-B3CE-43E3-9292-61568C46CDEB}
{36706AC2-C851-4038-B161-9C1E44B668C8} = {4E3BD19A-6159-4548-A88F-700443E6D934}
{D652A019-B765-4922-B7B8-3AB1C58338D7} = {B867E038-B3CE-43E3-9292-61568C46CDEB}
+ {EC2A38BF-6E77-4A8E-A731-15929544F29C} = {ADA3AE29-F6DE-49F6-8C7C-B321508CAE8E}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {504DA352-6788-4DC0-8705-82167E72A4D3}
diff --git a/src/Microsoft.AspNetCore.Blazor.Browser/Properties/AssemblyInfo.cs b/src/Microsoft.AspNetCore.Blazor.Browser/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000000..fe974f5074
--- /dev/null
+++ b/src/Microsoft.AspNetCore.Blazor.Browser/Properties/AssemblyInfo.cs
@@ -0,0 +1,3 @@
+using System.Runtime.CompilerServices;
+
+[assembly: InternalsVisibleTo("Microsoft.AspNetCore.Blazor.Browser.Test")]
diff --git a/src/Microsoft.AspNetCore.Blazor.Browser/Routing/BrowserRouter.cs b/src/Microsoft.AspNetCore.Blazor.Browser/Routing/BrowserRouter.cs
index 647c29eab0..87fa2ba250 100644
--- a/src/Microsoft.AspNetCore.Blazor.Browser/Routing/BrowserRouter.cs
+++ b/src/Microsoft.AspNetCore.Blazor.Browser/Routing/BrowserRouter.cs
@@ -10,18 +10,35 @@ using Microsoft.AspNetCore.Blazor.RenderTree;
namespace Microsoft.AspNetCore.Blazor.Browser.Routing
{
+ ///
+ /// A component that displays whichever other component corresponds to the
+ /// browser's changing navigation state.
+ ///
public class BrowserRouter : IComponent, IDisposable
{
RenderHandle _renderHandle;
string _baseUriPrefix;
string _locationAbsolute;
+ ///
+ /// Gets or sets the assembly that should be searched, along with its referenced
+ /// assemblies, for components matching the URI.
+ ///
public Assembly AppAssembly { get; set; }
+ ///
+ /// Gets or sets the namespace prefix that should be prepended when searching
+ /// for matching components.
+ ///
public string PagesNamespace { get; set; }
+ ///
+ /// Gets or sets the component name that will be used if the URI ends with
+ /// a slash.
+ ///
public string DefaultComponentName { get; set; } = "Index";
+ ///
public void Init(RenderHandle renderHandle)
{
_renderHandle = renderHandle;
@@ -32,12 +49,14 @@ namespace Microsoft.AspNetCore.Blazor.Browser.Routing
_locationAbsolute = UriHelper.GetAbsoluteUri();
}
+ ///
public void SetParameters(ParameterCollection parameters)
{
parameters.AssignToProperties(this);
Refresh();
}
+ ///
public void Dispose()
{
UriHelper.OnLocationChanged -= OnLocationChanged;
diff --git a/src/Microsoft.AspNetCore.Blazor.Browser/Routing/UriHelper.cs b/src/Microsoft.AspNetCore.Blazor.Browser/Routing/UriHelper.cs
index 1ab69d4f50..da02e965eb 100644
--- a/src/Microsoft.AspNetCore.Blazor.Browser/Routing/UriHelper.cs
+++ b/src/Microsoft.AspNetCore.Blazor.Browser/Routing/UriHelper.cs
@@ -6,29 +6,59 @@ using System;
namespace Microsoft.AspNetCore.Blazor.Browser.Routing
{
+ // TODO: Make this not static, and wrap it in an interface that can be injected through DI.
+ // We can make EnableNavigationInteception private, and call it automatically when the any
+ // concrete instance is instantiated.
+
+ ///
+ /// Helpers for working with URIs and navigation state.
+ ///
public static class UriHelper
{
static readonly string _functionPrefix = typeof(UriHelper).FullName;
+ ///
+ /// An event that fires when the navigation location has changed.
+ ///
public static event EventHandler OnLocationChanged;
+ ///
+ /// Prevents default navigation on all links whose href is inside the base URI space,
+ /// causing clicks on those links to trigger instead.
+ ///
public static void EnableNavigationInteception()
=> RegisteredFunction.InvokeUnmarshalled