Skip to content

Fast.UnifyResult public API

Targets: net8.0;net9.0;net10.0. This is a declaration and XML-comment reference. See the module guide for usage and constraints.

Source commit: 43554c07f6c216f80b509bd535c0a5b66ae7f2e8. Maintained through scripts/export-dotnet-api.ps1 -Language en; ordinary site builds consume this file directly.

Fast.UnifyResult.NonUnifyAttribute

Source · Targets: net8.0, net9.0, net10.0

csharp
[SuppressSniffer]
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class)]
public sealed class NonUnifyAttribute : Attribute

Disable normalization

Fast.UnifyResult.NonValidationAttribute

Source · Targets: net8.0, net9.0, net10.0

csharp
[SuppressSniffer]
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class)]
public sealed class NonValidationAttribute : Attribute

Skip validation

Fast.UnifyResult.UnifyContext

Source · Targets: net8.0, net9.0, net10.0

csharp
[SuppressSniffer]
public static class UnifyContext

Normalized result context

Fast.UnifyResult.UnifyContext.EnabledUnifyHandler = false

Source · Targets: net8.0, net9.0, net10.0

csharp
public static bool EnabledUnifyHandler = false;

Whether result normalization is enabled

Fast.UnifyResult.UnifyContext.UnifyResultType

Source · Targets: net8.0, net9.0, net10.0

csharp
public static Type UnifyResultType { get; }

Unified response type

Fast.UnifyResult.UnifyContext.HandleRestfulStatusCode

Source · Targets: net8.0, net9.0, net10.0

csharp
public static RestfulResult<object> HandleRestfulStatusCode(int code, object data, string message, HttpContext httpContext)

Handles RESTful response status codes

  • Parameter code: Business or enum code
  • Parameter data: Data to process or transmit
  • Parameter message: Message to record or return
  • Parameter httpContext: Current request context
  • Returns: Handles RESTful response status codes

Fast.UnifyResult.UnifyContext.GetRestfulResult

Source · Targets: net8.0, net9.0, net10.0

csharp
public static RestfulResult<object> GetRestfulResult(int code, bool success, object data, object message,
        HttpContext httpContext)

Gets a normalized RESTful response

  • Parameter code: Business or enum code
  • Parameter success: Whether the operation succeeded
  • Parameter data: Data to process or transmit
  • Parameter message: Message to record or return
  • Parameter httpContext: Current request context
  • Returns: Normalized RESTful response

Fast.UnifyResult.IServiceCollectionExtension

Source · Targets: net8.0, net9.0, net10.0

csharp
[SuppressSniffer]
public static class IServiceCollectionExtension

Provides unified-response extensions for IServiceCollection

Fast.UnifyResult.IServiceCollectionExtension.AddDataValidation

Source · Targets: net8.0, net9.0, net10.0

csharp
public static IServiceCollection AddDataValidation(this IServiceCollection services)

Data-validation services

  • Parameter services: The service collection to add services to
  • Returns: Returns services for chaining

Fast.UnifyResult.IServiceCollectionExtension.AddFriendlyException

Source · Targets: net8.0, net9.0, net10.0

csharp
public static IServiceCollection AddFriendlyException(this IServiceCollection services)

User-friendly exception services

  • Parameter services: The service collection to add services to
  • Returns: Returns services for chaining

Fast.UnifyResult.IServiceCollectionExtension.AddUnifyResult

Source · Targets: net8.0, net9.0, net10.0

csharp
public static IServiceCollection AddUnifyResult(this IServiceCollection services)

Adds unified-response services

  • Parameter services: The service collection to add services to
  • Returns: Returns services for chaining

Fast.UnifyResult.IGlobalExceptionHandler

Source · Targets: net8.0, net9.0, net10.0

csharp
public interface IGlobalExceptionHandler

Global exception handling

Fast.UnifyResult.IGlobalExceptionHandler.OnExceptionAsync

