Skip to content

Commit f377390

Browse files
committed
Merge branch 'review-readme-files' into develop
2 parents 87b3034 + 15a848f commit f377390

9 files changed

Lines changed: 171 additions & 62 deletions

File tree

OnTopic.AspNetCore.Mvc/README.md

Lines changed: 34 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
# `Ignia.Topics.AspNetCore.Mvc`
2-
The `Ignia.Topics.AspNetCore.Mvc` assembly provides a default implementation for utilizing OnTopic with the ASP.NET Core 3.x Framework.
1+
# OnTopic for ASP.NET Core 3.x
2+
The `OnTopic.AspNetCore.Mvc` assembly provides a default implementation for utilizing OnTopic with the ASP.NET Core 3.x Framework. It is the recommended client for working with OnTopic.
3+
4+
[![OnTopic.AspNetCore.Mvc package in Internal feed in Azure Artifacts](https://igniasoftware.feeds.visualstudio.com/_apis/public/Packaging/Feeds/46d5f49c-5e1e-47bb-8b14-43be6c719ba8/Packages/4db5e20c-69c6-4134-823a-c3de06d1176e/Badge)](https://igniasoftware.visualstudio.com/OnTopic/_packaging?_a=package&feed=46d5f49c-5e1e-47bb-8b14-43be6c719ba8&package=4db5e20c-69c6-4134-823a-c3de06d1176e&preferRelease=true)
5+
[![Build Status](https://igniasoftware.visualstudio.com/OnTopic/_apis/build/status/OnTopic-CI-V3?branchName=master)](https://igniasoftware.visualstudio.com/OnTopic/_build/latest?definitionId=7&branchName=master)
36

47
### Contents
58
- [Components](#components)
@@ -9,19 +12,20 @@ The `Ignia.Topics.AspNetCore.Mvc` assembly provides a default implementation for
912
- [View Locations](#view-locations)
1013
- [Example](#example)
1114
- [Configuration](#configuration)
15+
- [Dependencies](#dependencies)
1216
- [Application](#application)
1317
- [Route Configuration](#route-configuration)
1418
- [Composition Root](#composition-root)
1519

1620
## Components
1721
There are five key components at the heart of the ASP.NET Core implementation.
18-
- **`TopicController`**: This is a default controller instance that can be used for _any_ topic path. It will automatically validate that the `Topic` exists, that it is not disabled (`IsDisabled`), and will honor any redirects (e.g., if the `Url` attribute is filled out). Otherwise, it will return a `TopicViewResult` based on a view model, view name, and content type.
19-
- **`TopicViewLocationExpander`**: Assists the out-of-the-box Razor view engine in locating views associated with OnTopic, e.g. by looking in `~/Views/ContentTypes/ContentType.cshtml`, or `~/Views/ContentType/View.cshtml. See [View Locations](#view-locations) below.
22+
- **`TopicController`**: This is a default controller instance that can be used for _any_ topic path. It will automatically validate that the `Topic` exists, that it is not disabled (`!IsDisabled`), and will honor any redirects (e.g., if the `Url` attribute is filled out). Otherwise, it will return a `TopicViewResult` based on a view model, view name, and content type.
23+
- **`TopicViewLocationExpander`**: Assists the out-of-the-box Razor view engine in locating views associated with OnTopic, e.g. by looking in `~/Views/ContentTypes/ContentType.cshtml`, or `~/Views/ContentType/View.cshtml`. See [View Locations](#view-locations) below.
2024
- **`TopicViewResultExecutor`**: When the `TopicController` returns a `TopicViewResult`, the `TopicViewResultExecutor` takes over and attempts to identify the correct view based on the `accept` headers, `view` query string parameter, topic's default `View` attribute and, finally, the topic's `ContentType` attribute. See [View Matching](#view-matching) below.
21-
- **`ServiceCollectionExtensions`**: A set of extensions to be used in an ASP.NET Core website's `Startup` class that automatically handle registering services, controllers, and other extensions from `Ignia.Topics.AspNetCore.Mvc`.
22-
- **`ITopicRepositoryExtensions`**: A set of extensions that allows loading topics based on an ASP.NET Core `RouteData` collection, including `Ignia.Topics` route variables, such as `path` and `contenttype`.
25+
- **`ServiceCollectionExtensions`**: A set of extensions to be used in an ASP.NET Core website's `Startup` class that automatically handle registering services, controllers, and other extensions from `OnTopic.AspNetCore.Mvc`.
26+
- **`ITopicRepositoryExtensions`**: A set of extensions that allows loading topics based on an ASP.NET Core `RouteData` collection, including `OnTopic` route variables, such as `path` and `contenttype`.
2327

24-
> **Note:** In [`Ignia.Topics.Web.Mvc`](../Ignia.Topics.Web.Mvc/), the `TopicViewEngine` took on the responsibilities now handled by the `TopicViewLocationExpander`, the `TopicViewResult` took on responsibilities now handled by the `TopicViewResultExecutor`, and the `MvcTopicRoutingService` took on responsibilities now handled by the `ITopicRepositoryExtensions`.
28+
> **Note:** In [`OnTopic.Web.Mvc`](https://github.com/OnTopic/OnTopic-MVC/), the `TopicViewEngine` took on the responsibilities now handled by the `TopicViewLocationExpander`, `TopicViewResult` responsibilities for `TopicViewResultExecutor`, and the `MvcTopicRoutingService` responsibilities for `ITopicRepositoryExtensions`.
2529
2630
## Controllers and View Components
2731
There are six main controllers and view components that ship with the ASP.NET Core implementation. In addition to the core **`TopicController`**, these include the following ancillary classes:
@@ -78,20 +82,32 @@ If no match is found, then the next `Accept` header will be searched. Eventually
7882

7983
## Configuration
8084

85+
### Dependencies
86+
Installation can be performed by providing a `<PackageReference /`> to the `OnTopic.AspNetCore.Mvc` **NuGet** package.
87+
```xml
88+
<Project Sdk="Microsoft.NET.Sdk.Web">
89+
90+
<ItemGroup>
91+
<PackageReference Include="OnTopic.AspNetCore.Mvc" Version="4.0.0" />
92+
</ItemGroup>
93+
</Project>
94+
```
95+
96+
> *Note:* This package is currently only available on Ignia's private **NuGet** repository. For access, please contact [Ignia](http://www.ignia.com/).
97+
8198
### Application
8299
In the `Startup` class, OnTopic's ASP.NET Core support can be registered by calling the `AddTopicSupport()` extension method:
83-
```
100+
```c#
84101
public class Startup {
85102
public void ConfigureServices(IServiceCollection services) {
86-
services.AddMvc()
87-
.AddTopicSupport();
88-
}
103+
services.AddMvc().AddTopicSupport();
104+
}
89105
}
90106
```
91-
> *Note:* This will register the `TopicViewLocationExpander`, `TopicViewResultExecutor`, as well as all [Controllers](#controllers) that ship with `Ignia.Topics.AspNetCore.Mvc`.
107+
> *Note:* This will register the `TopicViewLocationExpander`, `TopicViewResultExecutor`, as well as all [Controllers](#controllers) that ship with `OnTopic.AspNetCore.Mvc`.
92108
93109
In addition, within the same `ConfigureServices()` method, you will need to establish a class that implements `IControllerActivator` and `IViewComponentActivator`, and will represent the site's _Composition Root_ for dependency injection. This will typically look like:
94-
```
110+
```c#
95111
var activator = new OrganizationNameControllerActivator(Configuration.GetConnectionString("OnTopic")
96112
services.AddSingleton<IControllerActivator>(activator);
97113
services.AddSingleton<IViewComponentActivator>(activator);
@@ -104,7 +120,7 @@ See [Composition Root](#composition-root) below for information on creating an i
104120

105121
### Route Configuration
106122
When registering routes via `Startup.Configure()` you may register any routes for OnTopic using the extension method:
107-
```
123+
```c#
108124
public class Startup {
109125
public void Configure(IApplicationBuilder app, IWebHostEnvironment env) {
110126
app.UseEndpoints(endpoints => {
@@ -115,11 +131,11 @@ public class Startup {
115131
}
116132
}
117133
```
118-
> *Note:* Because OnTopic relies on wildcard pathnames, a new route should be configured for every root namespace (e.g., `/Web`). While it's possible to configure OnTopic to evaluate _all_ paths, this makes it difficult to delegate control to other controllers and handlers, when necessary. As a result, it is recommended that each root container be registered individually.
134+
> *Note:* Because OnTopic relies on wildcard path names, a new route should be configured for every root namespace (e.g., `/Web`). While it's possible to configure OnTopic to evaluate _all_ paths, this makes it difficult to delegate control to other controllers and handlers, when necessary. As a result, it is recommended that each root container be registered individually.
119135

120136
### Composition Root
121137
As OnTopic relies on constructor injection, the application must be configured in a **Composition Root**in the case of ASP.NET Core, that means a custom controller activator for controllers, and view component activator for view components. For controllers, the basic structure of this might look like:
122-
```
138+
```c#
123139
var sqlTopicRepository = new SqlTopicRepository(connectionString);
124140
var cachedTopicRepository = new CachedTopicRepository(sqlTopicRepository);
125141
var topicViewModelLookupService = new TopicViewModelLookupService();
@@ -132,6 +148,6 @@ return controllerType.Name switch {
132148
_ => throw new Exception($"Unknown controller {controllerType.Name}")
133149
};
134150
```
135-
For a complete reference template, including the ancillary controllers, view components, and a more maintainable structure, see the [`OrganizationNameActivator.cs`](https://gist.github.com/JeremyCaney/00c04b1b9f40d9743793cd45dfaaa606) Gist.
151+
For a complete reference template, including the ancillary controllers, view components, and a more maintainable structure, see the [`OrganizationNameActivator.cs`](https://gist.github.com/JeremyCaney/00c04b1b9f40d9743793cd45dfaaa606) Gist. Optionally, you may use a dependency injection container.
136152
137-
> *Note:* The default `TopicController` will automatically identify the current topic (based on the `RouteData`), map the current topic to a corresponding view model (based on [the `TopicMappingService` conventions](../Ignia.Topics/Mapping/)), and then return a corresponding view (based on the [view conventions](#view-conventions)). For most applications, this is enough. If custom mapping rules or additional presentation logic are needed, however, implementors can subclass `TopicController`.
153+
> *Note:* The default `TopicController` will automatically identify the current topic (based on the `RouteData`), map the current topic to a corresponding view model (based on [the `TopicMappingService` conventions](../OnTopic/Mapping/README.md)), and then return a corresponding view (based on the [view conventions](#view-conventions)). For most applications, this is enough. If custom mapping rules or additional presentation logic are needed, however, implementors can subclass `TopicController`.

OnTopic.Data.Caching/README.md

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,27 @@
1-
# `CachedTopicRepository`
2-
The `CachedTopicRepository` provides an in-memory wrapper around an `ITopicRepository` implementation. When topics are requested, they are pulled from the cache, if they exist; otherwise, they are pulled from the underlying `ITopicRepository` implementation, and then cached. Similarly, when topics are e.g. saved, the updated versions are persisted to the underlying `ITopicRepository`, and then updated in the cache.
1+
# OnTopic Cached Repository
2+
The `CachedTopicRepository` provides an in-memory wrapper around an `ITopicRepository` implementation.
33

4-
## Usage
4+
[![OnTopic.Data.Caching package in Internal feed in Azure Artifacts](https://igniasoftware.feeds.visualstudio.com/_apis/public/Packaging/Feeds/46d5f49c-5e1e-47bb-8b14-43be6c719ba8/Packages/3dfb3a0a-c049-407d-959e-546f714dcd0f/Badge)](https://igniasoftware.visualstudio.com/OnTopic/_packaging?_a=package&feed=46d5f49c-5e1e-47bb-8b14-43be6c719ba8&package=3dfb3a0a-c049-407d-959e-546f714dcd0f&preferRelease=true)
5+
[![Build Status](https://igniasoftware.visualstudio.com/OnTopic/_apis/build/status/OnTopic-CI-V3?branchName=master)](https://igniasoftware.visualstudio.com/OnTopic/_build/latest?definitionId=7&branchName=master)
6+
7+
## Functionality
8+
When topics are requested, they are pulled from the cache, if they exist; otherwise, they are pulled from the underlying `ITopicRepository` implementation, and then cached. Similarly, when topics are e.g. saved, the updated versions are persisted to the underlying `ITopicRepository`, and then updated in the cache.
9+
10+
## Installation
11+
Installation can be performed by providing a `<PackageReference /`> to the `OnTopic.Data.Caching` **NuGet** package.
12+
```xml
13+
<Project Sdk="Microsoft.NET.Sdk.Web">
14+
15+
<ItemGroup>
16+
<PackageReference Include="OnTopic.Data.Caching" Version="4.0.0" />
17+
</ItemGroup>
18+
</Project>
519
```
20+
21+
> *Note:* This package is currently only available on Ignia's private **NuGet** repository. For access, please contact [Ignia](http://www.ignia.com/).
22+
23+
## Usage
24+
```c#
625
var sqlTopicRepository = new SqlTopicRepository(connectionString);
726
var cachedTopicRepository = new CachedTopicRepository(sqlTopicRepository);
827

OnTopic.Data.Sql.Database/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# SQL Schema
2-
The `Ignia.Topics.Data.Sql.Database` provides a default schema for supporting the [`SqlTopicRepository`](../Ignia.Topics.Data.Sql).
2+
The `OnTopic.Data.Sql.Database` provides a default schema for supporting the [`SqlTopicRepository`](../OnTopic.Data.Sql).
33

44
> *Note:* Not all SQL objects are documented here. Missing objects are primarily intended for infrastructure support and used exclusively by stored procedures or administrators.
55

OnTopic.Data.Sql/README.md

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,27 @@
1-
# `SqlTopicRepository`
1+
# OnTopic SQL Repository
22
The `SqlTopicRepository` provides an implementation of the `ITopicRepository` interface for use with Microsoft SQL Server. All requests are sent to the database, with no effort to cache data.
33

4-
> *Note:* The schema for the Microsoft SQL Server implementation can be found at [`Ignia.Topics.Data.Sql.Database`](../Ignia.Topics.Data.Sql.Database). It is not currently distributed as part of the `SqlTopicRepository` and must be deployed separately.
4+
[![OnTopic.Data.Sql package in Internal feed in Azure Artifacts](https://igniasoftware.feeds.visualstudio.com/_apis/public/Packaging/Feeds/46d5f49c-5e1e-47bb-8b14-43be6c719ba8/Packages/15c8a666-efa5-4b23-b08b-1de907478d2d/Badge)](https://igniasoftware.visualstudio.com/OnTopic/_packaging?_a=package&feed=46d5f49c-5e1e-47bb-8b14-43be6c719ba8&package=15c8a666-efa5-4b23-b08b-1de907478d2d&preferRelease=true)
5+
[![Build Status](https://igniasoftware.visualstudio.com/OnTopic/_apis/build/status/OnTopic-CI-V3?branchName=master)](https://igniasoftware.visualstudio.com/OnTopic/_build/latest?definitionId=7&branchName=master)
56

6-
## Usage
7+
> *Note:* The schema for the Microsoft SQL Server implementation can be found at [`OnTopic.Data.Sql.Database`](../OnTopic.Data.Sql.Database/README.md). It is not currently distributed as part of the `SqlTopicRepository` and must be deployed separately.
8+
9+
## Installation
10+
Installation can be performed by providing a `<PackageReference /`> to the `OnTopic.Data.Sql` **NuGet** package.
11+
```xml
12+
<Project Sdk="Microsoft.NET.Sdk.Web">
13+
14+
<ItemGroup>
15+
<PackageReference Include="OnTopic.Data.Sql" Version="4.0.0" />
16+
</ItemGroup>
17+
</Project>
718
```
19+
20+
> *Note:* This package is currently only available on Ignia's private **NuGet** repository. For access, please contact [Ignia](http://www.ignia.com/).
21+
22+
## Usage
23+
```c#
824
var sqlTopicRepository = new SqlTopicRepository(connectionString);
925
var rootTopic = sqlTopicRepository.Load();
1026
```
11-
> *Note:* In real-world applications, it is recommended that the `SqlTopicRepository` be wrapped by the [`CachedTopicRepository`](../Ignia.Topics.Data.Caching), which provides an in-memory cache of any `ITopicRepository` implementation.
27+
> *Note:* In real-world applications, it is recommended that the `SqlTopicRepository` be wrapped by the [`CachedTopicRepository`](../OnTopic.Data.Caching/README.md), which provides an in-memory cache of any `ITopicRepository` implementation.

OnTopic.TestDoubles/README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# `TestDoubles`
2+
Provides common test doubles for use in testing the **OnTopic Library**.
3+
4+
[![OnTopic.TestDoubles package in Internal feed in Azure Artifacts](https://igniasoftware.feeds.visualstudio.com/_apis/public/Packaging/Feeds/46d5f49c-5e1e-47bb-8b14-43be6c719ba8/Packages/3a741b7a-7fa1-4bdb-bc55-efbac3f04e6c/Badge)](https://igniasoftware.visualstudio.com/OnTopic/_packaging?_a=package&feed=46d5f49c-5e1e-47bb-8b14-43be6c719ba8&package=3a741b7a-7fa1-4bdb-bc55-efbac3f04e6c&preferRelease=true)
5+
[![Build Status](https://igniasoftware.visualstudio.com/OnTopic/_apis/build/status/OnTopic-CI-V3?branchName=master)](https://igniasoftware.visualstudio.com/OnTopic/_build/latest?definitionId=7&branchName=master)
6+
7+
## Installation
8+
Installation can be performed by providing a `<PackageReference /`> to the `OnTopic.TestDoubles` **NuGet** package.
9+
```xml
10+
<Project Sdk="Microsoft.NET.Sdk.Web">
11+
12+
<ItemGroup>
13+
<PackageReference Include="OnTopic.TestDoubles" Version="4.0.0" />
14+
</ItemGroup>
15+
</Project>
16+
```
17+
18+
> *Note:* This package is currently only available on Ignia's private **NuGet** repository. For access, please contact [Ignia](http://www.ignia.com/).
19+
20+
## Inventory
21+
22+
### Dummies
23+
Dummies provide no actual functionality and are not expected to function correctly if called. They are simply provided to satisfy the inferface requirement of dependencies, so that a service can be constructed.
24+
25+
- [`DummyTopicMappingService`](DummyTopicMappingService.cs)
26+
- [`DummyTopicRepository`](DummyTopicRepository.cs)
27+
28+
### Stubs
29+
Stubs not only satisfy the interface, but will return canned data that tests can operate against, thus allowing unit tests to interact with predetermined scenarios against the service.
30+
31+
- [`StubTopicRepository`](StubTopicRepository.cs)

OnTopic.Tests/OnTopic.Tests.csproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
<Project Sdk="Microsoft.NET.Sdk">
2+
23
<PropertyGroup>
34
<TargetFramework>netcoreapp3.0</TargetFramework>
45
<IsPackable>false</IsPackable>
56
<NoWarn>CS1591,1701,1702,CA1707,CA1062,CS8602,CS8604;CA1303;IDE0059</NoWarn>
67
<LangVersion>8.0</LangVersion>
78
<Nullable>enable</Nullable>
89
</PropertyGroup>
10+
911
<PropertyGroup>
1012
<AssemblyTitle>Ignia OnTopic Unit Tests</AssemblyTitle>
1113
<Company>Ignia</Company>
@@ -14,6 +16,7 @@
1416
<Copyright>©2020 Ignia, LLC</Copyright>
1517
<OutputPath>bin\$(Configuration)\</OutputPath>
1618
</PropertyGroup>
19+
1720
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
1821
<DebugType>full</DebugType>
1922
<DocumentationFile>bin\$(Configuration)\OnTopic.Tests.XML</DocumentationFile>
@@ -22,6 +25,7 @@
2225
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
2326
<DebugType>pdbonly</DebugType>
2427
</PropertyGroup>
28+
2529
<ItemGroup>
2630
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.4">
2731
<PrivateAssets>all</PrivateAssets>
@@ -31,10 +35,12 @@
3135
<PackageReference Include="MSTest.TestAdapter" Version="2.0.0" />
3236
<PackageReference Include="MSTest.TestFramework" Version="2.0.0" />
3337
</ItemGroup>
38+
3439
<ItemGroup>
3540
<ProjectReference Include="..\OnTopic.Data.Caching\OnTopic.Data.Caching.csproj" />
3641
<ProjectReference Include="..\OnTopic.TestDoubles\OnTopic.TestDoubles.csproj" />
3742
<ProjectReference Include="..\OnTopic.ViewModels\OnTopic.ViewModels.csproj" />
3843
<ProjectReference Include="..\OnTopic\OnTopic.csproj" />
3944
</ItemGroup>
45+
4046
</Project>

0 commit comments

Comments
 (0)