本文整理汇总了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);
}
示例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));
}
}
}
}
}
}
示例3: Add
public void Add(AppDomain appDomain)
{
foreach (Assembly assembly in appDomain.GetAssemblies())
{
Add(assembly);
}
}
示例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());
}
示例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)));
}
示例6: RegisterAllAssemblies
public static void RegisterAllAssemblies(IExecutionContext context, AppDomain domain)
{
foreach(Assembly assembly in domain.GetAssemblies())
{
context.RegisterAssembly(assembly);
}
}
示例7: GetAssembly
public Assembly GetAssembly(AppDomain _domain, string _name)
{
foreach (Assembly _asm in _domain.GetAssemblies ()) {
if (_asm.GetName ().Name == _name)
return _asm;
}
return null;
}
示例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);
}
}
示例9: GetPublicPartRegistryInstancesInAppDomain
private static IEnumerable<IPartRegistry<IContractService>> GetPublicPartRegistryInstancesInAppDomain(AppDomain domain)
{
var registryInstancesLocatedInDomain = domain
.GetAssemblies()
.SelectMany(x => PartRegistryTypeFilter.Filter(x.GetTypes()))
.Select(CreatePartRegistryInstance);
return registryInstancesLocatedInDomain;
}
示例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();
}
示例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 );
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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)));
}
}