Browse Source

Added ICancellationTokenProvider. Moved Abp project to latest c# language features.

pull/179/head
Halil İbrahim Kalkan 9 years ago
parent
commit
0ecc1ee1dc
  1. 23
      src/Volo.Abp.EntityFrameworkCore/Volo/Abp/Domain/Repositories/EntityFrameworkCore/EfCoreRepository.cs
  2. 8
      src/Volo.Abp/System/Collections/Generic/AbpDictionaryExtensions.cs
  3. 2
      src/Volo.Abp/System/Reflection/AbpMemberInfoExtensions.cs
  4. 1
      src/Volo.Abp/Volo.Abp.csproj
  5. 2
      src/Volo.Abp/Volo.Abp.csproj.DotSettings
  6. 2
      src/Volo.Abp/Volo/Abp/AbpKernelModule.cs
  7. 2
      src/Volo.Abp/Volo/Abp/Domain/Entities/Entity.cs
  8. 2
      src/Volo.Abp/Volo/Abp/Domain/Repositories/IQueryableRepository.cs
  9. 16
      src/Volo.Abp/Volo/Abp/Domain/Repositories/IRepository.cs
  10. 2
      src/Volo.Abp/Volo/Abp/Domain/Repositories/QueryableRepositoryBase.cs
  11. 22
      src/Volo.Abp/Volo/Abp/Domain/Repositories/RepositoryBase.cs
  12. 4
      src/Volo.Abp/Volo/Abp/Domain/Repositories/RepositoryExtensions.cs
  13. 4
      src/Volo.Abp/Volo/Abp/ObjectMapping/DefaultObjectMapper.cs
  14. 4
      src/Volo.Abp/Volo/Abp/Reflection/ReflectionHelper.cs
  15. 2
      src/Volo.Abp/Volo/Abp/Session/CurrentUser.cs
  16. 12
      src/Volo.Abp/Volo/Abp/Threading/CancellationTokenProviderExtensions.cs
  17. 9
      src/Volo.Abp/Volo/Abp/Threading/ICancellationTokenProvider.cs
  18. 16
      src/Volo.Abp/Volo/Abp/Threading/NullCancellationTokenProvider.cs
  19. 6
      src/Volo.Abp/Volo/Abp/Uow/ChildUnitOfWork.cs
  20. 2
      src/Volo.Abp/Volo/Abp/Uow/ISupportsSavingChanges.cs
  21. 6
      src/Volo.Abp/Volo/Abp/Uow/IUnitOfWork.cs
  22. 6
      src/Volo.Abp/Volo/Abp/Uow/UnitOfWork.cs

23
src/Volo.Abp.EntityFrameworkCore/Volo/Abp/Domain/Repositories/EntityFrameworkCore/EfCoreRepository.cs

