Browse Source

Removed IBasicUnitOfWork

pull/112/head
Halil İbrahim Kalkan 9 years ago
parent
commit
1a6778b4c6
  1. BIN
      src/AbpDesk/Web_PlugIns/AbpDesk.MongoBlog.dll
  2. 37
      src/Volo.Abp/Volo/Abp/Uow/ChildUnitOfWork.cs
  3. 26
      src/Volo.Abp/Volo/Abp/Uow/IBasicUnitOfWork.cs
  4. 29
      src/Volo.Abp/Volo/Abp/Uow/IUnitOfWork.cs
  5. 4
      src/Volo.Abp/Volo/Abp/Uow/IUnitOfWorkManager.cs
  6. 10
      src/Volo.Abp/Volo/Abp/Uow/UnitOfWork.cs
  7. 6
      src/Volo.Abp/Volo/Abp/Uow/UnitOfWorkFailedEventArgs.cs
  8. 9
      src/Volo.Abp/Volo/Abp/Uow/UnitOfWorkManager.cs
  9. 2
      src/Volo.Abp/Volo/Abp/Uow/UnitOfWorkManagerExtensions.cs

BIN
src/AbpDesk/Web_PlugIns/AbpDesk.MongoBlog.dll

Binary file not shown.

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

@ -13,27 +13,9 @@ namespace Volo.Abp.Uow
public IUnitOfWork Outer => _parent.Outer;
public bool IsReserved
{
get => _parent.IsReserved;
set => _parent.IsReserved = value;
}
public string ReservationName
{
get => _parent.ReservationName;
set => _parent.ReservationName = value;
}
public void SetOuter(IUnitOfWork outer)
{
_parent.SetOuter(outer);
}
public bool IsReserved => _parent.IsReserved;
public void Initialize(UnitOfWorkOptions options)
{
_parent.Initialize(options);
}
public string ReservationName => _parent.ReservationName;
public event EventHandler Completed;
public event EventHandler<UnitOfWorkFailedEventArgs> Failed;
@ -54,6 +36,21 @@ namespace Volo.Abp.Uow
_parent.Disposed += (sender, args) => { Disposed.InvokeSafely(sender, args); };
}
public void SetOuter(IUnitOfWork outer)
{
_parent.SetOuter(outer);
}
public void Initialize(UnitOfWorkOptions options)
{
_parent.Initialize(options);
}
public void Reserve(string reservationName)
{
_parent.Reserve(reservationName);
}
public void SaveChanges()
{
_parent.SaveChanges();

26
src/Volo.Abp/Volo/Abp/Uow/IBasicUnitOfWork.cs

@ -1,26 +0,0 @@
using System;
using System.Threading;
using System.Threading.Tasks;
namespace Volo.Abp.Uow
{
//TODO: Find a better naming :(
public interface IBasicUnitOfWork : IDisposable
{
Guid Id { get; }
event EventHandler Completed;
event EventHandler<UnitOfWorkFailedEventArgs> Failed;
event EventHandler Disposed;
void SaveChanges();
Task SaveChangesAsync(CancellationToken cancellationToken = default(CancellationToken));
void Complete();
Task CompleteAsync(CancellationToken cancellationToken = default(CancellationToken));
}
}

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

@ -1,19 +1,40 @@
using JetBrains.Annotations;
using System;
using System.Threading;
using System.Threading.Tasks;
using JetBrains.Annotations;
namespace Volo.Abp.Uow
{
public interface IUnitOfWork : IBasicUnitOfWork, IDatabaseApiContainer, ITransactionApiContainer
public interface IUnitOfWork : IDatabaseApiContainer, ITransactionApiContainer, IDisposable
{
Guid Id { get; }
event EventHandler Completed;
event EventHandler<UnitOfWorkFailedEventArgs> Failed;
event EventHandler Disposed;
IUnitOfWorkOptions Options { get; }
IUnitOfWork Outer { get; }
bool IsReserved { get; set; }
bool IsReserved { get; }
string ReservationName { get; set; }
string ReservationName { get; }
void SetOuter([CanBeNull] IUnitOfWork outer);
void Initialize([NotNull] UnitOfWorkOptions options);
void Reserve([NotNull] string reservationName);
void SaveChanges();
Task SaveChangesAsync(CancellationToken cancellationToken = default(CancellationToken));
void Complete();
Task CompleteAsync(CancellationToken cancellationToken = default(CancellationToken));
}
}

4
src/Volo.Abp/Volo/Abp/Uow/IUnitOfWorkManager.cs

@ -8,10 +8,10 @@ namespace Volo.Abp.Uow
IUnitOfWork Current { get; }
[NotNull]
IBasicUnitOfWork Begin([NotNull] UnitOfWorkOptions options, bool requiresNew = false);
IUnitOfWork Begin([NotNull] UnitOfWorkOptions options, bool requiresNew = false);
[NotNull]
IBasicUnitOfWork Reserve([NotNull] string reservationName, bool requiresNew = false);
IUnitOfWork Reserve([NotNull] string reservationName, bool requiresNew = false);
void BeginReserved([NotNull] string reservationName, [NotNull] UnitOfWorkOptions options);

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

@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using JetBrains.Annotations;
using Microsoft.Extensions.Options;
using Volo.Abp.DependencyInjection;
@ -52,6 +53,15 @@ namespace Volo.Abp.Uow
}
Options = _defaultOptions.Normalize(options.Clone());
IsReserved = false;
}
public void Reserve(string reservationName)
{
Check.NotNull(reservationName, nameof(reservationName));
ReservationName = reservationName;
IsReserved = true;
}
public void SetOuter(IUnitOfWork outer)

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

