using System; using System.Collections.Generic; using System.Linq; using System.Transactions; namespace Abp.Domain.Uow { /// /// Unit of work options. /// public class UnitOfWorkOptions { /// /// Scope option. /// public TransactionScopeOption? Scope { get; set; } /// /// Is this UOW transactional? /// Uses default value if not supplied. /// public bool? IsTransactional { get; set; } /// /// Timeout of UOW As milliseconds. /// Uses default value if not supplied. /// public TimeSpan? Timeout { get; set; } /// /// If this UOW is transactional, this option indicated the isolation level of the transaction. /// Uses default value if not supplied. /// public IsolationLevel? IsolationLevel { get; set; } /// /// This option should be set to /// if unit of work is used in an async scope. /// public TransactionScopeAsyncFlowOption? AsyncFlowOption { get; set; } /// /// Can be used to enable/disable some filters. /// public List FilterOverrides { get; } /// /// Creates a new object. /// public UnitOfWorkOptions() { FilterOverrides = new List(); } 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 filterOverrides) { foreach (var filterOverride in filterOverrides) { if (FilterOverrides.Any(fo => fo.FilterName == filterOverride.FilterName)) { continue; } FilterOverrides.Add(filterOverride); } } } }