• /r/csharp
  • I’m trying to pass my Autofac’s container to a factory but it keeps returning null.

    Program.cs: var builder = new ContainerBuilder(); builder.RegisterType<MenuFactory>() .As<IFactory<Menu, Type>>() .WithParameter(new TypedParameter(typeof(IContainer), _container)) .SingleInstance(); _container = builder.Build(); MenuFactory.cs: public MenuFactory(IContainer container) { _container = container; } Why isn’t this working? I’ve also tried this: builder.RegisterType<MenuFactory>() .As<IFactory<Menu, Type>>() .WithParameter(“container”, _container) .SingleInstance(); submitted by /u/Asusralis [link] [comments]

  • /r/csharp
  • Java to C# Application Structure

    So I’m new to C#, if my username didn’t make that obvious. However, I’ve spent the last several years writing Java applications. Mostly internal business applications that made heavy use of Swing for the UI. Had some questions, and was hoping for general sanity tips, feedback, etc. How do you guys usually structure the application? […]