@@ -2,6 +2,7 @@ | |||
using Microsoft.Extensions.DependencyInjection; | |||
using System; | |||
// ReSharper disable once CheckNamespace | |||
namespace Microsoft.AspNetCore.Builder | |||
{ | |||
/// <summary> | |||
@@ -3,13 +3,14 @@ using System; | |||
namespace Cap.Consistency | |||
{ | |||
/// <summary> | |||
/// Creates a new instance of <see cref="ConsistenceBuilder"/>. | |||
/// </summary> | |||
/// <param name="message">The <see cref="Type"/> to use for the message.</param> | |||
/// <param name="services">The <see cref="IServiceCollection"/> to attach to.</param> | |||
public class ConsistenceBuilder | |||
{ | |||
/// <summary> | |||
/// Creates a new instance of <see cref="ConsistenceBuilder"/>. | |||
/// </summary> | |||
/// <param name="message">The <see cref="Type"/> to use for the message.</param> | |||
/// <param name="service">The <see cref="IServiceCollection"/> to attach to.</param> | |||
public ConsistenceBuilder(Type message, IServiceCollection service) { | |||
MessageType = message; | |||
Services = service; | |||
@@ -32,10 +33,10 @@ namespace Cap.Consistency | |||
public Type MessageType { get; private set; } | |||
/// <summary> | |||
/// Adds a <see cref="IRoleStore{TRole}"/> for the <seealso cref="RoleType"/>. | |||
/// Adds a <see cref="IConsistentMessageStore{TMessage}"/> for the <seealso cref="MessageType"/>. | |||
/// </summary> | |||
/// <typeparam name="T">The role type held in the store.</typeparam> | |||
/// <returns>The current <see cref="IdentityBuilder"/> instance.</returns> | |||
/// <returns>The current <see cref="ConsistenceBuilder"/> instance.</returns> | |||
public virtual ConsistenceBuilder AddMessageStore<T>() where T : class { | |||
return AddScoped(typeof(IConsistentMessageStore<>).MakeGenericType(MessageType), typeof(T)); | |||
} | |||
@@ -103,7 +103,7 @@ namespace Cap.Consistency | |||
/// <summary> | |||
/// Finds and returns a message, if any, who has the specified <paramref name="messageId"/>. | |||
/// </summary> | |||
/// <param name="userId">The message ID to search for.</param> | |||
/// <param name="messageId">The message ID to search for.</param> | |||
/// <returns> | |||
/// The <see cref="Task"/> that represents the asynchronous operation, containing the user matching the specified <paramref name="messageId"/> if it exists. | |||
/// </returns> | |||
@@ -113,9 +113,9 @@ namespace Cap.Consistency | |||
} | |||
/// <summary> | |||
/// Gets the message identifier for the specified <paramref name="user"/>. | |||
/// Gets the message identifier for the specified <paramref name="message"/>. | |||
/// </summary> | |||
/// <param name="user">The message whose identifier should be retrieved.</param> | |||
/// <param name="message">The message whose identifier should be retrieved.</param> | |||
/// <returns>The <see cref="Task"/> that represents the asynchronous operation, containing the identifier for the specified <paramref name="message"/>.</returns> | |||
public virtual async Task<string> GetMessageIdAsync(TMessage message) { | |||
ThrowIfDisposed(); | |||
@@ -25,7 +25,7 @@ namespace Cap.Consistency | |||
/// </summary> | |||
/// <param name="message">The message to create in the store.</param> | |||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param> | |||
/// <returns>A <see cref="Task{TResult}"/> that represents the <see cref="IdentityResult"/> of the asynchronous query.</returns> | |||
/// <returns>A <see cref="Task{TResult}"/> that represents the <see cref="OperateResult"/> of the asynchronous query.</returns> | |||
Task<OperateResult> CreateAsync(TMessage message, CancellationToken cancellationToken); | |||
/// <summary> | |||
@@ -33,7 +33,7 @@ namespace Cap.Consistency | |||
/// </summary> | |||
/// <param name="message">The message to update in the store.</param> | |||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param> | |||
/// <returns>A <see cref="Task{TResult}"/> that represents the <see cref="IdentityResult"/> of the asynchronous query.</returns> | |||
/// <returns>A <see cref="Task{TResult}"/> that represents the <see cref="OperateResult"/> of the asynchronous query.</returns> | |||
Task<OperateResult> UpdateAsync(TMessage message, CancellationToken cancellationToken); | |||
/// <summary> | |||
@@ -41,7 +41,7 @@ namespace Cap.Consistency | |||
/// </summary> | |||
/// <param name="message">The message to delete in the store.</param> | |||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param> | |||
/// <returns>A <see cref="Task{TResult}"/> that represents the <see cref="IdentityResult"/> of the asynchronous query.</returns> | |||
/// <returns>A <see cref="Task{TResult}"/> that represents the <see cref="OperateResult"/> of the asynchronous query.</returns> | |||
Task<OperateResult> DeleteAsync(TMessage message, CancellationToken cancellationToken); | |||
/// <summary> | |||
@@ -8,7 +8,10 @@ namespace Cap.Consistency | |||
/// </summary> | |||
public class OperateResult | |||
{ | |||
// ReSharper disable once InconsistentNaming | |||
private static readonly OperateResult _success = new OperateResult { Succeeded = true }; | |||
// ReSharper disable once FieldCanBeMadeReadOnly.Local | |||
private List<OperateError> _errors = new List<OperateError>(); | |||
/// <summary> | |||
@@ -24,16 +27,16 @@ namespace Cap.Consistency | |||
public IEnumerable<OperateError> Errors => _errors; | |||
/// <summary> | |||
/// Returns an <see cref="IdentityResult"/> indicating a successful identity operation. | |||
/// Returns an <see cref="OperateResult"/> indicating a successful identity operation. | |||
/// </summary> | |||
/// <returns>An <see cref="IdentityResult"/> indicating a successful operation.</returns> | |||
/// <returns>An <see cref="OperateResult"/> indicating a successful operation.</returns> | |||
public static OperateResult Success => _success; | |||
/// <summary> | |||
/// Creates an <see cref="IdentityResult"/> indicating a failed operation, with a list of <paramref name="errors"/> if applicable. | |||
/// Creates an <see cref="OperateResult"/> indicating a failed operation, with a list of <paramref name="errors"/> if applicable. | |||
/// </summary> | |||
/// <param name="errors">An optional array of <see cref="IdentityError"/>s which caused the operation to fail.</param> | |||
/// <returns>An <see cref="IdentityResult"/> indicating a failed operation, with a list of <paramref name="errors"/> if applicable.</returns> | |||
/// <param name="errors">An optional array of <see cref="OperateError"/>s which caused the operation to fail.</param> | |||
/// <returns>An <see cref="OperateResult"/> indicating a failed operation, with a list of <paramref name="errors"/> if applicable.</returns> | |||
public static OperateResult Failed(params OperateError[] errors) { | |||
var result = new OperateResult { Succeeded = false }; | |||
if (errors != null) { | |||
@@ -43,9 +46,9 @@ namespace Cap.Consistency | |||
} | |||
/// <summary> | |||
/// Converts the value of the current <see cref="IdentityResult"/> object to its equivalent string representation. | |||
/// Converts the value of the current <see cref="OperateResult"/> object to its equivalent string representation. | |||
/// </summary> | |||
/// <returns>A string representation of the current <see cref="IdentityResult"/> object.</returns> | |||
/// <returns>A string representation of the current <see cref="OperateResult"/> object.</returns> | |||
/// <remarks> | |||
/// If the operation was successful the ToString() will return "Succeeded" otherwise it returned | |||
/// "Failed : " followed by a comma delimited list of error codes from its <see cref="Errors"/> collection, if any. | |||
@@ -1,6 +1,7 @@ | |||
using Cap.Consistency; | |||
using Microsoft.Extensions.DependencyInjection.Extensions; | |||
// ReSharper disable once CheckNamespace | |||
namespace Microsoft.Extensions.DependencyInjection | |||
{ | |||
/// <summary> | |||
@@ -1,16 +1,14 @@ | |||
{ | |||
{ | |||
"version": "1.0.0-*", | |||
"dependencies": { | |||
"Microsoft.AspNetCore.Http.Abstractions": "1.1.0-*", | |||
"Microsoft.Extensions.DependencyInjection.Abstractions": "1.1.0", | |||
"Microsoft.Extensions.Logging.Abstractions": "1.1.0-*", | |||
"NETStandard.Library": "1.6.1" | |||
}, | |||
"frameworks": { | |||
"netstandard1.6": { | |||
"imports": "dnxcore50" | |||
} | |||
} | |||
} | |||
} |