Commit 819c4465 authored by yangxiaodong's avatar yangxiaodong

cleanup code.

parent 821544b2
using System;
using System.Collections.Generic;
using System.Text;
namespace DotNetCore.CAP
{
......
using System;
using System.Collections.Generic;
using System.Text;
using DotNetCore.CAP.EntityFrameworkCore;
namespace DotNetCore.CAP
namespace DotNetCore.CAP
{
public class SqlServerOptions : EFOptions
{
......@@ -11,6 +6,5 @@ namespace DotNetCore.CAP
/// Gets or sets the database's connection string that will be used to store database entities.
/// </summary>
public string ConnectionString { get; set; } //= "Server=DESKTOP-M9R8T31;Initial Catalog=Test;User Id=sa;Password=P@ssw0rd;MultipleActiveResultSets=True";
}
}
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Text;
using DotNetCore.CAP.Models;
using DotNetCore.CAP.Models;
namespace DotNetCore.CAP.EntityFrameworkCore
{
......
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Text;
using System.Threading.Tasks;
using Dapper;
using DotNetCore.CAP.Processor;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
namespace DotNetCore.CAP.EntityFrameworkCore
......@@ -44,7 +41,7 @@ namespace DotNetCore.CAP.EntityFrameworkCore
var removedCount = 0;
do
{
using(var connection = new SqlConnection(_options.ConnectionString))
using (var connection = new SqlConnection(_options.ConnectionString))
{
removedCount = await connection.ExecuteAsync($@"
DELETE TOP (@count)
......
using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
using System.Threading;
using Dapper;
using DotNetCore.CAP.Models;
using Microsoft.EntityFrameworkCore.Storage;
namespace DotNetCore.CAP.EntityFrameworkCore
{
......
......@@ -43,7 +43,6 @@ namespace DotNetCore.CAP.EntityFrameworkCore
protected virtual string CreateDbTablesScript(string schema)
{
var batchSQL =
$@"
IF NOT EXISTS (SELECT * FROM sys.schemas WHERE name = '{schema}')
......
using System;
using DotNetCore.CAP;
using DotNetCore.CAP.Kafka;
namespace Microsoft.Extensions.DependencyInjection
{
......
......@@ -81,7 +81,6 @@ namespace DotNetCore.CAP.Kafka
MessageReceieved?.Invoke(sender, message);
}
#endregion private methods
}
}
\ No newline at end of file
......@@ -6,7 +6,6 @@ namespace DotNetCore.CAP.RabbitMQ
{
public CapSubscribeAttribute(string name) : base(name)
{
}
}
}
\ No newline at end of file
......@@ -64,7 +64,6 @@ namespace DotNetCore.CAP.RabbitMQ
Description = ex.Message
}));
}
}
}
}
\ No newline at end of file
......@@ -35,7 +35,6 @@ namespace DotNetCore.CAP
/// </summary>
public int PollingDelay { get; set; } = 8;
/// <summary>
/// Registers an extension that will be executed when building services.
/// </summary>
......
using System;
using System.Data;
using System.Data;
using System.Threading.Tasks;
namespace DotNetCore.CAP
......
using System;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using DotNetCore.CAP.Infrastructure;
......
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using System.Threading.Tasks;
namespace DotNetCore.CAP
{
......
......@@ -40,7 +40,7 @@ namespace DotNetCore.CAP.Infrastructure
public static long ToTimestamp(DateTime value)
{
var elapsedTime = value - Epoch;
return (long) elapsedTime.TotalSeconds;
return (long)elapsedTime.TotalSeconds;
}
public static DateTime FromTimestamp(long value)
......
using System;
using System.Collections.Generic;
using System.Text;
namespace DotNetCore.CAP.Infrastructure
namespace DotNetCore.CAP.Infrastructure
{
/// <summary>
/// The message status name.
......
......@@ -21,7 +21,7 @@ namespace DotNetCore.CAP.Infrastructure
var tcs = new TaskCompletionSource<bool>();
registeredHandle = ThreadPool.RegisterWaitForSingleObject(
handle,
(state, timedOut) => ((TaskCompletionSource<bool>) state).TrySetResult(!timedOut),
(state, timedOut) => ((TaskCompletionSource<bool>)state).TrySetResult(!timedOut),
tcs,
timeout,
true);
......
......@@ -44,7 +44,6 @@ namespace DotNetCore.CAP.Internal
return executorDescriptorList;
}
private static IEnumerable<ConsumerExecutorDescriptor> FindConsumersFromInterfaceTypes(
IServiceProvider provider)
{
......
using System;
using System.Linq;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using DotNetCore.CAP.Abstractions;
namespace DotNetCore.CAP.Internal
......
......@@ -130,7 +130,7 @@ namespace DotNetCore.CAP.Internal
private static ConsumerMethodExecutor WrapVoidAction(VoidActionExecutor executor)
{
return delegate(object target, object[] parameters)
return delegate (object target, object[] parameters)
{
executor(target, parameters);
return null;
......@@ -192,7 +192,7 @@ namespace DotNetCore.CAP.Internal
/// </summary>
private static async Task<object> CastToObject<T>(Task<T> task)
{
return (object) await task;
return (object)await task;
}
private static Type GetTaskInnerTypeOrNull(Type type)
......@@ -279,7 +279,7 @@ namespace DotNetCore.CAP.Internal
private static Task<object> Convert<T>(object taskAsObject)
{
var task = (Task<T>) taskAsObject;
var task = (Task<T>)taskAsObject;
return CastToObject<T>(task);
}
......
using System;
namespace DotNetCore.CAP.Internal
{
public class SubscriberNotFoundException : Exception
{
public SubscriberNotFoundException() { }
public SubscriberNotFoundException()
{
}
public SubscriberNotFoundException(string message) : base(message) { }
public SubscriberNotFoundException(string message) : base(message)
{
}
public SubscriberNotFoundException(string message, Exception inner) :
base(message, inner) { }
base(message, inner)
{ }
}
}
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Linq;
using DotNetCore.CAP.Processor;
using Microsoft.Extensions.Logging;
namespace DotNetCore.CAP
......@@ -66,7 +63,6 @@ namespace DotNetCore.CAP
5,
"Received message topic method '{topicName}' failed to execute.");
_jobRetrying = LoggerMessage.Define<int>(
LogLevel.Debug,
3,
......@@ -104,19 +100,16 @@ namespace DotNetCore.CAP
_jobFailedWillRetry(logger, ex);
}
public static void JobRetrying(this ILogger logger, int retries)
{
_jobRetrying(logger, retries, null);
}
public static void JobExecuted(this ILogger logger, double seconds)
{
_jobExecuted(logger, seconds, null);
}
public static void ConsumerMethodExecutingFailed(this ILogger logger, string methodName, Exception ex)
{
_executingConsumerMethod(logger, methodName, ex);
......
......@@ -32,7 +32,7 @@ namespace DotNetCore.CAP
/// Returns an <see cref="OperateResult"/> indicating a successful identity operation.
/// </summary>
/// <returns>An <see cref="OperateResult"/> indicating a successful operation.</returns>
public static OperateResult Success { get; } = new OperateResult {Succeeded = true};
public static OperateResult Success { get; } = new OperateResult { Succeeded = true };
/// <summary>
/// Creates an <see cref="OperateResult"/> indicating a failed operation, with a list of <paramref name="errors"/> if applicable.
......@@ -41,7 +41,7 @@ namespace DotNetCore.CAP
/// <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};
var result = new OperateResult { Succeeded = false };
if (errors != null)
{
result._errors.AddRange(errors);
......
using System;
using System.Collections.Generic;
using System.Text;
namespace DotNetCore.CAP.Processor
namespace DotNetCore.CAP.Processor
{
public interface IAdditionalProcessor : IProcessor
{
}
}
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Text;
namespace DotNetCore.CAP.Processor
namespace DotNetCore.CAP.Processor
{
public interface IDispatcher : IProcessor
{
......
......@@ -2,8 +2,8 @@
using System.Threading;
using System.Threading.Tasks;
using DotNetCore.CAP.Infrastructure;
using DotNetCore.CAP.Processor.States;
using DotNetCore.CAP.Models;
using DotNetCore.CAP.Processor.States;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
......
......@@ -2,8 +2,8 @@
using System.Threading;
using System.Threading.Tasks;
using DotNetCore.CAP.Infrastructure;
using DotNetCore.CAP.Processor.States;
using DotNetCore.CAP.Models;
using DotNetCore.CAP.Processor.States;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
......
......@@ -18,7 +18,7 @@ namespace DotNetCore.CAP.Processor
{
DefaultRetryCount = 25;
DefaultRetryInThunk = retries =>
(int) Math.Round(Math.Pow(retries - 1, 4) + 15 + (_random.Next(30) * (retries)));
(int)Math.Round(Math.Pow(retries - 1, 4) + 15 + (_random.Next(30) * (retries)));
DefaultRetry = new RetryBehavior(true);
NoRetry = new RetryBehavior(false);
......
......@@ -19,7 +19,7 @@ namespace DotNetCore.CAP
{
var _queueExectors = _serviceProvider.GetServices<IQueueExecutor>();
if (messageType== MessageType.Publish)
if (messageType == MessageType.Publish)
{
return _queueExectors.FirstOrDefault(x => typeof(BasePublishQueueExecutor).IsAssignableFrom(x.GetType()));
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment