当前位置: 首页>>代码示例>>C#>>正文


C# AppDomain.GetAssemblies方法代码示例

本文整理汇总了C#中System.AppDomain.GetAssemblies方法的典型用法代码示例。如果您正苦于以下问题:C# AppDomain.GetAssemblies方法的具体用法?C# AppDomain.GetAssemblies怎么用?C# AppDomain.GetAssemblies使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.AppDomain的用法示例。


在下文中一共展示了AppDomain.GetAssemblies方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RegisterWithBuilderFromPath

        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);
        }
开发者ID:jcgonzalezalzate,项目名称:HerbProject,代码行数:34,代码来源:DIGlobalRegister.cs

示例2: DiscoverServices

 /// <summary>
 /// Discovers the services.
 /// </summary>
 public static void DiscoverServices(string prefix, AppDomain domain, bool cors)
 {
     IEnumerable<Assembly> possibleAssemblies = domain.GetAssemblies();
     IList<Type> possibleTypes = new List<Type>();
     foreach (Assembly assembly in possibleAssemblies)
     {
         if (!assembly.FullName.StartsWith("System"))
         {
             foreach (Type type in assembly.GetTypes())
             {
                 if (IsValidService(type))
                 {
                     string name = string.IsNullOrEmpty(prefix) ? type.Name.ToLower() : prefix + "/" + type.Name.ToLower();
                     if (cors)
                     {
                         RouteTable.Routes.Add(new ServiceRoute(name, new CorsEnabledServiceHostFactory(), type));
                     }
                     else
                     {
                         RouteTable.Routes.Add(new ServiceRoute(name, new WebServiceHostFactory(), type));
                     }
                 }
             }
         }
     }
 }
开发者ID:jseijas,项目名称:supido,代码行数:29,代码来源:ServiceDiscover.cs

示例3: Add

		public void Add(AppDomain appDomain)
		{
			foreach (Assembly assembly in appDomain.GetAssemblies())
			{
				Add(assembly);
			}
		}
开发者ID:modulexcite,项目名称:NetReflector,代码行数:7,代码来源:NetReflectorTypeTable.cs

示例4: Print

        // Private Methods 

        private static void Print(AppDomain defaultAppDomain)
        {
            Assembly[] loadedAssemblies = defaultAppDomain.GetAssemblies();
            Console.WriteLine("Here are the assemblies loaded in {0}\n", defaultAppDomain.FriendlyName);
            foreach (Assembly a in loadedAssemblies)
                PrintAssemblyName(a.GetName());
        }
开发者ID:exaphaser,项目名称:cs2php,代码行数:9,代码来源:ApplicationDomains.cs

示例5: ListLoadedTypes

        public IEnumerable<TypeWrapper> ListLoadedTypes(AppDomain appDomain)
        {
            if (appDomain == null)
                throw new ArgumentNullException("appDomain");

            return appDomain.GetAssemblies().SelectMany(o => o.GetTypes().Select(t => new TypeWrapper(null, t)));
        }
开发者ID:ptownsend1984,项目名称:SampleApplications,代码行数:7,代码来源:ListLoadedTypesHelper.cs

示例6: RegisterAllAssemblies

 public static void RegisterAllAssemblies(IExecutionContext context, AppDomain domain)
 {
     foreach(Assembly assembly in domain.GetAssemblies())
     {
         context.RegisterAssembly(assembly);
     }
 }
开发者ID:redxdev,项目名称:DScript,代码行数:7,代码来源:ContextUtilities.cs

示例7: GetAssembly

 public Assembly GetAssembly(AppDomain _domain, string _name)
 {
     foreach (Assembly _asm in _domain.GetAssemblies ()) {
         if (_asm.GetName ().Name == _name)
             return _asm;
     }
     return null;
 }
开发者ID:BackupTheBerlios,项目名称:nmodule-svn,代码行数:8,代码来源:ModuleLoader.cs

示例8: PrintAssemblies

 private static void PrintAssemblies(AppDomain appDomain)
 {
     Console.WriteLine();
     Console.WriteLine("{0} assemblies:", appDomain.FriendlyName);
     foreach (var assembly in appDomain.GetAssemblies())
     {
         Console.WriteLine("  {0}", assembly.FullName);
     }
 }
开发者ID:thijskuipers,项目名称:CrmAppDomainTests,代码行数:9,代码来源:Program.cs

示例9: GetPublicPartRegistryInstancesInAppDomain

        private static IEnumerable<IPartRegistry<IContractService>> GetPublicPartRegistryInstancesInAppDomain(AppDomain domain)
        {
            var registryInstancesLocatedInDomain = domain
                .GetAssemblies()
                .SelectMany(x => PartRegistryTypeFilter.Filter(x.GetTypes()))
                .Select(CreatePartRegistryInstance);

            return registryInstancesLocatedInDomain;
        }
开发者ID:doublekill,项目名称:MefContrib,代码行数:9,代码来源:AppDomainPartRegistryLocator.cs

示例10: CreateMessageHandlersFromDomain

 public static List<IMessageHandler> CreateMessageHandlersFromDomain(AppDomain appDomain)
 {
     //http://stackoverflow.com/questions/5120647/instantiate-all-classes-implementing-a-specific-interface
     var interfaceType = typeof(IMessageHandler);
     return appDomain.GetAssemblies()
       .SelectMany(x => x.GetTypes())
       .Where(x => interfaceType.IsAssignableFrom(x) && !x.IsInterface && !x.IsAbstract)
       .Select(x => Activator.CreateInstance(x) as IMessageHandler).ToList();
 }
