コード例 #1
0
 /// <inheritdoc />
 public virtual TService Create <TService>(IDomainContext domainContext, IUnitOfWorkContextFactory uowContextFactory) where TService : IDomainService
 {
     if (ServiceFactories.TryGetValue(typeof(TService), out var factory) == false)
     {
         throw new ArgumentException($"Type {typeof(TService)} is not registered for this provider", nameof(TService));
     }
     return((TService)factory.Create(domainContext, uowContextFactory));
 }
コード例 #2
0
 /// <summary>
 /// Get another service running in a nested unit of work context
 /// </summary>
 protected TService UseService <TService>(IUnitOfWorkContextFactory uowContextFactory) where TService : class, IDomainService
 {
     return(DomainContext.UseService <TService>(uowContextFactory));
 }
コード例 #3
0
 /// <summary>
 /// Creates a new instance of <see cref="DomainServiceBase"/>
 /// </summary>
 protected DomainServiceBase(IDomainContext domainContext, IUnitOfWorkContextFactory uowContextFactory)
 {
     DomainContext     = domainContext;
     UowContextFactory = uowContextFactory;
 }
コード例 #4
0
        public void InitializeFromRevisionHistoryResource(IUnitOfWorkContextFactory unitOfWorkContextFactory, Type revisionHistoryResourceAssemblyType, string revisionHistoryResourceName)
        {
            DatabaseHistory history;

            if ((object)unitOfWorkContextFactory == null)
                throw new ArgumentNullException("unitOfWorkContextFactory");

            if ((object)revisionHistoryResourceAssemblyType == null)
                throw new ArgumentNullException("revisionHistoryResourceAssemblyType");

            if ((object)revisionHistoryResourceName == null)
                throw new ArgumentNullException("revisionHistoryResourceName");

            if (DataType.IsNullOrWhiteSpace(revisionHistoryResourceName))
                throw new ArgumentOutOfRangeException("revisionHistoryResourceName");

            if (this.UseDatabaseFile)
            {
                if (!DataType.IsNullOrWhiteSpace(this.DatabaseFilePath))
                {
                    if (this.KillDatabaseFile)
                    {
                        if (File.Exists(this.DatabaseFilePath))
                            File.Delete(this.DatabaseFilePath);
                    }

                    this.EnsureDatabaseFile();
                }

                if (!Cerealization.TryGetFromAssemblyResource<DatabaseHistory>(revisionHistoryResourceAssemblyType, revisionHistoryResourceName, out history))
                    throw new InvalidOperationException(string.Format("Unable to deserialize instance of '{0}' from the manifest resource name '{1}' in the assembly '{2}'.", typeof(DatabaseHistory).FullName, revisionHistoryResourceName, revisionHistoryResourceAssemblyType.Assembly.FullName));

                using (IUnitOfWorkContext unitOfWorkContext = unitOfWorkContextFactory.GetUnitOfWorkContext())
                {
                    history.PerformSchemaUpgrade(unitOfWorkContext);

                    unitOfWorkContext.Complete();
                }
            }
        }
コード例 #5
0
 /// <inheritdoc />
 public IDomainService Create(IDomainContext domainContext, IUnitOfWorkContextFactory uowContextFactory)
 {
     return(CreateDomainServiceFunc.Invoke(domainContext, uowContextFactory));
 }
コード例 #6
0
 /// <inheritdoc />
 public virtual TService UseService <TService>(IUnitOfWorkContextFactory contextFactory) where TService : class, IDomainService
 {
     return(DomainServiceProvider.Create <TService>(this, contextFactory));
 }