@ -7,6 +7,7 @@ using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Volo.Abp.Domain.Entities; using Volo.Abp.Domain.Entities;
using Volo.Abp.EntityFrameworkCore; using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.Threading;
namespace Volo.Abp.Domain.Repositories.EntityFrameworkCore namespace Volo.Abp.Domain.Repositories.EntityFrameworkCore
{ {
@ -45,14 +46,14 @@ namespace Volo.Abp.Domain.Repositories.EntityFrameworkCore
return DbSet.AsQueryable(); return DbSet.AsQueryable();
} }
public override Task<List<TEntity>> GetListAsync(CancellationToken cancellationToken = new CancellationToken()) public override Task<List<TEntity>> GetListAsync(CancellationToken cancellationToken = default(CancellationToken))
{ {
return DbSet.ToListAsync(cancellationToken); return DbSet.ToListAsync(CancellationTokenProvider.FallbackToProvider(cancellationToken));
} }
public override async Task<TEntity> GetAsync(TPrimaryKey id, CancellationToken cancellationToken = default(CancellationToken)) public override async Task<TEntity> GetAsync(TPrimaryKey id, CancellationToken cancellationToken = default(CancellationToken))
{ {
var entity = await FindAsync(id, cancellationToken); var entity = await FindAsync(id, CancellationTokenProvider.FallbackToProvider(cancellationToken));
if (entity == null) if (entity == null)
{ {
@ -69,7 +70,7 @@ namespace Volo.Abp.Domain.Repositories.EntityFrameworkCore
public override Task<TEntity> FindAsync(TPrimaryKey id, CancellationToken cancellationToken = default(CancellationToken)) public override Task<TEntity> FindAsync(TPrimaryKey id, CancellationToken cancellationToken = default(CancellationToken))
{ {
return DbSet.FindAsync(new object[] { id }, cancellationToken); return DbSet.FindAsync(new object[] { id }, CancellationTokenProvider.FallbackToProvider(cancellationToken));
} }
public override TEntity Insert(TEntity entity, bool autoSave = false) public override TEntity Insert(TEntity entity, bool autoSave = false)
@ -90,7 +91,7 @@ namespace Volo.Abp.Domain.Repositories.EntityFrameworkCore
if (autoSave) if (autoSave)
{ {
await DbContext.SaveChangesAsync(cancellationToken); await DbContext.SaveChangesAsync(CancellationTokenProvider.FallbackToProvider(cancellationToken));
} }
return savedEntity; return savedEntity;
@ -109,7 +110,7 @@ namespace Volo.Abp.Domain.Repositories.EntityFrameworkCore
public override async Task DeleteAsync(Expression<Func<TEntity, bool>> predicate, CancellationToken cancellationToken = default(CancellationToken)) public override async Task DeleteAsync(Expression<Func<TEntity, bool>> predicate, CancellationToken cancellationToken = default(CancellationToken))
{ {
var entities = await GetQueryable().Where(predicate).ToListAsync(cancellationToken); var entities = await GetQueryable().Where(predicate).ToListAsync(CancellationTokenProvider.FallbackToProvider(cancellationToken));
foreach (var entity in entities) foreach (var entity in entities)
{ {
DbSet.Remove(entity); DbSet.Remove(entity);
@ -118,25 +119,25 @@ namespace Volo.Abp.Domain.Repositories.EntityFrameworkCore
public override Task<long> GetCountAsync(CancellationToken cancellationToken = default(CancellationToken)) public override Task<long> GetCountAsync(CancellationToken cancellationToken = default(CancellationToken))
{ {
return GetQueryable().LongCountAsync(cancellationToken); return GetQueryable().LongCountAsync(CancellationTokenProvider.FallbackToProvider(cancellationToken));
} }
public virtual Task EnsureCollectionLoadedAsync<TProperty>( public virtual Task EnsureCollectionLoadedAsync<TProperty>(
TEntity entity, TEntity entity,
Expression<Func<TEntity, IEnumerable<TProperty>>> propertyExpression, Expression<Func<TEntity, IEnumerable<TProperty>>> propertyExpression,
CancellationToken cancellationToken) CancellationToken cancellationToken = default(CancellationToken))
where TProperty : class where TProperty : class
{ {
return DbContext.Entry(entity).Collection(propertyExpression).LoadAsync(cancellationToken); return DbContext.Entry(entity).Collection(propertyExpression).LoadAsync(CancellationTokenProvider.FallbackToProvider(cancellationToken));
} }
public virtual Task EnsurePropertyLoadedAsync<TProperty>( public virtual Task EnsurePropertyLoadedAsync<TProperty>(
TEntity entity, TEntity entity,
Expression<Func<TEntity, TProperty>> propertyExpression, Expression<Func<TEntity, TProperty>> propertyExpression,
CancellationToken cancellationToken) CancellationToken cancellationToken = default(CancellationToken))
where TProperty : class where TProperty : class
{ {
return DbContext.Entry(entity).Reference(propertyExpression).LoadAsync(cancellationToken); return DbContext.Entry(entity).Reference(propertyExpression).LoadAsync(CancellationTokenProvider.FallbackToProvider(cancellationToken));
} }
} }
} }

8
src/Volo.Abp/System/Collections/Generic/AbpDictionaryExtensions.cs

@ -22,7 +22,7 @@ namespace System.Collections.Generic
return true; return true;
} }
value = default(T); value = default;
return false; return false;
} }
@ -37,7 +37,7 @@ namespace System.Collections.Generic
public static TValue GetOrDefault<TKey, TValue>(this Dictionary<TKey, TValue> dictionary, TKey key) public static TValue GetOrDefault<TKey, TValue>(this Dictionary<TKey, TValue> dictionary, TKey key)
{ {
TValue obj; TValue obj;
return dictionary.TryGetValue(key, out obj) ? obj : default(TValue); return dictionary.TryGetValue(key, out obj) ? obj : default;
} }
/// <summary> /// <summary>
@ -51,7 +51,7 @@ namespace System.Collections.Generic
public static TValue GetOrDefault<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, TKey key) public static TValue GetOrDefault<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, TKey key)
{ {
TValue obj; TValue obj;
return dictionary.TryGetValue(key, out obj) ? obj : default(TValue); return dictionary.TryGetValue(key, out obj) ? obj : default;
} }
/// <summary> /// <summary>
@ -65,7 +65,7 @@ namespace System.Collections.Generic
public static TValue GetOrDefault<TKey, TValue>(this IReadOnlyDictionary<TKey, TValue> dictionary, TKey key) public static TValue GetOrDefault<TKey, TValue>(this IReadOnlyDictionary<TKey, TValue> dictionary, TKey key)
{ {
TValue obj; TValue obj;
return dictionary.TryGetValue(key, out obj) ? obj : default(TValue); return dictionary.TryGetValue(key, out obj) ? obj : default;
} }
/// <summary> /// <summary>

