本文整理汇总了C#中AssemblyResolver类的典型用法代码示例。如果您正苦于以下问题:C# AssemblyResolver类的具体用法?C# AssemblyResolver怎么用?C# AssemblyResolver使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AssemblyResolver类属于命名空间,在下文中一共展示了AssemblyResolver类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShouldOnlyReturnBinariesWhenFlagIsSet
public void ShouldOnlyReturnBinariesWhenFlagIsSet(
[Frozen] Mock<IPackageAssemblyResolver> packageAssemblyResolverMock,
[Frozen] Mock<IFileSystem> fileSystemMock,
[Frozen] Mock<IAssemblyUtility> assemblyUtilityMock,
AssemblyResolver resolver)
{
const string WorkingDirectory = @"C:\";
var binFolder = Path.Combine(WorkingDirectory, "bin");
assemblyUtilityMock.Setup(a => a.IsManagedAssembly(It.IsAny<string>())).Returns(true);
fileSystemMock.Setup(x => x.DirectoryExists(binFolder)).Returns(true);
fileSystemMock.Setup(x => x.DirectoryExists(@"C:\packages")).Returns(true);
fileSystemMock.SetupGet(x => x.PackagesFolder).Returns("packages");
fileSystemMock.SetupGet(x => x.BinFolder).Returns("bin");
fileSystemMock.Setup(x => x.EnumerateFiles(binFolder, It.IsAny<string>(), SearchOption.AllDirectories))
.Returns(Enumerable.Empty<string>());
packageAssemblyResolverMock.Setup(p=>p.GetAssemblyNames(WorkingDirectory)).Returns(new string[] {"test.dll", "test.exe", "test.foo"});
var assemblies = resolver.GetAssemblyPaths(WorkingDirectory, true).ToList();
assemblies.ShouldNotContain("test.foo");
assemblies.ShouldContain("test.dll");
assemblies.ShouldContain("test.exe");
}
示例2: ShouldNotReturnNonManagedAssemblies
public void ShouldNotReturnNonManagedAssemblies(
[Frozen] Mock<IFileSystem> fileSystemMock,
[Frozen] Mock<IPackageAssemblyResolver> packageAssemblyResolverMock,
[Frozen] Mock<IAssemblyUtility> assemblyUtilityMock,
AssemblyResolver resolver
)
{
const string WorkingDirectory = @"C:\";
var binFolder = Path.Combine(WorkingDirectory, "bin");
var managed = Path.Combine(binFolder, "MyAssembly.dll");
var nonManaged = Path.Combine(binFolder, "MyNonManagedAssembly.dll");
fileSystemMock.Setup(x => x.DirectoryExists(binFolder)).Returns(true);
fileSystemMock.SetupGet(x => x.PackagesFolder).Returns("packages");
fileSystemMock.SetupGet(x => x.BinFolder).Returns("bin");
fileSystemMock.Setup(x => x.EnumerateFiles(binFolder, It.IsAny<string>(), SearchOption.TopDirectoryOnly
))
.Returns(new[] { managed, nonManaged });
assemblyUtilityMock.Setup(x => x.IsManagedAssembly(managed)).Returns(true);
assemblyUtilityMock.Setup(x => x.IsManagedAssembly(nonManaged)).Returns(false);
var assemblies = resolver.GetAssemblyPaths(WorkingDirectory).ToList();
assemblies.Count.ShouldEqual(1);
assemblies[0].ShouldEqual(managed);
}
示例3: AssemblyLoaderImporter
public AssemblyLoaderImporter(ModuleReader moduleReader, AssemblyResolver assemblyResolver, EmbedTask embedTask)
{
instructionConstructorInfo = typeof (Instruction).GetConstructor(BindingFlags.NonPublic | BindingFlags.Instance, null, new[] {typeof (OpCode), typeof (object)}, null);
this.moduleReader = moduleReader;
this.assemblyResolver = assemblyResolver;
this.embedTask = embedTask;
}
示例4: Should_exception_if_type_not_found
public void Should_exception_if_type_not_found()
{
var job = new PrivateJob { Type = "someType" };
assemblyResolver = new AssemblyResolver(this.dir, log);
//Test
var ex = Assert.Throws<PluginNotFoundOrLoadedException>(() => assemblyResolver.ResolveType(job));
//Assert
Assert.That(ex.Message, Is.EqualTo(string.Format("The plugin someType is not found or loaded")));
}
示例5: DefaultResolve
public void DefaultResolve()
{
var resolver = new AssemblyResolver();
resolver.Should().NotBeNull();
var assemblies = resolver.Resolve().ToList();
assemblies.Should().NotBeEmpty();
assemblies.Should().Contain(a => a.FullName.StartsWith("System"));
}
示例6: IncludeAssemblyForTestCore
public void IncludeAssemblyForTestCore()
{
var resolver = new AssemblyResolver();
resolver.Should().NotBeNull();
resolver.IncludeAssemblyFor<SampleWorker>();
var assemblies = resolver.Resolve().ToList();
assemblies.Should().NotBeEmpty();
assemblies.Count.Should().Be(1);
assemblies.Should().Contain(a => a == typeof(SampleWorker).Assembly);
}
示例7: Should_Resolve_type_sucessfuly
public void Should_Resolve_type_sucessfuly()
{
var job = new WmiClient();
var files = new List<string>() { string.Format(@"{0}\SqlToGraphite.Plugin.Wmi.dll", Directory.GetCurrentDirectory()) };
dir.Expect(x => x.GetFilesInCurrentDirectory(AssemblyResolver.FilesToScan)).Return(files);
//Test
assemblyResolver = new AssemblyResolver(this.dir, log);
var rtn = assemblyResolver.ResolveType(job);
//Assert
Assert.That(rtn.FullName, Is.EqualTo(job.GetType().FullName));
dir.VerifyAllExpectations();
}
示例8: CreateAssemblyResolver
public void CreateAssemblyResolver(IEnumerable<string> paths)
{
string appDataKey = typeof (AssemblyResolver).FullName;
resolver = (AssemblyResolver)AppDomain.CurrentDomain.GetData(appDataKey)
?? new AssemblyResolver(new ConsoleLog());
AppDomain.CurrentDomain.SetData(appDataKey, resolver);
foreach (var path in paths)
{
resolver.AddDirectory(path);
}
}
示例9: ExcludeSystem
public void ExcludeSystem()
{
var domainAssemblies = AppDomain.CurrentDomain.GetAssemblies();
var resolver = new AssemblyResolver();
resolver.Should().NotBeNull();
resolver.ExcludeName("System");
var assemblies = resolver.Resolve().ToList();
assemblies.Should().NotBeEmpty();
assemblies.Should().NotContain(a => a.FullName.StartsWith("System"));
}
示例10: Configuration
/// <summary>
/// Initializes a new instance of the <see cref="Configuration"/> class.
/// </summary>
public Configuration()
{
_assemblies = new AssemblyResolver();
// exclude system assemblies
_assemblies.ExcludeName("mscorlib");
_assemblies.ExcludeName("Microsoft");
_assemblies.ExcludeName("System");
// exclude self
_assemblies.ExcludeName("KickStart");
_starters = new List<IKickStarter>();
}
示例11: Should_ignore_bad_image_exception_for_not_dot_net_dlls
public void Should_ignore_bad_image_exception_for_not_dot_net_dlls()
{
File.WriteAllText("bad.dll", "abc");
var job = new WmiClient() { Type = "SqlToGraphite.Plugin.Wmi.WmiClient" };
var files = new List<string>() { string.Format(@"{0}\bad.dll", Directory.GetCurrentDirectory()), string.Format(@"{0}\SqlToGraphite.Plugin.Wmi.dll", Directory.GetCurrentDirectory()) };
dir.Expect(x => x.GetFilesInCurrentDirectory(AssemblyResolver.FilesToScan)).Return(files);
//Test
assemblyResolver = new AssemblyResolver(this.dir, log);
//Test
var type = assemblyResolver.ResolveType(job);
//Assert
Assert.That(type.FullName, Is.EqualTo(job.GetType().FullName));
File.Delete("bad.dll");
}
示例12: SqlToGraphiteConfig
public SqlToGraphiteConfig()
{
var job = new JobImpl();
this.WireUpLog4Net();
var assemblyResolver = new AssemblyResolver(new DirectoryImpl(), log);
jobTypes = assemblyResolver.ResolveTypes(job);
alljobtypes = assemblyResolver.ResolveAllTypes(job);
//JobTypes = GetJobTypes().ToArray();
clientTypes = GetClientTypes().ToArray();
this.Jobs = new List<Job>();
this.Clients = new ListOfUniqueType<Client>();
this.Hosts = new List<Host>();
this.Templates = new List<Template>();
this.genericSerializer = new GenericSerializer(Global.GetNameSpace());
}
示例13: CompilerBase
public CompilerBase(
IFrontEnd frontEnd, IMiddleEnd middleEnd, IBackEnd backEnd,
CompilerOptions options
)
{
_options = options;
_frontEnd = frontEnd;
_middleEnd = middleEnd;
_backEnd = backEnd;
_frontEnd.Compiler = this;
_middleEnd.Compiler = this;
_backEnd.Compiler = this;
_resolver = new AssemblyResolver(this);
}
示例14: ConfigRepository
public ConfigRepository(IConfigReader configReader, ICache cache, ISleep sleep, ILog log,
int errorReadingConfigSleepTime, IGenericSerializer genericSerializer)
{
this.configReader = configReader;
this.cache = cache;
this.sleep = sleep;
ConfigRepository.log = log;
this.errorReadingConfigSleepTime = errorReadingConfigSleepTime;
this.genericSerializer = genericSerializer;
clientList = new GraphiteClients();
var dir = new DirectoryImpl();
if (ar == null)
{
ar = new AssemblyResolver(dir, log);
}
this.masterConfig = new SqlToGraphiteConfig(ar, log);
this.Hash = "NotSet";
}
示例15: Find
void Find() {
var cflowDeobfuscator = new CflowDeobfuscator(new MethodCallInliner(true));
foreach (var type in module.Types) {
if (DotNetUtils.GetPInvokeMethod(type, "kernel32", "CloseHandle") == null)
continue;
var resolver = new AssemblyResolver(type, cflowDeobfuscator);
if (!resolver.Detected)
continue;
var patcher = new MemoryPatcher(type, cflowDeobfuscator);
if (!patcher.Detected)
continue;
assemblyResolver = resolver;
memoryPatcher = patcher;
return;
}
}