public void RegisterWithAssemblyObject() { _context.RegisterAssembly(typeof(IContractInAnotherAssembly).Assembly); var c = _context.GetComponent <IContractInAnotherAssembly>(); Assert.IsNotNull(c); }
public void TestInitialize() { _context = new ComponentContext(); _context.RegisterAssembly(typeof(Aop.AssemblyPointer).Assembly); _classEmitter = _context.GetComponent <IClassEmitter>(); // UNCOMMENT FOLLOWING FOR DEBUGGING // _classEmitter = new DefaultClassEmitter { SaveEmittedAssembly = true, SaveTargetFolder = "D:\\" }; // _context.InitializePlugs(_classEmitter, typeof(DefaultClassEmitter)); _eth = new TestingEmittedTypeHandler(); }
private void ConfigureComposer() { var context = new ComponentContext(); var assembly = Assembly.Load("Nebula"); context.RegisterAssembly(assembly); context.Register(typeof(NebulaContext), new PreInitializedComponentFactory(this)); context.Configuration.DisableAttributeChecking = true; ComponentContext = context; }
static void Main() { var context = new ComponentContext(); context.RegisterAssembly(Assembly.GetExecutingAssembly()); var plugins = context.GetAllComponents <ICommandPlugin>(); while (true) { Console.WriteLine("Type any of the commands to proceed:"); Console.WriteLine("[exit] - Quit the application"); foreach (var plugin in plugins) { Console.WriteLine("[{0}] - {1}", plugin.Command, plugin.Title); } Console.Write("> "); var command = (Console.ReadLine() ?? "").ToLower(); if (command == "exit") { break; } var selectedPlugin = plugins.SingleOrDefault(p => p.Command.ToLower() == command); Console.WriteLine(); Console.WriteLine("-----------------------------------------------------------"); if (selectedPlugin != null) { selectedPlugin.Execute(); } else { Console.WriteLine("Error: Unknown command."); } Console.WriteLine("-----------------------------------------------------------"); Console.WriteLine(); } }
static void Main() { // Create a new component context. var context = new ComponentContext(); // Register the whole assembly. // This makes Composer to go through all of the types in // the assembly, searching for any public class that is // attributed with [Component], and registers it with // default settings. // // Assembly.GetExecutingAssembly() returns the current // assembly (the executable containing the Program class) context.RegisterAssembly(Assembly.GetExecutingAssembly()); // When calling GetComponent, Composer will instantiate // the components and fill the plugs recursively until // the component graph is completely initialized. var calculator = context.GetComponent <ICalculator>(); Console.WriteLine(); // Calling methods of ICalculator, which is realized by // DefaultCalculator class. Console.WriteLine("67 + 12 = {0}", calculator.Add(67, 12)); Console.WriteLine(); Console.WriteLine("67 - 12 = {0}", calculator.Subtract(67, 12)); Console.WriteLine(); Console.WriteLine("67 * 12 = {0}", calculator.Multiply(67, 12)); Console.WriteLine(); Console.WriteLine("67 / 12 = {0} (with remainder = {1})", calculator.Divide(67, 12), calculator.Remainder(67, 12)); Console.WriteLine(); }
static void Main() { // Create a new component context, and register all // available components in the assembly at once. var context = new ComponentContext(); context.RegisterAssembly(Assembly.GetExecutingAssembly()); // Lookup the main component from Composer, which // will handle the main logic of the application. // When the "GetComponent" method below is called, // the whole application graph is instantiated // recursively, and all of the dependencies are // set into the component plugs, before the // GetComponent method returns. So, when we call // the Run() method, everything is already prepared // for the application to run. context.GetComponent <IProgramRunner>().Run(); }
public static void Setup(ComponentContext composer) { composer.RegisterAssembly(Assembly.GetExecutingAssembly()); composer.ProcessApplicationConfiguration(); }
public void TestInitialize() { _context = new ComponentContext(); _context.RegisterAssembly(typeof(Aop.AssemblyPointer).Assembly); _classEmitter = _context.GetComponent <IClassEmitter>(); }
public static void RegisterAssemblyFile(this ComponentContext context, string path) { var assembly = Assembly.LoadFile(path); context.RegisterAssembly(assembly); }
public static void RegisterAssembly(this ComponentContext context, string name) { var assembly = Assembly.Load(name); context.RegisterAssembly(assembly); }
private static void RegisterDefaultComponents(ComponentContext composer) { composer.RegisterAssembly(Assembly.GetExecutingAssembly()); }