2
src/Volo.Abp/System/Reflection/AbpMemberInfoExtensions.cs

@ -28,7 +28,7 @@ namespace System.Reflection
return (TAttribute)attrs[0]; return (TAttribute)attrs[0];
} }
return default(TAttribute); return default;
} }

1
src/Volo.Abp/Volo.Abp.csproj

@ -4,6 +4,7 @@
<PropertyGroup> <PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework> <TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>latest</LangVersion>
<AssemblyName>Volo.Abp</AssemblyName> <AssemblyName>Volo.Abp</AssemblyName>
<PackageId>Volo.Abp</PackageId> <PackageId>Volo.Abp</PackageId>
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback> <AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback>

2
src/Volo.Abp/Volo.Abp.csproj.DotSettings

@ -0,0 +1,2 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/CodeInspection/CSharpLanguageProject/LanguageLevel/@EntryValue">CSharp71</s:String></wpf:ResourceDictionary>

2
src/Volo.Abp/Volo/Abp/AbpKernelModule.cs

@ -5,6 +5,7 @@ using Volo.Abp.Localization;
using Volo.Abp.Modularity; using Volo.Abp.Modularity;
using Volo.Abp.ObjectMapping; using Volo.Abp.ObjectMapping;
using Volo.Abp.Reflection; using Volo.Abp.Reflection;
using Volo.Abp.Threading;
using Volo.Abp.Uow; using Volo.Abp.Uow;
using Volo.Abp.Validation; using Volo.Abp.Validation;
@ -40,6 +41,7 @@ namespace Volo.Abp
services.AddAssemblyOf<AbpKernelModule>(); services.AddAssemblyOf<AbpKernelModule>();
services.AddSingleton<ICancellationTokenProvider>(NullCancellationTokenProvider.Instance);
services.AddSingleton<IRequestedApiVersion>(NullRequestedApiVersion.Instance); services.AddSingleton<IRequestedApiVersion>(NullRequestedApiVersion.Instance);
services.AddSingleton(typeof(IDataFilter<>), typeof(DataFilter<>)); services.AddSingleton(typeof(IDataFilter<>), typeof(DataFilter<>));

2
src/Volo.Abp/Volo/Abp/Domain/Entities/Entity.cs

@ -26,7 +26,7 @@ namespace Volo.Abp.Domain.Entities
/// <inheritdoc/> /// <inheritdoc/>
public virtual bool IsTransient() public virtual bool IsTransient()
{ {
if (EqualityComparer<TPrimaryKey>.Default.Equals(Id, default(TPrimaryKey))) if (EqualityComparer<TPrimaryKey>.Default.Equals(Id, default))
{ {
return true; return true;
} }

2
src/Volo.Abp/Volo/Abp/Domain/Repositories/IQueryableRepository.cs

@ -34,6 +34,6 @@ namespace Volo.Abp.Domain.Repositories
/// </summary> /// </summary>
/// <param name="cancellationToken">A <see cref="T:System.Threading.CancellationToken" /> to observe while waiting for the task to complete.</param> /// <param name="cancellationToken">A <see cref="T:System.Threading.CancellationToken" /> to observe while waiting for the task to complete.</param>
/// <param name="predicate">A condition to filter entities</param> /// <param name="predicate">A condition to filter entities</param>
Task DeleteAsync([NotNull] Expression<Func<TEntity, bool>> predicate, CancellationToken cancellationToken = default(CancellationToken)); Task DeleteAsync([NotNull] Expression<Func<TEntity, bool>> predicate, CancellationToken cancellationToken = default);
} }
} }

16
src/Volo.Abp/Volo/Abp/Domain/Repositories/IRepository.cs