开发者ID:notepid,项目名称:DotDotBot,代码行数:9,代码来源:PluginLoader.cs

示例11: ReadAppDomain

 private void ReadAppDomain( AppDomain appDomain )
 {
     Assembly[] loadedAssemblies = appDomain.GetAssemblies();
      Console.WriteLine( "*************** Assemblies in {0} ***************", appDomain.FriendlyName );
      foreach (Assembly assembly in loadedAssemblies)
      {
     Console.WriteLine( "->Name: {0}", assembly.GetName().Name );
     Console.WriteLine( "->Version: {0}\n", assembly.GetName().Version );
      }
 }
开发者ID:ghostmonk,项目名称:CSharpTutorials,代码行数:10,代码来源:ProcessAppDomains.cs

示例12: ListAllAssembilesInAppDomain

        private static void ListAllAssembilesInAppDomain(AppDomain appDomain) {            
            var loadedAssemblies = from asm in appDomain.GetAssemblies()
                                       orderby asm.GetName().Name
                                       select asm;
            Console.WriteLine("************************* Assembiles loaded in {0} **", appDomain.FriendlyName);

            foreach (Assembly a in loadedAssemblies) {
                Console.WriteLine("-> Name: {0}", a.GetName().Name);
                Console.WriteLine("-> Version: {0}\n", a.GetName().Version);
            }
        }
开发者ID:Geronimobile,项目名称:DotNetExamIntro,代码行数:11,代码来源:Program.cs

示例13: FindAndPrintAssembly

        private static void FindAndPrintAssembly(AppDomain appDomain, string assemblyName)
        {
            var anAssembly = appDomain.GetAssemblies().Where(assembly => assembly.GetName().Name.Equals(assemblyName, StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault();

            if (anAssembly == null)
            {
                Console.WriteLine("Did not find Assembly {0} in {1})", assemblyName, appDomain.FriendlyName);
            }
            else
            {
                Console.WriteLine("Found Assembly --> {0} (version:{1}) in {2}", anAssembly.GetName().Name, anAssembly.GetName().Version, appDomain.FriendlyName);
            }
        }
开发者ID:caloggins,项目名称:DOT-NET-on-Linux,代码行数:13,代码来源:Program.cs

示例14: ListAllAssembliesInAppDomain

        static void ListAllAssembliesInAppDomain(AppDomain ad)
        {
            var loadedAssemblies = from a in ad.GetAssemblies()
                orderby a.GetName().Name
                select a;
            Console.WriteLine("***** Here are the assemblies loaded in {0} *****\n", ad.FriendlyName);

            foreach (Assembly assembly in loadedAssemblies)
            {
                Console.WriteLine("-> Name: {0}", assembly.GetName().Name);
                Console.WriteLine("-> Version: {0}", assembly.GetName().Version);
            }
        }
开发者ID:volkoff-pro,项目名称:Troelsen.CSharp,代码行数:13,代码来源:Program.cs

示例15: Configure

        public static void Configure(
            AppDomain appDomain, IContainer container, IConventionConfigurator[] conventionConfigurators)
        {
            lock (Configured)
            {
                if (Configured.ContainsKey(appDomain) && Configured[appDomain].Contains(container))
                {
                    throw new InvalidOperationException(
                        "Application from this domain has been configured for this container already. " +
                        "AppllicationConfigurator.Configure() must be called once per AppDomain per Container.");
                }
                if (Configured.ContainsKey(appDomain))
                {
                    Configured[appDomain].Add(container);
                }
                else
                {
                    Configured.Add(appDomain, new HashSet<IContainer> {container});
                }
            }

            var assemblies = appDomain.GetAssemblies();
            foreach (var assembly in assemblies)
            {
                var assemblyTypes = assembly.GetTypes();
                Type assemblyConfiguratorType;
                try
                {
                    assemblyConfiguratorType =
                        assemblyTypes.SingleOrDefault(x => x.IsAssignableFrom(typeof (IAssemblyConfigurator)));
                }
                catch (Exception exception)
                {
                    var s = string.Join(string.Format(",{0}", Environment.NewLine),
                                        assemblyTypes.Where(x => x.IsAssignableFrom(typeof (IAssemblyConfigurator)))
                                                        .Select(x => x.FullName));
                    throw new Exception(string.Format("Found more than one assembly configurators in assembly '{0}'. " +
                                                        "There must be only one configurator in assembly. " +
                                                        "Configurator types found:{1}{2}",
                                                        assembly.FullName, Environment.NewLine, s),
                                        exception);
                }
                if (assemblyConfiguratorType != null)
                {
                    var assemblyConfigurator = (IAssemblyConfigurator)Activator.CreateInstance(assemblyConfiguratorType);
                    assemblyConfigurator.Configure(container, assemblyTypes);
                }
                assemblyTypes.ForEach(assemlyType =>
                    conventionConfigurators.ForEach(x => x.Configure(container, assemlyType)));
            }
        }
开发者ID:vlindos,项目名称:Vlindos,代码行数:51,代码来源:AppllicationConfigurator.cs


注:本文中的System.AppDomain.GetAssemblies方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。