| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Transactions;
- namespace Abp.Domain.Uow
- {
- /// <summary>
- /// Unit of work options.
- /// </summary>
- public class UnitOfWorkOptions
- {
- /// <summary>
- /// Scope option.
- /// </summary>
- public TransactionScopeOption? Scope { get; set; }
- /// <summary>
- /// Is this UOW transactional?
- /// Uses default value if not supplied.
- /// </summary>
- public bool? IsTransactional { get; set; }
- /// <summary>
- /// Timeout of UOW As milliseconds.
- /// Uses default value if not supplied.
- /// </summary>
- public TimeSpan? Timeout { get; set; }
- /// <summary>
- /// If this UOW is transactional, this option indicated the isolation level of the transaction.
- /// Uses default value if not supplied.
- /// </summary>
- public IsolationLevel? IsolationLevel { get; set; }
- /// <summary>
- /// This option should be set to <see cref="TransactionScopeAsyncFlowOption.Enabled"/>
- /// if unit of work is used in an async scope.
- /// </summary>
- public TransactionScopeAsyncFlowOption? AsyncFlowOption { get; set; }
- /// <summary>
- /// Can be used to enable/disable some filters.
- /// </summary>
- public List<DataFilterConfiguration> FilterOverrides { get; }
- /// <summary>
- /// Creates a new <see cref="UnitOfWorkOptions"/> object.
- /// </summary>
- public UnitOfWorkOptions()
- {
- FilterOverrides = new List<DataFilterConfiguration>();
- }
- internal void FillDefaultsForNonProvidedOptions(IUnitOfWorkDefaultOptions defaultOptions)
- {
- //TODO: Do not change options object..?
- if (!IsTransactional.HasValue)
- {
- IsTransactional = defaultOptions.IsTransactional;
- }
- if (!Scope.HasValue)
- {
- Scope = defaultOptions.Scope;
- }
- if (!Timeout.HasValue && defaultOptions.Timeout.HasValue)
- {
- Timeout = defaultOptions.Timeout.Value;
- }
- if (!IsolationLevel.HasValue && defaultOptions.IsolationLevel.HasValue)
- {
- IsolationLevel = defaultOptions.IsolationLevel.Value;
- }
- }
- internal void FillOuterUowFiltersForNonProvidedOptions(List<DataFilterConfiguration> filterOverrides)
- {
- foreach (var filterOverride in filterOverrides)
- {
- if (FilterOverrides.Any(fo => fo.FilterName == filterOverride.FilterName))
- {
- continue;
- }
- FilterOverrides.Add(filterOverride);
- }
- }
- }
- }
|