@ -9,12 +9,12 @@ namespace Volo.Abp.Uow
public class UnitOfWorkFailedEventArgs : EventArgs
{
/// <summary>
/// Exception that caused failure. This is set only if an error occured during <see cref="IBasicUnitOfWork.Complete"/>.
/// Can be null if there is no exception, but <see cref="IBasicUnitOfWork.Complete"/> is not called.
/// Exception that caused failure. This is set only if an error occured during <see cref="IUnitOfWork.Complete"/>.
/// Can be null if there is no exception, but <see cref="IUnitOfWork.Complete"/> is not called.
/// Can be null if another exception occurred during the UOW.
/// </summary>
[CanBeNull]
public Exception Exception { get; private set; }
public Exception Exception { get; }
/// <summary>
/// Creates a new <see cref="UnitOfWorkFailedEventArgs"/> object.

9
src/Volo.Abp/Volo/Abp/Uow/UnitOfWorkManager.cs

@ -19,7 +19,7 @@ namespace Volo.Abp.Uow
_ambientUnitOfWork = ambientUnitOfWork;
}
public IBasicUnitOfWork Begin(UnitOfWorkOptions options, bool requiresNew = false)
public IUnitOfWork Begin(UnitOfWorkOptions options, bool requiresNew = false)
{
Check.NotNull(options, nameof(options));
@ -34,7 +34,7 @@ namespace Volo.Abp.Uow
return unitOfWork;
}
public IBasicUnitOfWork Reserve(string reservationName, bool requiresNew = false)
public IUnitOfWork Reserve(string reservationName, bool requiresNew = false)
{
Check.NotNull(reservationName, nameof(reservationName));
@ -46,9 +46,7 @@ namespace Volo.Abp.Uow
}
var unitOfWork = CreateNewUnitOfWork();
unitOfWork.IsReserved = true;
unitOfWork.ReservationName = reservationName;
unitOfWork.Reserve(reservationName);
return unitOfWork;
}
@ -78,7 +76,6 @@ namespace Volo.Abp.Uow
return false;
}
uow.IsReserved = false;
uow.Initialize(options);
return true;

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

@ -5,7 +5,7 @@ namespace Volo.Abp.Uow
public static class UnitOfWorkManagerExtensions
{
[NotNull]
public static IBasicUnitOfWork Begin([NotNull] this IUnitOfWorkManager unitOfWorkManager, bool requiresNew = false)
public static IUnitOfWork Begin([NotNull] this IUnitOfWorkManager unitOfWorkManager, bool requiresNew = false)
{
Check.NotNull(unitOfWorkManager, nameof(unitOfWorkManager));

Loading…
Cancel
Save