Skip to content

Commit

Permalink
[r] formatting, new c# features, primary constructors, usings cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
i4004 committed Jan 21, 2024
1 parent f0abb89 commit 61d292c
Show file tree
Hide file tree
Showing 159 changed files with 858 additions and 986 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@
"appsettings",
"ASPNETCORE",
"Bootstrapper",
"cacheable",
"Catched",
"cref",
"HOSTINGSTARTUPASSEMBLIES",
"localizable",
"mscorlib",
"OWIN",
"Redirector",
"registrator"
Expand Down
2 changes: 1 addition & 1 deletion src/Simplify.Web/ActionModulesAccessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace Simplify.Web;

/// <summary>
/// Action modules accessor base class
/// Action modules accessor base class.
/// </summary>
public class ActionModulesAccessor : ModulesAccessor
{
Expand Down
14 changes: 5 additions & 9 deletions src/Simplify.Web/ApplicationBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@
namespace Simplify.Web;

/// <summary>
/// IApplicationBuilder Simplify.Web extensions
/// IApplicationBuilder Simplify.Web extensions.
/// </summary>
public static class ApplicationBuilderExtensions
{
/// <summary>
/// Performs Simplify.Web bootstrapper registrations and adds Simplify.Web to the OWIN pipeline as a terminal middleware
/// Performs Simplify.Web bootstrapper registrations and adds Simplify.Web to the OWIN pipeline as a terminal middleware.
/// </summary>
/// <param name="builder">The OWIN builder.</param>
/// <returns></returns>
public static IApplicationBuilder UseSimplifyWeb(this IApplicationBuilder builder)
{
try
Expand All @@ -37,10 +36,9 @@ public static IApplicationBuilder UseSimplifyWeb(this IApplicationBuilder builde
}

/// <summary>
/// Adds Simplify.Web to the OWIN pipeline as a terminal middleware without bootstrapper registrations (useful when you want to control bootstrapper registrations manually)
/// Adds Simplify.Web to the OWIN pipeline as a terminal middleware without bootstrapper registrations (useful when you want to control bootstrapper registrations manually).
/// </summary>
/// <param name="builder">The builder.</param>
/// <returns></returns>
public static IApplicationBuilder UseSimplifyWebWithoutRegistrations(this IApplicationBuilder builder)
{
try
Expand All @@ -60,10 +58,9 @@ public static IApplicationBuilder UseSimplifyWebWithoutRegistrations(this IAppli
}

/// <summary>
/// Performs Simplify.Web bootstrapper registrations and adds Simplify.Web to the OWIN pipeline as a non-terminal middleware
/// Performs Simplify.Web bootstrapper registrations and adds Simplify.Web to the OWIN pipeline as a non-terminal middleware.
/// </summary>
/// <param name="builder">The OWIN builder.</param>
/// <returns></returns>
public static IApplicationBuilder UseSimplifyWebNonTerminal(this IApplicationBuilder builder)
{
try
Expand All @@ -84,10 +81,9 @@ public static IApplicationBuilder UseSimplifyWebNonTerminal(this IApplicationBui
}

/// <summary>
/// Adds Simplify.Web to the OWIN pipeline as a non-terminal middleware without bootstrapper registrations
/// Adds Simplify.Web to the OWIN pipeline as a non-terminal middleware without bootstrapper registrations.
/// </summary>
/// <param name="builder">The OWIN builder.</param>
/// <returns></returns>
public static IApplicationBuilder UseSimplifyWebNonTerminalWithoutRegistrations(this IApplicationBuilder builder)
{
try
Expand Down
2 changes: 1 addition & 1 deletion src/Simplify.Web/AsyncController.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
namespace Simplify.Web;

/// <summary>
/// Asynchronous controllers base class
/// Asynchronous controllers base class version 1.
/// </summary>
public abstract class AsyncController : AsyncControllerBase
{
Expand Down
2 changes: 1 addition & 1 deletion src/Simplify.Web/AsyncControllerBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Simplify.Web;

/// <summary>
/// Asynchronous controllers base class
/// Asynchronous controllers base class.
/// </summary>
public abstract class AsyncControllerBase : ControllerBase
{
Expand Down
2 changes: 1 addition & 1 deletion src/Simplify.Web/AsyncController{T}.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
namespace Simplify.Web;

/// <summary>
/// Asynchronous model controllers base class
/// Asynchronous model controllers base class version 1.
/// </summary>
public abstract class AsyncController<T> : AsyncControllerBase
where T : class
Expand Down
2 changes: 1 addition & 1 deletion src/Simplify.Web/Controller.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
namespace Simplify.Web;

/// <summary>
/// Synchronous controllers base class
/// Synchronous controllers base class version 1.
/// </summary>
public abstract class Controller : SyncControllerBase
{
Expand Down
2 changes: 1 addition & 1 deletion src/Simplify.Web/Controller2.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
namespace Simplify.Web;

/// <summary>
/// Controllers base class version 2
/// Controllers base class version 2.
/// </summary>
public abstract class Controller2 : ResponseShortcutsControllerBase
{
Expand Down
2 changes: 1 addition & 1 deletion src/Simplify.Web/Controller2{T}.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
namespace Simplify.Web;

/// <summary>
/// Model controllers base class version 2
/// Model controllers base class version 2.
/// </summary>
public abstract class Controller2<T> : ResponseShortcutsControllerBase
where T : class
Expand Down
7 changes: 1 addition & 6 deletions src/Simplify.Web/ControllerBase.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
#nullable disable

using System;
using Simplify.Templates;
using Simplify.Web.Modules;
using Simplify.Web.Responses;

namespace Simplify.Web;

/// <summary>
/// Controllers base class
/// Controllers base class.
/// </summary>
public abstract class ControllerBase : ResponseShortcutsControllerBase
{
Expand Down
2 changes: 1 addition & 1 deletion src/Simplify.Web/ControllerResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace Simplify.Web;

/// <summary>
/// Provides controllers responses base class
/// Provides controllers responses base class.
/// </summary>
public abstract class ControllerResponse : ActionModulesAccessor
{
Expand Down
8 changes: 4 additions & 4 deletions src/Simplify.Web/ControllerResponseResult.cs
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
namespace Simplify.Web;

/// <summary>
/// Provides controller response result types
/// Provides controller response result types.
/// </summary>
public enum ControllerResponseResult
{
/// <summary>
/// The default result (no special processing required)
/// The default result (no special processing required).
/// </summary>
Default,

/// <summary>
/// The execution should be stopped, because raw output will be sent to the client
/// The execution should be stopped, because raw output will be sent to the client.
/// </summary>
RawOutput,

/// <summary>
/// The execution should be stopped, because the client will be redirected to the new URL
/// The execution should be stopped, because the client will be redirected to the new URL.
/// </summary>
Redirect
}
2 changes: 1 addition & 1 deletion src/Simplify.Web/Controller{T}.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
namespace Simplify.Web;

/// <summary>
/// Synchronous model controllers base class
/// Synchronous model controllers base class version 1.
/// </summary>
public abstract class Controller<T> : SyncControllerBase
where T : class
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace Simplify.Web.Core.AccessorsBuilding;

/// <summary>
/// Provides builder for ActionModulesAccessor objects
/// Provides builder for ActionModulesAccessor objects.
/// </summary>
public class ActionModulesAccessorBuilder : ModulesAccessorBuilder
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
namespace Simplify.Web.Core.AccessorsBuilding;

/// <summary>
/// Provides builder for ModulesAccessor objects
/// Provides builder for ModulesAccessor objects.
/// </summary>
public class ModulesAccessorBuilder : ViewAccessorBuilder
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace Simplify.Web.Core.AccessorsBuilding;

/// <summary>
/// Provides builder for ViewAccessor objects construction
/// Provides builder for ViewAccessor objects construction.
/// </summary>
public abstract class ViewAccessorBuilder
{
Expand Down
15 changes: 11 additions & 4 deletions src/Simplify.Web/Core/Controllers/ControllersAgent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
namespace Simplify.Web.Core.Controllers;

/// <summary>
/// Provides controllers agent
/// Provides controllers agent.
/// </summary>
/// <remarks>
/// Initializes a new instance of the <see cref="ControllersAgent" /> class.
Expand Down Expand Up @@ -45,7 +45,9 @@ public IList<IControllerMetaData> GetStandardControllersMetaData() =>

var item = controllerMetaData.ExecParameters.Routes.FirstOrDefault(x => x.Key == HttpRequestUtil.HttpMethodStringToHttpMethod(httpMethod));

return default(KeyValuePair<HttpMethod, string>).Equals(item) ? null : _routeMatcher.Match(sourceRoute, item.Value);
return default(KeyValuePair<HttpMethod, string>).Equals(item)
? null
: _routeMatcher.Match(sourceRoute, item.Value);
}

/// <summary>
Expand Down Expand Up @@ -94,12 +96,17 @@ public SecurityRuleCheckResult IsSecurityRulesViolated(IControllerMetaData metaD
return SecurityRuleCheckResult.Ok;

if (metaData.Security.RequiredUserRoles == null || !metaData.Security.RequiredUserRoles.Any())
return user?.Identity == null || !user.Identity.IsAuthenticated ? SecurityRuleCheckResult.NotAuthenticated : SecurityRuleCheckResult.Ok;
return user?.Identity == null ||
!user.Identity.IsAuthenticated
? SecurityRuleCheckResult.NotAuthenticated
: SecurityRuleCheckResult.Ok;

if (user?.Identity == null || !user.Identity.IsAuthenticated)
return SecurityRuleCheckResult.NotAuthenticated;

return metaData.Security.RequiredUserRoles.Any(user.IsInRole) ? SecurityRuleCheckResult.Ok : SecurityRuleCheckResult.Forbidden;
return metaData.Security.RequiredUserRoles.Any(user.IsInRole)
? SecurityRuleCheckResult.Ok
: SecurityRuleCheckResult.Forbidden;
}

private static IList<IControllerMetaData> SortControllersMetaContainers(IEnumerable<IControllerMetaData> controllersMetaContainers) =>
Expand Down
6 changes: 2 additions & 4 deletions src/Simplify.Web/Core/Controllers/ControllersProcessor.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Simplify.DI;
using Simplify.Web.Core.Controllers.Execution;
using Simplify.Web.Meta;
using Simplify.Web.Modules;

namespace Simplify.Web.Core.Controllers;

/// <summary>
/// Provides controllers processor
/// Provides controllers processor.
/// </summary>
/// <remarks>
/// Initializes a new instance of the <see cref="ControllersProcessor" /> class.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
namespace Simplify.Web.Core.Controllers;

/// <summary>
/// Controllers processor result types
/// Controllers processor result types.
/// </summary>
public enum ControllersProcessorResult
{
Expand Down
29 changes: 11 additions & 18 deletions src/Simplify.Web/Core/Controllers/ControllersRequestHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,19 @@
namespace Simplify.Web.Core.Controllers;

/// <summary>
/// Provides controllers HTTP request handler
/// Provides controllers HTTP request handler.
/// </summary>
public class ControllersRequestHandler : IControllersRequestHandler
/// <remarks>
/// Initializes a new instance of the <see cref="ControllersRequestHandler" /> class.
/// </remarks>
/// <param name="controllersProcessor">The controllers request handler.</param>
/// <param name="pageProcessor">The page processor.</param>
/// <param name="redirector">The redirector.</param>
public class ControllersRequestHandler(IControllersProcessor controllersProcessor, IPageProcessor pageProcessor, IRedirector redirector) : IControllersRequestHandler
{
private readonly IControllersProcessor _controllersProcessor;
private readonly IPageProcessor _pageProcessor;
private readonly IRedirector _redirector;

/// <summary>
/// Initializes a new instance of the <see cref="ControllersRequestHandler" /> class.
/// </summary>
/// <param name="controllersProcessor">The controllers request handler.</param>
/// <param name="pageProcessor">The page processor.</param>
/// <param name="redirector">The redirector.</param>
public ControllersRequestHandler(IControllersProcessor controllersProcessor, IPageProcessor pageProcessor, IRedirector redirector)
{
_controllersProcessor = controllersProcessor;
_pageProcessor = pageProcessor;
_redirector = redirector;
}
private readonly IControllersProcessor _controllersProcessor = controllersProcessor;
private readonly IPageProcessor _pageProcessor = pageProcessor;
private readonly IRedirector _redirector = redirector;

/// <summary>
/// Gets or sets a value indicating whether Simplify.Web is terminal middleware.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Simplify.Web.Core.Controllers.Execution;

/// <summary>
/// Provides v1 controller factory
/// Provides v1 controller factory.
/// </summary>
public class Controller1Factory : ActionModulesAccessorBuilder, IController1Factory
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace Simplify.Web.Core.Controllers.Execution;

/// <summary>
/// Provides v2 controller factory
/// Provides v2 controller factory.
/// </summary>
public class Controller2Factory : ActionModulesAccessorBuilder, IController2Factory
{
Expand Down
6 changes: 3 additions & 3 deletions src/Simplify.Web/Core/Controllers/HandlerControllerType.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
namespace Simplify.Web.Core.Controllers;

/// <summary>
/// Handler controller types
/// Handler controller types.
/// </summary>
public enum HandlerControllerType
{
/// <summary>
/// The HTTP 404 handler
/// The HTTP 404 handler.
/// </summary>
Http404Handler,

/// <summary>
/// The HTTP 403 handler
/// The HTTP 403 handler.
/// </summary>
Http403Handler
}
2 changes: 1 addition & 1 deletion src/Simplify.Web/Core/Controllers/IControllersAgent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
namespace Simplify.Web.Core.Controllers;

/// <summary>
/// Represent controllers agent
/// Represent controllers agent.
/// </summary>
public interface IControllersAgent
{
Expand Down
4 changes: 2 additions & 2 deletions src/Simplify.Web/Core/Controllers/IControllersProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
namespace Simplify.Web.Core.Controllers;

/// <summary>
/// Represents controllers processor
/// Represents controllers processor.
/// </summary>
public interface IControllersProcessor
{
/// <summary>
/// Process controllers for current HTTP request
/// Process controllers for current HTTP request.
/// </summary>
/// <param name="resolver">The DI container resolver.</param>
/// <param name="context">The context.</param>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace Simplify.Web.Core.Controllers;

/// <summary>
/// Represent controllers HTTP request handler
/// Represent controllers HTTP request handler.
/// </summary>
public interface IControllersRequestHandler
{
Expand Down
Loading

0 comments on commit 61d292c

Please sign in to comment.