autofac

    0热度

    1回答

    我对Autofac非常陌生,无法理解注册的语法。我有以下calsses /接口: //Interface public interface ISender { void Send(); } //implementations public class Post : ISender { public void Send() { //Post

    0热度

    1回答

    我在我的项目中使用Autofac,并且大部分工作正常。前一段时间,我需要得到获取当前用户,被告知要做到这一点的最好办法是创建一个包装类是这样的: public class PrincipalProvider : IPrincipalProvider { public IPrincipal User => HttpContext.Current?.User; } 这已经通过我的应用

    0热度

    1回答

    我正在构建OWIN自托管Web API 2应用程序,并且使用通用存储库模式并使用Autofac进行依赖项注入。 我的通用存储库类; public abstract class Repository<T> : IRepository<T> where T : BaseEntity { private DbContext context_; private Identity _c

    2热度

    3回答

    在我的应用程序中,我需要与两个数据库进行交互。我有两个域类位于两个不同的数据库中。我也有一个通用的存储库模式,它的构造函数接受一个UoW。我正在寻找一种方法来基于Domain类注入适当的UoW。 我不想为第二个数据库编写第二个通用存储库。。有没有简洁的解决方案? public interface IEntity { int Id { get; set; } } 位于数据库A pu

    0热度

    1回答

    我有一个ASP.NET Core项目。我想动态地解决其他依赖内部的“每个请求一个实例”依赖关系。 我已经注册使用Autofac作为我的启动类的InstancePerLifetimeScope依赖的相关性: public IServiceProvider ConfigureServices(IServiceCollection services) { var builder = new

    0热度

    1回答

    我在网上看到类似的问题,但我的情况是,在本地我的WebAPi应用程序工作正常,但在Azure失败,它抱怨找不到类型PositionServer.Repository.PositionRepository,PositionServer.Repository。它可能需要组装资格,例如“MyType的,MyAssembly程序” 下面是autofac.json { "components":

    0热度

    1回答

    我有以下几点: containerBuilder.RegisterType<CustomContext>() .As<CustomContext>() .InstancePerLifetimeScope(); containerBuilder.RegisterType<CustomContext>() .As<BaseContext>()

    3热度

    1回答

    我的目标是实现以下内容。我正在尝试使用MySQL,.NET Core,Autofac,EF Core ...来使用(通用)存储库模式来设置新的解决方案。 Ultimately I'll be jumping onto a project with an existing db, thus my aim is to somehow make use of (t4) templates & EF to

    -1热度

    1回答

    问题是相当基本的,我刚开始使用Autofac,遇到Autofac无法正常工作的问题,因为我预计它可以正常工作。因此,鉴于“这是它的工作方式”,我想了解这种行为背后的逻辑。 这是非常基本的代码: public interface X { } internal class A : X { } class Program { static void Main(string[] arg

    1热度

    1回答

    我有一个类hirerachy,看起来像这样: public class Foo : IFoo { private readonly IBar _bar; public Foo(IBar bar) => _bar = bar; } public class Bar : IBar { private readonly Func<IFoo> _foo