Source · Targets: net8.0, net9.0, net10.0

csharp
Task OnExceptionAsync(ExceptionContext context, bool isUserFriendlyException, bool isValidationException);

Exception interception

  • Parameter context: Current exception handling context
  • Parameter isUserFriendlyException: Whether to treat the exception as safe to display directly to the user
  • Parameter isValidationException: Whether to treat the exception as a parameter-validation exception
  • Returns: A task representing exception interception

Fast.UnifyResult.ExceptionMetadata

Source · Targets: net8.0, net9.0, net10.0

csharp
[SuppressSniffer]
public sealed class ExceptionMetadata

Exception metadata

Fast.UnifyResult.ExceptionMetadata.StatusCode

Source · Targets: net8.0, net9.0, net10.0

csharp
public int StatusCode { get; set; }

Status code

Fast.UnifyResult.ExceptionMetadata.ErrorCode

Source · Targets: net8.0, net9.0, net10.0

csharp
public object ErrorCode { get; set; }

Error code

Fast.UnifyResult.ExceptionMetadata.OriginErrorCode

Source · Targets: net8.0, net9.0, net10.0

csharp
public object OriginErrorCode { get; set; }

Original error code before ErrorCode was overridden

Fast.UnifyResult.ExceptionMetadata.Errors

Source · Targets: net8.0, net9.0, net10.0

csharp
public object Errors { get; set; }

Error object or information

Fast.UnifyResult.ExceptionMetadata.Data

Source · Targets: net8.0, net9.0, net10.0

csharp
public object Data { get; set; }

Additional data

Fast.UnifyResult.ValidationMetadata

Source · Targets: net8.0, net9.0, net10.0

csharp
[SuppressSniffer]
public sealed class ValidationMetadata

Validation metadata

Fast.UnifyResult.ValidationMetadata.ValidationResult

Source · Targets: net8.0, net9.0, net10.0

csharp
public object ValidationResult { get; set; }

Validation result

Remarks: Returns a dictionary or string

Fast.UnifyResult.ValidationMetadata.Message

Source · Targets: net8.0, net9.0, net10.0

csharp
public string Message { get; set; }

Exception message

Fast.UnifyResult.ValidationMetadata.ModelState

Source · Targets: net8.0, net9.0, net10.0

csharp
public ModelStateDictionary ModelState { get; set; }

Validation status

Fast.UnifyResult.ValidationMetadata.ErrorCode

Source · Targets: net8.0, net9.0, net10.0

csharp
public object ErrorCode { get; set; }

Error code

Fast.UnifyResult.ValidationMetadata.OriginErrorCode

Source · Targets: net8.0, net9.0, net10.0

csharp
public object OriginErrorCode { get; set; }

Original error code before ErrorCode was overridden

Fast.UnifyResult.ValidationMetadata.StatusCode

Source · Targets: net8.0, net9.0, net10.0

csharp
public int? StatusCode { get; set; }

Status code

Fast.UnifyResult.ValidationMetadata.FirstErrorProperty

Source · Targets: net8.0, net9.0, net10.0

csharp
public string FirstErrorProperty { get; set; }

First invalid property

Fast.UnifyResult.ValidationMetadata.FirstErrorMessage

Source · Targets: net8.0, net9.0, net10.0

csharp
public string FirstErrorMessage { get; set; }

First error message

Fast.UnifyResult.ValidationMetadata.Data

Source · Targets: net8.0, net9.0, net10.0

csharp
public object Data { get; set; }

Additional data

Fast.UnifyResult.IUnifyResponseProvider

Source · Targets: net8.0, net9.0, net10.0

csharp
public interface IUnifyResponseProvider

Normalized response data provider

Fast.UnifyResult.IUnifyResponseProvider.ResponseExceptionAsync

Source · Targets: net8.0, net9.0, net10.0

