public void TestLoadImplementationDifferentNamespace() { var protocolName = typeof(IRunnable); var classLoader = new DynaClassLoader(); // Vlingo.Xoom.Common.Runnable__Proxy is what is being called if the interface is implemented in // different namespace than the implementation. var dynaNamingClassType = classLoader.LoadClass("Vlingo.Xoom.Common.Runnable__Proxy", protocolName); Assert.NotNull(dynaNamingClassType); }
private static DynaClassLoader ClassLoaderFor(Actor actor) { var classLoader = actor.LifeCycle.Environment.Stage.World.ClassLoader; if (classLoader == null) { classLoader = new DynaClassLoader(); actor.Stage.World.ClassLoader = classLoader; } return classLoader; }
public void TestDynaClassLoader() { var classLoader = new DynaClassLoader(); var dynaNamingClassType = classLoader.LoadClass("Vlingo.Xoom.Common.Compiler.DynaNaming"); Assert.NotNull(dynaNamingClassType); var relativeTargetFile = ToFullPath(ClassName); var pathToGeneratedSource = ToNamespacePath(ClassName); var directory = GeneratedTestSources + pathToGeneratedSource; if (!Directory.Exists(directory)) { Directory.CreateDirectory(directory); } var pathToSource = $"{GeneratedTestSources}{relativeTargetFile}.cs"; var input = new Input( typeof(ITestInterface), ClassName, ClassName, Source, PersistDynaClassSource(pathToSource, Source), classLoader, DynaType.Test, false); new DynaCompiler().Compile(input); // load a brand new class just added to the DynaClassLoader var testClass = classLoader.LoadClass(ClassName); Assert.NotNull(testClass); var instance = (ITestInterface)Activator.CreateInstance(testClass); Assert.NotNull(instance); Assert.Equal(1, instance.Test()); // load another class from the default/parent ClassLoader var actorDynaClass = classLoader.LoadClass("Vlingo.Xoom.Common.Compiler.DynaFile"); Assert.NotNull(actorDynaClass); }
private World(string name, Configuration configuration) { Name = name; Configuration = configuration; classLoader = new DynaClassLoader(GetType().GetAssemblyLoadContext()); completesProviderKeeper = new CompletesEventuallyProviderKeeper(); loggerProviderKeeper = new LoggerProviderKeeper(); mailboxProviderKeeper = new MailboxProviderKeeper(); stages = new Dictionary <string, Stage>(); AddressFactory = new AddressFactory(); var defaultStage = StageNamed(DefaultStage); configuration.StartPlugins(this, 1); StartRootFor(defaultStage, DefaultLogger); configuration.StartPlugins(this, 2); defaultStage.StartDirectoryScanner(); }