コード例 #1
0
        public static void RegisterWithBuilderFromPath(ContainerBuilder builder, AppDomain currentDomain, EnumRegistrationType enumRegistrationType)
        {
            List<Assembly> vuelingAssembliesList = new List<Assembly>();
            Assembly[] vuelingAssembliesArray;

            customRegistration(builder);

            List<Assembly> assemblies = currentDomain.GetAssemblies().ToList<Assembly>();

            var loadedAssemblies = currentDomain.GetAssemblies().ToList();
            var loadedPaths = loadedAssemblies.Select(a => a.Location).ToArray();

            var referencedPaths = Directory.GetFiles(currentDomain.BaseDirectory, "*.dll");
            var toLoad = referencedPaths.Where(r => !loadedPaths.Contains(r, StringComparer.InvariantCultureIgnoreCase)).ToList();
            toLoad.ForEach(path => loadedAssemblies.Add(currentDomain.Load(AssemblyName.GetAssemblyName(path))));

            foreach (var referencedAssembly in toLoad)
            {

                assemblies.Add(Assembly.LoadFrom(referencedAssembly));

            }

            foreach (var assembly in assemblies.Distinct())
            {

                if (assembly.GetName().Name.ToLower().Contains("vueling")) vuelingAssembliesList.Add(Assembly.Load(assembly.GetName().Name));

            }
            vuelingAssembliesArray = vuelingAssembliesList.ToArray<Assembly>();

            if (enumRegistrationType == EnumRegistrationType.justWithDecoratedClasses) RegisterAssemblyTypesWithDecoratedClasses(builder, vuelingAssembliesArray);
            else RegisterAssemblyTypes(builder, vuelingAssembliesArray);
        }
コード例 #2
0
        public static void RegisterWithBuilder(ContainerBuilder builder, AppDomain currentDomain, EnumRegistrationType enumRegistrationType)
        {
            List<Assembly> vuelingAssembliesList = new List<Assembly>();
            Assembly[] vuelingAssembliesArray;

            customRegistration(builder);

            List<Assembly> assemblies = System.Web.Compilation.BuildManager.GetReferencedAssemblies().Cast<Assembly>().ToList();

            foreach (var assembly in assemblies)
            {

                if (assembly.GetName().Name.ToLower().Contains("vueling")) vuelingAssembliesList.Add(Assembly.Load(assembly.GetName().Name));

            }
            vuelingAssembliesArray = vuelingAssembliesList.ToArray<Assembly>();

            if (enumRegistrationType == EnumRegistrationType.justWithDecoratedClasses) RegisterAssemblyTypesWithDecoratedClasses(builder, vuelingAssembliesArray);
            else RegisterAssemblyTypes(builder, vuelingAssembliesArray);
        }