unity-container

How to Inject dependencies in a Unity IoC container for SignalR hub?

折月煮酒 提交于 2021-01-27 14:41:55
问题 I have an application that is written with c# on the top of the ASP.NET MVC 5 Framework. I implemented Unity.Mvc into my project. Now, I am trying to inject dependencies objects into my SignalR Hub. I created a class called UnityHubActivator My class looks like this public class UnityHubActivator : IHubActivator { private readonly IUnityContainer _container; public UnityHubActivator(IUnityContainer container) { _container = container; } public IHub Create(HubDescriptor descriptor) { return

ASP.NET - Unity - Read configuration section from external configuration file

此生再无相见时 提交于 2021-01-27 07:08:35
问题 I want to integrate Unity in my app and I want it to use an external config file The Unity initialization code is var fileMap = new ExeConfigurationFileMap { ExeConfigFilename = "unity.config" }; System.Configuration.Configuration configuration = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None); // *** problem starts here *** var unitySection = (UnityConfigurationSection)configuration.GetSection("unity"); var container = new UnityContainer()

Unable to consolidate NuGet package transitive dependency versions in two NET Standard projects

一曲冷凌霜 提交于 2020-12-03 07:50:30
问题 Adding EF Core to a NET Standard project introduces transitive dependency versions incompatible with NuGet packages in other projects I have a solution with multiple .NET Standard 2.0 projects. One Project A uses the Google.Protobuf (3.11.2) NuGet package, that depends on System.Memory (4.5.3) System.Buffers (4.4.0) System.Numerics.Vectors (4.4.0) System.Runtime.CompilerServices.Unsafe (4.5.2) A few other projects also depend on System.Memory and all use the same dependency versions . Another

Unable to consolidate NuGet package transitive dependency versions in two NET Standard projects

血红的双手。 提交于 2020-12-03 07:49:42
问题 Adding EF Core to a NET Standard project introduces transitive dependency versions incompatible with NuGet packages in other projects I have a solution with multiple .NET Standard 2.0 projects. One Project A uses the Google.Protobuf (3.11.2) NuGet package, that depends on System.Memory (4.5.3) System.Buffers (4.4.0) System.Numerics.Vectors (4.4.0) System.Runtime.CompilerServices.Unsafe (4.5.2) A few other projects also depend on System.Memory and all use the same dependency versions . Another

PerRequestLifetimeManager and Task.Factory.StartNew - Dependency Injection with Unity

痞子三分冷 提交于 2020-07-18 07:11:40
问题 How to manage new tasks with PerRequestLifeTimeManager? Should I create another container inside a new task?(I wouldn't like to change PerRequestLifeTimeManager to PerResolveLifetimeManager/HierarchicalLifetimeManager) [HttpPost] public ActionResult UploadFile(FileUploadViewModel viewModel) { var cts = new CancellationTokenSource(); CancellationToken cancellationToken = cts.Token; Task.Factory.StartNew(() => { // _fileService = DependencyResolver.Current.GetService<IFileService>();