示例#1
0
 /// <summary>
 /// Creates IlocatorConfigure modules via Activator.CreateIntance
 /// </summary>
 /// <param name="filteredModules"></param>
 /// <param name="config"></param>
 /// <returns></returns>
 IEnumerable <ILocatorConfigure> ILocatorRegistryWithResolveConfigureModules.ResolveConfigureModules(IEnumerable <IDependencyNode> filteredModules, IStartupConfiguration config)
 {
     if (_registrations.TryGetValue(typeof(ILocatorConfigure), out List <ContainerRegistration> locatorConfTypes))
     {
         foreach (var module in locatorConfTypes)
         {
             if (module.ServiceInstance is object)
             {
                 yield return((ILocatorConfigure)module.ServiceInstance);
             }
             else
             {
                 yield return((ILocatorConfigure)Activator.CreateInstance(module.ServiceImplementation));
             }
         }
     }
 }
示例#2
0
        // hack: GetAllInstances Requires additional sorting as LightInject returns from ConcurrentDictionary
        // required for LightInject, which causes many other considerations as constructor injection isn't supported by this, affects DotNetStarter.Web injection

        /* IEnumerable will need another sorting mechanism for most things
         * I will need to work around it in IStartupModule cases like in DotNetStarter.Web
         * this also won't support delegate rolutions
         */

        private void SortList <T>(ref IEnumerable <T> list, Type service)
        {
            if (_registrations.TryGetValue(service, out List <ContainerRegistration> sourceList))
            {
                var typed = from o in sourceList.Select(x => x.ServiceImplementation)
                            join i in list
                            on o equals i.GetType()
                            select i;

                list = typed.ToList();
            }
            ;
        }