Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ASP.NET Core Facility (now production ready BUT... ) #394

Merged
1 commit merged into from Jul 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
207 changes: 150 additions & 57 deletions docs/aspnetcore-facility.md

Large diffs are not rendered by default.

192 changes: 0 additions & 192 deletions src/Castle.Facilities.AspNetCore.Tests/AspNetCoreFacilityTestCase.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,23 @@
<ProjectReference Include="..\Castle.Facilities.AspNetCore\Castle.Facilities.AspNetCore.csproj" />
</ItemGroup>

<ItemGroup>
<None Update="Fakes\ModelFakes.tt">
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>ModelFakes.cs</LastGenOutput>
</None>
</ItemGroup>

<ItemGroup>
<Service Include="{508349b6-6b84-4df5-91f0-309beebad82d}" />
</ItemGroup>

<ItemGroup>
<Compile Update="Fakes\ModelFakes.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>ModelFakes.tt</DependentUpon>
</Compile>
</ItemGroup>

</Project>
64 changes: 64 additions & 0 deletions src/Castle.Facilities.AspNetCore.Tests/Fakes/AnyFakes.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// Copyright 2004-2018 Castle Project - http://www.castleproject.org/
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.


namespace Castle.Facilities.AspNetCore.Tests.Fakes
{
using System;
using System.Threading.Tasks;

using Microsoft.AspNetCore.Http;

using Castle.MicroKernel.Lifestyle;

public class AnyComponent { }
public class AnyComponentWithLifestyleManager : AbstractLifestyleManager
{
public override void Dispose()
{
}
}

public sealed class AnyMiddleware : IMiddleware
{
private readonly AnyComponent anyComponent;
private readonly ServiceProviderOnlyScopedDisposable serviceProviderOnlyScopedDisposable;
private readonly WindsorOnlyScopedDisposable windsorOnlyScopedDisposable;
private readonly CrossWiredScopedDisposable crossWiredScopedDisposable;

public AnyMiddleware(
ServiceProviderOnlyScopedDisposable serviceProviderOnlyScopedDisposable,
WindsorOnlyScopedDisposable windsorOnlyScopedDisposable,
CrossWiredScopedDisposable crossWiredScopedDisposable)
{
this.serviceProviderOnlyScopedDisposable = serviceProviderOnlyScopedDisposable ?? throw new ArgumentNullException(nameof(serviceProviderOnlyScopedDisposable));
this.windsorOnlyScopedDisposable = windsorOnlyScopedDisposable ?? throw new ArgumentNullException(nameof(windsorOnlyScopedDisposable));
this.crossWiredScopedDisposable = crossWiredScopedDisposable ?? throw new ArgumentNullException(nameof(crossWiredScopedDisposable));
}

public AnyMiddleware(AnyComponent anyComponent)
{
// This will never get called because Windsor picks the most greedy constructor
this.anyComponent = anyComponent ?? throw new ArgumentNullException(nameof(anyComponent));
}

public async Task InvokeAsync(HttpContext context, RequestDelegate next)
{
// Do something before
await next(context);
// Do something after
}
}

}
57 changes: 57 additions & 0 deletions src/Castle.Facilities.AspNetCore.Tests/Fakes/CompositeFakes.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// Copyright 2004-2018 Castle Project - http://www.castleproject.org/
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

namespace Castle.Facilities.AspNetCore.Tests.Fakes
{
using System;

public class CompositeController
{
public CompositeController(
ControllerCrossWired crossWiredController,
ControllerServiceProviderOnly serviceProviderOnlyController,
ControllerWindsorOnly windsorOnlyController)
{
if (crossWiredController == null) throw new ArgumentNullException(nameof(crossWiredController));
if (serviceProviderOnlyController == null) throw new ArgumentNullException(nameof(serviceProviderOnlyController));
if (windsorOnlyController == null) throw new ArgumentNullException(nameof(windsorOnlyController));
}
}

public class CompositeTagHelper
{
public CompositeTagHelper(
TagHelperCrossWired crossWiredTagHelper,
TagHelperServiceProviderOnly serviceProviderOnlyTagHelper,
TagHelperWindsorOnly windsorOnlyTagHelper)
{
if (crossWiredTagHelper == null) throw new ArgumentNullException(nameof(crossWiredTagHelper));
if (serviceProviderOnlyTagHelper == null) throw new ArgumentNullException(nameof(serviceProviderOnlyTagHelper));
if (windsorOnlyTagHelper == null) throw new ArgumentNullException(nameof(windsorOnlyTagHelper));
}
}

public class CompositeViewComponent
{
public CompositeViewComponent(
ViewComponentCrossWired crossWiredViewComponent,
ViewComponentServiceProviderOnly serviceProviderOnlyViewComponent,
ViewComponentWindsorOnly windsorOnlyViewComponent)
{
if (crossWiredViewComponent == null) throw new ArgumentNullException(nameof(crossWiredViewComponent));
if (serviceProviderOnlyViewComponent == null) throw new ArgumentNullException(nameof(serviceProviderOnlyViewComponent));
if (windsorOnlyViewComponent == null) throw new ArgumentNullException(nameof(windsorOnlyViewComponent));
}
}
}
Loading