Skip to content

Commit

Permalink
Refactoring + HttpClient rework
Browse files Browse the repository at this point in the history
  • Loading branch information
Jérôme Quiles committed Aug 24, 2017
1 parent 881467e commit 2590f91
Show file tree
Hide file tree
Showing 121 changed files with 1,312 additions and 1,389 deletions.
2 changes: 1 addition & 1 deletion Skeleton.Abstraction/Domain/IEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public interface IEntity<TEntity> :
IEntityValidatable<TEntity>,
IEntityDescriptor,
IEntityAuditable
where TEntity : class, IEntity<TEntity>
where TEntity : class, IEntity<TEntity>, new()
{
object Id { get; }

Expand Down
2 changes: 1 addition & 1 deletion Skeleton.Abstraction/Domain/IEntityValidatable.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
namespace Skeleton.Abstraction.Domain
{
public interface IEntityValidatable<out TEntity> : IHideObjectMethods
where TEntity : class, IEntity<TEntity>
where TEntity : class, IEntity<TEntity>, new()
{
IEntityValidationResult Validate(IEntityValidator<TEntity> validator);
}
Expand Down
2 changes: 1 addition & 1 deletion Skeleton.Abstraction/Domain/IEntityValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Skeleton.Abstraction.Domain
{
public interface IEntityValidator<in TEntity> : IHideObjectMethods
where TEntity : class, IEntity<TEntity>
where TEntity : class, IEntity<TEntity>, new()
{
IEnumerable<IValidationRule> BrokenRules(TEntity entity);
}
Expand Down
2 changes: 1 addition & 1 deletion Skeleton.Abstraction/Orm/IAsyncCachedEntityReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace Skeleton.Abstraction.Orm
{
public interface IAsyncCachedEntityReader<TEntity> :
IAsyncEntityReader<TEntity>
where TEntity : class, IEntity<TEntity>
where TEntity : class, IEntity<TEntity>, new()
{
IAsyncCacheProvider Cache { get; }

Expand Down
2 changes: 1 addition & 1 deletion Skeleton.Abstraction/Orm/IAsyncEntityAggregate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
namespace Skeleton.Abstraction.Orm
{
public interface IAsyncEntityAggregate<TEntity>
where TEntity : class, IEntity<TEntity>
where TEntity : class, IEntity<TEntity>, new()
{
Task<int> CountAsync();

Expand Down
2 changes: 1 addition & 1 deletion Skeleton.Abstraction/Orm/IAsyncEntityQuery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace Skeleton.Abstraction.Orm
{
public interface IAsyncEntityQuery<TEntity>
where TEntity : class, IEntity<TEntity>
where TEntity : class, IEntity<TEntity>, new()
{
Task<TEntity> FirstOrDefaultAsync();

Expand Down
9 changes: 4 additions & 5 deletions Skeleton.Abstraction/Orm/IAsyncEntityReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,29 @@ public interface IAsyncEntityReader<TEntity> :
IAsyncEntityAggregate<TEntity>,
IDisposable,
IHideObjectMethods
where TEntity : class, IEntity<TEntity>
where TEntity : class, IEntity<TEntity>, new()
{
IAsyncEntityReader<TEntity> GroupBy(
Expression<Func<TEntity, object>> expression);

IAsyncEntityReader<TEntity> LeftJoin<TEntity2>(
Expression<Func<TEntity, TEntity2, bool>> expression)
where TEntity2 : class, IEntity<TEntity2>;
where TEntity2 : class, IEntity<TEntity2>, new();

IAsyncEntityReader<TEntity> RightJoin<TEntity2>(
Expression<Func<TEntity, TEntity2, bool>> expression)
where TEntity2 : class, IEntity<TEntity2>;
where TEntity2 : class, IEntity<TEntity2>, new();

IAsyncEntityReader<TEntity> InnerJoin<TEntity2>(
Expression<Func<TEntity, TEntity2, bool>> expression)
where TEntity2 : class, IEntity<TEntity2>;
where TEntity2 : class, IEntity<TEntity2>, new();

IAsyncEntityReader<TEntity> OrderBy(
Expression<Func<TEntity, object>> expression);

IAsyncEntityReader<TEntity> OrderByDescending(
Expression<Func<TEntity, object>> expression);

[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Select")]
IAsyncEntityReader<TEntity> Select(
params Expression<Func<TEntity, object>>[] expressions);

Expand Down
2 changes: 1 addition & 1 deletion Skeleton.Abstraction/Orm/IAsyncEntityWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Skeleton.Abstraction.Orm
public interface IAsyncEntityWriter<in TEntity> :
IDisposable,
IHideObjectMethods
where TEntity : class, IEntity<TEntity>
where TEntity : class, IEntity<TEntity>, new()
{
Task<bool> AddAsync(TEntity entity);

Expand Down
2 changes: 1 addition & 1 deletion Skeleton.Abstraction/Orm/ICachedEntityReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace Skeleton.Abstraction.Orm
{
public interface ICachedEntityReader<TEntity> :
IEntityReader<TEntity>
where TEntity : class, IEntity<TEntity>
where TEntity : class, IEntity<TEntity>, new()
{
ICacheProvider Cache { get; }

Expand Down
2 changes: 1 addition & 1 deletion Skeleton.Abstraction/Orm/IEntityAggregate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
namespace Skeleton.Abstraction.Orm
{
public interface IEntityAggregate<TEntity>
where TEntity : class, IEntity<TEntity>
where TEntity : class, IEntity<TEntity>, new()
{
int Count();

Expand Down
4 changes: 2 additions & 2 deletions Skeleton.Abstraction/Orm/IEntityMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ namespace Skeleton.Abstraction.Orm
{
public interface IEntityMapper<TEntity, TDto> :
IHideObjectMethods
where TEntity : class, IEntity<TEntity>
where TDto : class
where TEntity : class, IEntity<TEntity>, new()
where TDto : class, new()
{
TDto Map(TEntity entity);

Expand Down
2 changes: 1 addition & 1 deletion Skeleton.Abstraction/Orm/IEntityQuery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace Skeleton.Abstraction.Orm
{
public interface IEntityQuery<TEntity>
where TEntity : class, IEntity<TEntity>
where TEntity : class, IEntity<TEntity>, new()
{
TEntity FirstOrDefault();

Expand Down
9 changes: 4 additions & 5 deletions Skeleton.Abstraction/Orm/IEntityReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,29 @@ public interface IEntityReader<TEntity> :
IEntityAggregate<TEntity>,
IDisposable,
IHideObjectMethods
where TEntity : class, IEntity<TEntity>
where TEntity : class, IEntity<TEntity>, new()
{
IEntityReader<TEntity> GroupBy(
Expression<Func<TEntity, object>> expression);

IEntityReader<TEntity> LeftJoin<TEntity2>(
Expression<Func<TEntity, TEntity2, bool>> expression)
where TEntity2 : class, IEntity<TEntity2>;
where TEntity2 : class, IEntity<TEntity2>, new();

IEntityReader<TEntity> RightJoin<TEntity2>(
Expression<Func<TEntity, TEntity2, bool>> expression)
where TEntity2 : class, IEntity<TEntity2>;
where TEntity2 : class, IEntity<TEntity2>, new();

IEntityReader<TEntity> InnerJoin<TEntity2>(
Expression<Func<TEntity, TEntity2, bool>> expression)
where TEntity2 : class, IEntity<TEntity2>;
where TEntity2 : class, IEntity<TEntity2>, new();

IEntityReader<TEntity> OrderBy(
Expression<Func<TEntity, object>> expression);

IEntityReader<TEntity> OrderByDescending(
Expression<Func<TEntity, object>> expression);

[SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Select")]
IEntityReader<TEntity> Select(
params Expression<Func<TEntity, object>>[] expressions);

Expand Down
2 changes: 1 addition & 1 deletion Skeleton.Abstraction/Orm/IEntityWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Skeleton.Abstraction.Orm
public interface IEntityWriter<in TEntity> :
IDisposable,
IHideObjectMethods
where TEntity : class, IEntity<TEntity>
where TEntity : class, IEntity<TEntity>, new()
{
bool Add(TEntity entity);

Expand Down
4 changes: 2 additions & 2 deletions Skeleton.Core/Caching/MemoryCacheProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ public sealed class MemoryCacheProvider :

public T GetOrAdd<T>(string key, Func<T> valueFactory, Action<ICacheConfiguration> configurator)
{
key.ThrowIfNullOrEmpty(nameof(key));
valueFactory.ThrowIfNull(nameof(valueFactory));
key.ThrowIfNullOrEmpty();
valueFactory.ThrowIfNull();

try
{
Expand Down
2 changes: 1 addition & 1 deletion Skeleton.Core/ConvertExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public static class ConvertExtensions
{
public static object ChangeType(this object value, Type type, IFormatProvider provider)
{
type.ThrowIfNull(nameof(type));
type.ThrowIfNull();

while (true)
{
Expand Down
6 changes: 3 additions & 3 deletions Skeleton.Core/DictionaryExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ public static class DictionaryExtensions
TKey key,
Func<TValue> valueFactory)
{
source.ThrowIfNull(nameof(source));
key.ThrowIfNull(nameof(key));
valueFactory.ThrowIfNull(nameof(valueFactory));
source.ThrowIfNull();
key.ThrowIfNull();
valueFactory.ThrowIfNull();

if (source.ContainsKey(key))
return source[key];
Expand Down
6 changes: 3 additions & 3 deletions Skeleton.Core/Domain/EntityBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ namespace Skeleton.Core.Domain
{
[DebuggerDisplay("Id = {ToString()}")]
public abstract class EntityBase<TEntity> : IEntity<TEntity>
where TEntity : class, IEntity<TEntity>
where TEntity : class, IEntity<TEntity>, new()
{
private const int HashMultiplier = 31;

protected EntityBase(Expression<Func<TEntity, object>> idExpression)
{
idExpression.ThrowIfNull(nameof(idExpression));
idExpression.ThrowIfNull();

Metadata = new MetadataProvider().GetMetadata(typeof(TEntity));
IdAccessor = Metadata.GetProperty(idExpression);
Expand Down Expand Up @@ -58,7 +58,7 @@ public virtual bool IsTransient()

public IEntityValidationResult Validate(IEntityValidator<TEntity> validator)
{
validator.ThrowIfNull(nameof(validator));
validator.ThrowIfNull();

return new EntityValidationResult(validator.BrokenRules(this as TEntity));
}
Expand Down
2 changes: 1 addition & 1 deletion Skeleton.Core/Domain/EntityValidationResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public sealed class EntityValidationResult : IEntityValidationResult
public EntityValidationResult(IEnumerable<IValidationRule> brokenRules)
{
var enumerable = brokenRules.AsList();
enumerable.ThrowIfNull(nameof(enumerable));
enumerable.ThrowIfNull();

BrokenRules = enumerable;
}
Expand Down
2 changes: 1 addition & 1 deletion Skeleton.Core/Domain/EntityValidatorBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace Skeleton.Core.Domain
{
public abstract class EntityValidatorBase<TEntity> : IEntityValidator<TEntity>
where TEntity : class, IEntity<TEntity>
where TEntity : class, IEntity<TEntity>, new()
{
private readonly List<IValidationRule> _brokenRules = new List<IValidationRule>();

Expand Down
Binary file removed Skeleton.Core/Domain/GlobalSuppressions.cs
Binary file not shown.
8 changes: 4 additions & 4 deletions Skeleton.Core/EnumerableExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public static List<T> AsList<T>(this IEnumerable<T> source)

public static bool FastAny<TSource>(this IEnumerable<TSource> source)
{
source.ThrowIfNull(nameof(source));
source.ThrowIfNull();

var enumerable = source as IList<TSource> ?? source.ToList();
var collection = source as ICollection<TSource>;
Expand All @@ -37,8 +37,8 @@ public static bool FastAny<TSource>(this IEnumerable<TSource> source)

public static void ForEach<TSource>(this IEnumerable<TSource> source, Action<TSource> action)
{
source.ThrowIfNull(nameof(source));
action.ThrowIfNull(nameof(action));
source.ThrowIfNull();
action.ThrowIfNull();

var enumerable = source as IList<TSource> ?? source.ToList();

Expand All @@ -58,7 +58,7 @@ public static bool IsNullOrEmpty<TSource>(this IEnumerable<TSource> source)

public static Task<List<TSource>> ToListAsync<TSource>(this IEnumerable<TSource> source)
{
source.ThrowIfNull(nameof(source));
source.ThrowIfNull();

return Task.Run(() => source.ToList());
}
Expand Down
11 changes: 5 additions & 6 deletions Skeleton.Core/ExpressionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public static class ExpressionExtensions
{
public static BinaryExpression GetBinaryExpression(this Expression expression)
{
expression.ThrowIfNull(nameof(expression));
expression.ThrowIfNull();

var binaryExpression = expression as BinaryExpression;
if (binaryExpression != null)
Expand All @@ -21,7 +21,7 @@ public static BinaryExpression GetBinaryExpression(this Expression expression)

public static object GetExpressionValue(this Expression expression)
{
expression.ThrowIfNull(nameof(expression));
expression.ThrowIfNull();

var constantExpression = expression as ConstantExpression;
if (constantExpression != null)
Expand Down Expand Up @@ -64,7 +64,7 @@ private static object GetValue(this MemberExpression expression, object instance

public static MemberExpression GetMemberExpression(this Expression expression)
{
expression.ThrowIfNull(nameof(expression));
expression.ThrowIfNull();

while (true)
{
Expand All @@ -85,7 +85,7 @@ public static MemberExpression GetMemberExpression(this Expression expression)

public static PropertyInfo GetPropertyAccess(this LambdaExpression expression)
{
expression.ThrowIfNull(nameof(expression));
expression.ThrowIfNull();

if (expression.Parameters.Count != 1)
throw new ArgumentException("Expression must have at least 1 parameter");
Expand All @@ -104,7 +104,7 @@ public static PropertyInfo GetPropertyAccess(this LambdaExpression expression)

public static object InvokeMethodCall(this MethodCallExpression callExpression)
{
callExpression.ThrowIfNull(nameof(callExpression));
callExpression.ThrowIfNull();

var arguments = callExpression.Arguments.Select(GetExpressionValue).ToArray();
var obj = callExpression.Object != null
Expand All @@ -119,7 +119,6 @@ public static object InvokeMethodCall(this MethodCallExpression callExpression)
Expression propertyAccessExpression)
{
var propertyInfos = new List<PropertyInfo>();

MemberExpression memberExpression;

do
Expand Down
9 changes: 4 additions & 5 deletions Skeleton.Core/GuardExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Runtime.CompilerServices;

namespace Skeleton.Core
{
[DebuggerStepThrough]
public static class GuardExtensions
{
public static void ThrowIfNull<T>(this T value, string parameterName)
public static void ThrowIfNull<T>(this T value, [CallerMemberName] string parameterName = null)
{
if (value.Equals(default(T)))
throw new ArgumentNullException(parameterName ?? "object");
}

public static void ThrowIfNullOrEmpty<T>(this IEnumerable<T> value, string parameterName)
public static void ThrowIfNullOrEmpty<T>(this IEnumerable<T> value, [CallerMemberName] string parameterName = null)
{
if (value.IsNullOrEmpty())
throw new ArgumentNullException(parameterName ?? "collection");
}

public static void ThrowIfNullOrEmpty(this string value, string parameterName)
public static void ThrowIfNullOrEmpty(this string value, [CallerMemberName] string parameterName = null)
{
value.ThrowIfNull(nameof(parameterName));

if (string.IsNullOrEmpty(value))
throw new ArgumentException("Argument cannot be null", parameterName ?? "string");
}
Expand Down
2 changes: 1 addition & 1 deletion Skeleton.Core/LazyRef.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public sealed class LazyRef<T> : HideObjectMethodsBase

public LazyRef(Func<T> initializer)
{
initializer.ThrowIfNull(nameof(initializer));
initializer.ThrowIfNull();

_initializer = initializer;
}
Expand Down
5 changes: 2 additions & 3 deletions Skeleton.Core/Reflection/ConstructorAccessor.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Skeleton.Abstraction.Reflection;
using Skeleton.Core.Reflection.Emitter;
using System;

namespace Skeleton.Core.Reflection
Expand All @@ -10,8 +9,8 @@ public sealed class ConstructorAccessor : IInstanceAccessor

public ConstructorAccessor(Type type, Type[] paramTypes)
{
type.ThrowIfNull(nameof(type));
paramTypes.ThrowIfNull(nameof(paramTypes));
type.ThrowIfNull();
paramTypes.ThrowIfNull();

var emitter = new ConstructorEmitter(type, paramTypes);
_constructorDelegate = emitter.CreateDelegate();
Expand Down
Loading

0 comments on commit 2590f91

Please sign in to comment.