csharp
Task<(int statusCode, string message)> ResponseExceptionAsync(ExceptionContext context, ExceptionMetadata metadata,
        HttpContext httpContext);

Handles exception responses

  • Parameter context: Current exception handling context
  • Parameter metadata: Metadata for the exception response
  • Parameter httpContext: Current request context
  • Returns: A task whose result is the exception response

Fast.UnifyResult.IUnifyResponseProvider.ResponseValidationExceptionAsync

Source · Targets: net8.0, net9.0, net10.0

csharp
Task ResponseValidationExceptionAsync(ActionExecutingContext context, ValidationMetadata metadata, HttpContext httpContext);

Handles data-validation error responses

  • Parameter context: Current action context
  • Parameter metadata: Metadata for the validation failure response
  • Parameter httpContext: Current request context
  • Returns: A task representing validation-error response handling

Fast.UnifyResult.IUnifyResponseProvider.ResponseDataAsync

Source · Targets: net8.0, net9.0, net10.0

csharp
Task<object> ResponseDataAsync(long timestamp, object data, HttpContext httpContext);

Processes response data

Remarks: Called only for a successful normal response

  • Parameter timestamp: Timestamp
  • Parameter data: Data to process or transmit
  • Parameter httpContext: Current request context
  • Returns: A task whose result is the processed response

Fast.UnifyResult.IUnifyResultProvider

Source · Targets: net8.0, net9.0, net10.0

csharp
public interface IUnifyResultProvider

Normalized result provider

Fast.UnifyResult.IUnifyResultProvider.OnException

Source · Targets: net8.0, net9.0, net10.0

csharp
IActionResult OnException(ExceptionContext context, ExceptionMetadata metadata, int? statusCode = null,
        string message = null);

Exception response value

  • Parameter context: Current exception handling context
  • Parameter metadata: Metadata for the exception response
  • Parameter statusCode: HTTP status code
  • Parameter message: Message to record or return
  • Returns: Exception response value

Fast.UnifyResult.IUnifyResultProvider.OnSucceeded

Source · Targets: net8.0, net9.0, net10.0

csharp
IActionResult OnSucceeded(ActionExecutedContext context, object data);

Successful response value

  • Parameter context: Current action context
  • Parameter data: Data to process or transmit
  • Returns: Successful response value

Fast.UnifyResult.IUnifyResultProvider.OnValidateFailed

Source · Targets: net8.0, net9.0, net10.0

csharp
IActionResult OnValidateFailed(ActionExecutingContext context, ValidationMetadata metadata);

Validation failure response value

  • Parameter context: Current action context
  • Parameter metadata: Metadata for the validation failure response
  • Returns: Validation failure response value

Fast.UnifyResult.IUnifyResultProvider.OnResponseStatusCodes

Source · Targets: net8.0, net9.0, net10.0

csharp
Task OnResponseStatusCodes(HttpContext httpContext, int statusCode);

Intercepts response status codes

  • Parameter httpContext: Current request context
  • Parameter statusCode: HTTP status code
  • Returns: A task representing response status-code interception

Fast.UnifyResult.BadPageResult

Source · Targets: net8.0, net9.0, net10.0

csharp
[SuppressSniffer]
public class BadPageResult : StatusCodeResult

Error page

Fast.UnifyResult.BadPageResult.Title

Source · Targets: net8.0, net9.0, net10.0

csharp
public string Title { get; set; } = "ModelState Invalid";

Title

Fast.UnifyResult.BadPageResult.Description

Source · Targets: net8.0, net9.0, net10.0

csharp
public string Description { get; set; } = "User data verification failed. Please input it correctly.";

Description

Fast.UnifyResult.BadPageResult.Base64Icon

Source · Targets: net8.0, net9.0, net10.0

csharp
public string Base64Icon { get; set; } =
        "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTE0LjIxIDEzLjVsMS43NjcgMS43NzMtLjcwNC43MDRMMTMuNSAxNC4yMWwtMS43NzMgMS43NzMtLjcwNC0uNzEgMS43NzQtMS43NzQtMS43NzQtMS43NzMuNzA0LS43MDQgMS43NzMgMS43NzQgMS43NzMtMS43NzQuNzA0LjcxMUwxNC4yMSAxMy41ek0yIDE1aDh2MUgxVjBoOC43MUwxNCA0LjI5VjEwaC0xVjVIOVYxSDJ2MTR6bTgtMTFoMi4yOUwxMCAxLjcxVjR6IiBmaWxsPSIjMTAxMDEwIi8+PC9zdmc+";

Icon

Remarks: Must be base64 encoded

Fast.UnifyResult.BadPageResult.Code

Source · Targets: net8.0, net9.0, net10.0

csharp
public string Code { get; set; } = "";

Error code

Fast.UnifyResult.BadPageResult.CodeLang

Source · Targets: net8.0, net9.0, net10.0

csharp
public string CodeLang { get; set; } = "json";

Error code language

Fast.UnifyResult.BadPageResult.Status401Unauthorized

Source · Targets: net8.0, net9.0, net10.0

csharp
public static BadPageResult Status401Unauthorized { get; }

Returns a generic 401 error page

Fast.UnifyResult.BadPageResult.Status403Forbidden

Source · Targets: net8.0, net9.0, net10.0

csharp
public static BadPageResult Status403Forbidden { get; }

Returns a generic 403 error page

Fast.UnifyResult.BadPageResult.Status404NotFound

Source · Targets: net8.0, net9.0, net10.0

csharp
public static BadPageResult Status404NotFound { get; }

Returns a generic 404 error page

Fast.UnifyResult.BadPageResult.Status500InternalServerError

Source · Targets: net8.0, net9.0, net10.0

csharp
public static BadPageResult Status500InternalServerError { get; }

Returns a generic 500 error page

Fast.UnifyResult.BadPageResult.BadPageResult

Source · Targets: net8.0, net9.0, net10.0

csharp
public BadPageResult() : base(400)

Initializes an error-page result returning HTTP 400 by default

Fast.UnifyResult.BadPageResult.BadPageResult

Source · Targets: net8.0, net9.0, net10.0

csharp
public BadPageResult(int statusCode) : base(statusCode)

Initializes an error-page result with the specified HTTP status code

  • Parameter statusCode: HTTP status code to write to the response

Fast.UnifyResult.BadPageResult.ExecuteResult

Source · Targets: net8.0, net9.0, net10.0

csharp
public override void ExecuteResult(ActionContext context)

Documentation is inherited from an interface or base class; consult that declaration.

Fast.UnifyResult.BadPageResult.ToString

Source · Targets: net8.0, net9.0, net10.0

csharp
public override string ToString()

Documentation is inherited from an interface or base class; consult that declaration.

Fast.UnifyResult.RestfulResult

Source · Targets: net8.0, net9.0, net10.0

csharp
[SuppressSniffer]
public class RestfulResult<T>

RESTful response format

  • Type parameter T: Value type handled by this type

Fast.UnifyResult.RestfulResult.Success

Source · Targets: net8.0, net9.0, net10.0

csharp
public bool Success { get; set; }

Execution succeeded

Fast.UnifyResult.RestfulResult.Code

Source · Targets: net8.0, net9.0, net10.0

csharp
public int? Code { get; set; }

Status code

Fast.UnifyResult.RestfulResult.Message

Source · Targets: net8.0, net9.0, net10.0

csharp
public object Message { get; set; }

Error information

Fast.UnifyResult.RestfulResult.Data

Source · Targets: net8.0, net9.0, net10.0

csharp
public T Data { get; set; }

Data

Fast.UnifyResult.RestfulResult.Timestamp

Source · Targets: net8.0, net9.0, net10.0

csharp
public long Timestamp { get; set; }

Timestamp