@ -33,7 +33,7 @@ namespace Volo.Abp.Domain.Repositories
/// </summary> /// </summary>
/// <param name="cancellationToken">A <see cref="T:System.Threading.CancellationToken" /> to observe while waiting for the task to complete.</param> /// <param name="cancellationToken">A <see cref="T:System.Threading.CancellationToken" /> to observe while waiting for the task to complete.</param>
/// <returns>List of entities</returns> /// <returns>List of entities</returns>
Task<List<TEntity>> GetListAsync(CancellationToken cancellationToken = default(CancellationToken)); Task<List<TEntity>> GetListAsync(CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Gets an entity with given primary key. /// Gets an entity with given primary key.
@ -52,7 +52,7 @@ namespace Volo.Abp.Domain.Repositories
/// <param name="cancellationToken">A <see cref="T:System.Threading.CancellationToken" /> to observe while waiting for the task to complete.</param> /// <param name="cancellationToken">A <see cref="T:System.Threading.CancellationToken" /> to observe while waiting for the task to complete.</param>
/// <returns>Entity</returns> /// <returns>Entity</returns>
[NotNull] [NotNull]
Task<TEntity> GetAsync(TPrimaryKey id, CancellationToken cancellationToken = default(CancellationToken)); Task<TEntity> GetAsync(TPrimaryKey id, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Gets an entity with given primary key or null if not found. /// Gets an entity with given primary key or null if not found.
@ -68,7 +68,7 @@ namespace Volo.Abp.Domain.Repositories
/// <param name="id">Primary key of the entity to get</param> /// <param name="id">Primary key of the entity to get</param>
/// <param name="cancellationToken">A <see cref="T:System.Threading.CancellationToken" /> to observe while waiting for the task to complete.</param> /// <param name="cancellationToken">A <see cref="T:System.Threading.CancellationToken" /> to observe while waiting for the task to complete.</param>
/// <returns>Entity or null</returns> /// <returns>Entity or null</returns>
Task<TEntity> FindAsync(TPrimaryKey id, CancellationToken cancellationToken = default(CancellationToken)); Task<TEntity> FindAsync(TPrimaryKey id, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Inserts a new entity. /// Inserts a new entity.
@ -91,7 +91,7 @@ namespace Volo.Abp.Domain.Repositories
/// <param name="cancellationToken">A <see cref="T:System.Threading.CancellationToken" /> to observe while waiting for the task to complete.</param> /// <param name="cancellationToken">A <see cref="T:System.Threading.CancellationToken" /> to observe while waiting for the task to complete.</param>
/// <param name="entity">Inserted entity</param> /// <param name="entity">Inserted entity</param>
[NotNull] [NotNull]
Task<TEntity> InsertAsync([NotNull] TEntity entity, bool autoSave = false, CancellationToken cancellationToken = default(CancellationToken)); Task<TEntity> InsertAsync([NotNull] TEntity entity, bool autoSave = false, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Updates an existing entity. /// Updates an existing entity.
@ -106,7 +106,7 @@ namespace Volo.Abp.Domain.Repositories
/// <param name="cancellationToken">A <see cref="T:System.Threading.CancellationToken" /> to observe while waiting for the task to complete.</param> /// <param name="cancellationToken">A <see cref="T:System.Threading.CancellationToken" /> to observe while waiting for the task to complete.</param>
/// <param name="entity">Entity</param> /// <param name="entity">Entity</param>
[NotNull] [NotNull]
Task<TEntity> UpdateAsync([NotNull] TEntity entity, CancellationToken cancellationToken = default(CancellationToken)); Task<TEntity> UpdateAsync([NotNull] TEntity entity, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Deletes an entity. /// Deletes an entity.
@ -119,7 +119,7 @@ namespace Volo.Abp.Domain.Repositories
/// </summary> /// </summary>
/// <param name="cancellationToken">A <see cref="T:System.Threading.CancellationToken" /> to observe while waiting for the task to complete.</param> /// <param name="cancellationToken">A <see cref="T:System.Threading.CancellationToken" /> to observe while waiting for the task to complete.</param>
/// <param name="entity">Entity to be deleted</param> /// <param name="entity">Entity to be deleted</param>
Task DeleteAsync([NotNull] TEntity entity, CancellationToken cancellationToken = default(CancellationToken)); Task DeleteAsync([NotNull] TEntity entity, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Deletes an entity by primary key. /// Deletes an entity by primary key.
@ -132,7 +132,7 @@ namespace Volo.Abp.Domain.Repositories
/// </summary> /// </summary>
/// <param name="cancellationToken">A <see cref="T:System.Threading.CancellationToken" /> to observe while waiting for the task to complete.</param> /// <param name="cancellationToken">A <see cref="T:System.Threading.CancellationToken" /> to observe while waiting for the task to complete.</param>
/// <param name="id">Primary key of the entity</param> /// <param name="id">Primary key of the entity</param>
Task DeleteAsync(TPrimaryKey id, CancellationToken cancellationToken = default(CancellationToken)); Task DeleteAsync(TPrimaryKey id, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Get list of all entities without any filtering. /// Get list of all entities without any filtering.
@ -145,6 +145,6 @@ namespace Volo.Abp.Domain.Repositories
/// </summary> /// </summary>
/// <param name="cancellationToken">A <see cref="T:System.Threading.CancellationToken" /> to observe while waiting for the task to complete.</param> /// <param name="cancellationToken">A <see cref="T:System.Threading.CancellationToken" /> to observe while waiting for the task to complete.</param>
/// <returns>List of entities</returns> /// <returns>List of entities</returns>
Task<long> GetCountAsync(CancellationToken cancellationToken = default(CancellationToken)); Task<long> GetCountAsync(CancellationToken cancellationToken = default);
} }
} }

2
src/Volo.Abp/Volo/Abp/Domain/Repositories/QueryableRepositoryBase.cs

@ -60,7 +60,7 @@ namespace Volo.Abp.Domain.Repositories
} }
} }
public virtual Task DeleteAsync(Expression<Func<TEntity, bool>> predicate, CancellationToken cancellationToken = default(CancellationToken)) public virtual Task DeleteAsync(Expression<Func<TEntity, bool>> predicate, CancellationToken cancellationToken = default)
{ {
Delete(predicate); Delete(predicate);
return Task.CompletedTask; return Task.CompletedTask;

22
src/Volo.Abp/Volo/Abp/Domain/Repositories/RepositoryBase.cs

@ -4,6 +4,7 @@ using System.Linq.Expressions;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp.Domain.Entities; using Volo.Abp.Domain.Entities;
using Volo.Abp.Threading;
namespace Volo.Abp.Domain.Repositories namespace Volo.Abp.Domain.Repositories
{ {
@ -16,6 +17,13 @@ namespace Volo.Abp.Domain.Repositories
public abstract class RepositoryBase<TEntity, TPrimaryKey> : IRepository<TEntity, TPrimaryKey> public abstract class RepositoryBase<TEntity, TPrimaryKey> : IRepository<TEntity, TPrimaryKey>
where TEntity : class, IEntity<TPrimaryKey> where TEntity : class, IEntity<TPrimaryKey>
{ {
public ICancellationTokenProvider CancellationTokenProvider { get; set; }
protected RepositoryBase()
{
CancellationTokenProvider = NullCancellationTokenProvider.Instance;
}
public abstract List<TEntity> GetList(); public abstract List<TEntity> GetList();
public virtual Task<List<TEntity>> GetListAsync(CancellationToken cancellationToken = new CancellationToken()) public virtual Task<List<TEntity>> GetListAsync(CancellationToken cancellationToken = new CancellationToken())
@ -35,35 +43,35 @@ namespace Volo.Abp.Domain.Repositories
return entity; return entity;
} }
public virtual Task<TEntity> GetAsync(TPrimaryKey id, CancellationToken cancellationToken = default(CancellationToken)) public virtual Task<TEntity> GetAsync(TPrimaryKey id, CancellationToken cancellationToken = default)
{ {
return Task.FromResult(Get(id)); return Task.FromResult(Get(id));
} }
public abstract TEntity Find(TPrimaryKey id); public abstract TEntity Find(TPrimaryKey id);
public virtual Task<TEntity> FindAsync(TPrimaryKey id, CancellationToken cancellationToken = default(CancellationToken)) public virtual Task<TEntity> FindAsync(TPrimaryKey id, CancellationToken cancellationToken = default)
{ {
return Task.FromResult(Find(id)); return Task.FromResult(Find(id));
} }
public abstract TEntity Insert(TEntity entity, bool autoSave = false); public abstract TEntity Insert(TEntity entity, bool autoSave = false);
public virtual Task<TEntity> InsertAsync(TEntity entity, bool autoSave = false, CancellationToken cancellationToken = default(CancellationToken)) public virtual Task<TEntity> InsertAsync(TEntity entity, bool autoSave = false, CancellationToken cancellationToken = default)
{ {
return Task.FromResult(Insert(entity, autoSave)); return Task.FromResult(Insert(entity, autoSave));
} }
public abstract TEntity Update(TEntity entity); public abstract TEntity Update(TEntity entity);
public virtual Task<TEntity> UpdateAsync(TEntity entity, CancellationToken cancellationToken = default(CancellationToken)) public virtual Task<TEntity> UpdateAsync(TEntity entity, CancellationToken cancellationToken = default)
{ {
return Task.FromResult(Update(entity)); return Task.FromResult(Update(entity));
} }
public abstract void Delete(TEntity entity); public abstract void Delete(TEntity entity);
public virtual Task DeleteAsync(TEntity entity, CancellationToken cancellationToken = default(CancellationToken)) public virtual Task DeleteAsync(TEntity entity, CancellationToken cancellationToken = default)
{ {
Delete(entity); Delete(entity);
return Task.CompletedTask; return Task.CompletedTask;
@ -80,7 +88,7 @@ namespace Volo.Abp.Domain.Repositories
Delete(entity); Delete(entity);
} }
public virtual Task DeleteAsync(TPrimaryKey id, CancellationToken cancellationToken = default(CancellationToken)) public virtual Task DeleteAsync(TPrimaryKey id, CancellationToken cancellationToken = default)
{ {
Delete(id); Delete(id);
return Task.CompletedTask; return Task.CompletedTask;
@ -88,7 +96,7 @@ namespace Volo.Abp.Domain.Repositories
public abstract long GetCount(); public abstract long GetCount();
public virtual Task<long> GetCountAsync(CancellationToken cancellationToken = default(CancellationToken)) public virtual Task<long> GetCountAsync(CancellationToken cancellationToken = default)
{ {
return Task.FromResult(GetCount()); return Task.FromResult(GetCount());
} }

4
src/Volo.Abp/Volo/Abp/Domain/Repositories/RepositoryExtensions.cs

@ -15,7 +15,7 @@ namespace Volo.Abp.Domain.Repositories
this IRepository<TEntity, TPrimaryKey> repository, this IRepository<TEntity, TPrimaryKey> repository,
TEntity entity, TEntity entity,
Expression<Func<TEntity, IEnumerable<TProperty>>> propertyExpression, Expression<Func<TEntity, IEnumerable<TProperty>>> propertyExpression,
CancellationToken cancellationToken = default(CancellationToken) CancellationToken cancellationToken = default
) )
where TEntity : class, IEntity<TPrimaryKey> where TEntity : class, IEntity<TPrimaryKey>
where TProperty : class where TProperty : class
@ -42,7 +42,7 @@ namespace Volo.Abp.Domain.Repositories
this IRepository<TEntity, TPrimaryKey> repository, this IRepository<TEntity, TPrimaryKey> repository,
TEntity entity, TEntity entity,
Expression<Func<TEntity, TProperty>> propertyExpression, Expression<Func<TEntity, TProperty>> propertyExpression,
CancellationToken cancellationToken = default(CancellationToken) CancellationToken cancellationToken = default
) )
where TEntity : class, IEntity<TPrimaryKey> where TEntity : class, IEntity<TPrimaryKey>
where TProperty : class where TProperty : class

4
src/Volo.Abp/Volo/Abp/ObjectMapping/DefaultObjectMapper.cs

@ -19,7 +19,7 @@ namespace Volo.Abp.ObjectMapping
{ {
if (source == null) if (source == null)
{ {
return default(TDestination); return default;
} }
//Check if a specific mapper is registered //Check if a specific mapper is registered
@ -39,7 +39,7 @@ namespace Volo.Abp.ObjectMapping
{ {
if (source == null) if (source == null)
{ {
return default(TDestination); return default;
} }
//Check if a specific mapper is registered //Check if a specific mapper is registered

4
src/Volo.Abp/Volo/Abp/Reflection/ReflectionHelper.cs

@ -80,7 +80,7 @@ namespace Volo.Abp.Reflection
/// <param name="memberInfo">MemberInfo</param> /// <param name="memberInfo">MemberInfo</param>
/// <param name="defaultValue">Default value (null as default)</param> /// <param name="defaultValue">Default value (null as default)</param>
/// <param name="inherit">Inherit attribute from base classes</param> /// <param name="inherit">Inherit attribute from base classes</param>
public static TAttribute GetSingleAttributeOrDefault<TAttribute>(MemberInfo memberInfo, TAttribute defaultValue = default(TAttribute), bool inherit = true) public static TAttribute GetSingleAttributeOrDefault<TAttribute>(MemberInfo memberInfo, TAttribute defaultValue = default, bool inherit = true)
where TAttribute : Attribute where TAttribute : Attribute
{ {
//Get attribute on the member //Get attribute on the member
@ -100,7 +100,7 @@ namespace Volo.Abp.Reflection
/// <param name="memberInfo">MemberInfo</param> /// <param name="memberInfo">MemberInfo</param>
/// <param name="defaultValue">Default value (null as default)</param> /// <param name="defaultValue">Default value (null as default)</param>
/// <param name="inherit">Inherit attribute from base classes</param> /// <param name="inherit">Inherit attribute from base classes</param>
public static TAttribute GetSingleAttributeOfMemberOrDeclaringTypeOrDefault<TAttribute>(MemberInfo memberInfo, TAttribute defaultValue = default(TAttribute), bool inherit = true) public static TAttribute GetSingleAttributeOfMemberOrDeclaringTypeOrDefault<TAttribute>(MemberInfo memberInfo, TAttribute defaultValue = default, bool inherit = true)
where TAttribute : class where TAttribute : class
{ {
return memberInfo.GetCustomAttributes(true).OfType<TAttribute>().FirstOrDefault() return memberInfo.GetCustomAttributes(true).OfType<TAttribute>().FirstOrDefault()

2
src/Volo.Abp/Volo/Abp/Session/CurrentUser.cs

@ -46,7 +46,7 @@ namespace Volo.Abp.Session
var value = FindClaimValue(claimType); var value = FindClaimValue(claimType);
if (value == null) if (value == null)
{ {
return default(T); return default;
} }
return value.To<T>(); return value.To<T>();

12
src/Volo.Abp/Volo/Abp/Threading/CancellationTokenProviderExtensions.cs

@ -0,0 +1,12 @@
using System.Threading;
namespace Volo.Abp.Threading
{
public static class CancellationTokenProviderExtensions
{
public static CancellationToken FallbackToProvider(this ICancellationTokenProvider provider, CancellationToken prefferedValue)
{
return prefferedValue == default ? provider.Token : prefferedValue;
}
}
}

9
src/Volo.Abp/Volo/Abp/Threading/ICancellationTokenProvider.cs

@ -0,0 +1,9 @@
using System.Threading;
namespace Volo.Abp.Threading
{
public interface ICancellationTokenProvider
{
CancellationToken Token { get; }
}
}

16
src/Volo.Abp/Volo/Abp/Threading/NullCancellationTokenProvider.cs

@ -0,0 +1,16 @@
using System.Threading;
namespace Volo.Abp.Threading
{
public class NullCancellationTokenProvider : ICancellationTokenProvider
{
public static NullCancellationTokenProvider Instance { get; } = new NullCancellationTokenProvider();
public CancellationToken Token { get; } = default;
private NullCancellationTokenProvider()
{
}
}
}

6
src/Volo.Abp/Volo/Abp/Uow/ChildUnitOfWork.cs

@ -56,7 +56,7 @@ namespace Volo.Abp.Uow
_parent.SaveChanges(); _parent.SaveChanges();
} }
public Task SaveChangesAsync(CancellationToken cancellationToken = default(CancellationToken)) public Task SaveChangesAsync(CancellationToken cancellationToken = default)
{ {
return _parent.SaveChangesAsync(cancellationToken); return _parent.SaveChangesAsync(cancellationToken);
} }
@ -66,7 +66,7 @@ namespace Volo.Abp.Uow
} }
public Task CompleteAsync(CancellationToken cancellationToken = default(CancellationToken)) public Task CompleteAsync(CancellationToken cancellationToken = default)
{ {
return Task.CompletedTask; return Task.CompletedTask;
} }
@ -76,7 +76,7 @@ namespace Volo.Abp.Uow
_parent.Rollback(); _parent.Rollback();
} }
public Task RollbackAsync(CancellationToken cancellationToken = default(CancellationToken)) public Task RollbackAsync(CancellationToken cancellationToken = default)
{ {
return _parent.RollbackAsync(cancellationToken); return _parent.RollbackAsync(cancellationToken);
} }

2
src/Volo.Abp/Volo/Abp/Uow/ISupportsSavingChanges.cs

@ -7,6 +7,6 @@ namespace Volo.Abp.Uow
{ {
void SaveChanges(); void SaveChanges();
Task SaveChangesAsync(CancellationToken cancellationToken = default(CancellationToken)); Task SaveChangesAsync(CancellationToken cancellationToken = default);
} }
} }

6
src/Volo.Abp/Volo/Abp/Uow/IUnitOfWork.cs

@ -31,14 +31,14 @@ namespace Volo.Abp.Uow
void SaveChanges(); void SaveChanges();
Task SaveChangesAsync(CancellationToken cancellationToken = default(CancellationToken)); Task SaveChangesAsync(CancellationToken cancellationToken = default);
void Complete(); void Complete();
Task CompleteAsync(CancellationToken cancellationToken = default(CancellationToken)); Task CompleteAsync(CancellationToken cancellationToken = default);
void Rollback(); void Rollback();
Task RollbackAsync(CancellationToken cancellationToken = default(CancellationToken)); Task RollbackAsync(CancellationToken cancellationToken = default);
} }
} }

6
src/Volo.Abp/Volo/Abp/Uow/UnitOfWork.cs

@ -77,7 +77,7 @@ namespace Volo.Abp.Uow
} }
} }
public virtual async Task SaveChangesAsync(CancellationToken cancellationToken = default(CancellationToken)) public virtual async Task SaveChangesAsync(CancellationToken cancellationToken = default)
{ {
foreach (var databaseApi in _databaseApis.Values) foreach (var databaseApi in _databaseApis.Values)
{ {
@ -110,7 +110,7 @@ namespace Volo.Abp.Uow
} }
} }
public virtual async Task CompleteAsync(CancellationToken cancellationToken = default(CancellationToken)) public virtual async Task CompleteAsync(CancellationToken cancellationToken = default)
{ {
if (_isRolledback) if (_isRolledback)
{ {
@ -144,7 +144,7 @@ namespace Volo.Abp.Uow
RollbackAll(); RollbackAll();
} }
public virtual async Task RollbackAsync(CancellationToken cancellationToken = default(CancellationToken)) public virtual async Task RollbackAsync(CancellationToken cancellationToken = default)
{ {
if (_isRolledback) if (_isRolledback)
{ {

Loading…
Cancel
Save