public void RegisterTwoTimesQueryBySelf() { _context.Register(typeof(DefaultCacheComponent)); // Register for second time var all = _context.GetAllComponents <DefaultCacheComponent>(); Assert.IsNotNull(all); Assert.IsTrue(all.Count() == 2); var allArray = all.ToArray(); var c0 = allArray[0]; var c1 = allArray[1]; Assert.AreNotSame(c0, c1); }
public void RegisterTwoTimesQueryBySelf() { _context.Register(typeof(ContractAgnosticComponent)); var all = _context.GetAllComponents <ContractAgnosticComponent>(); Assert.IsNotNull(all); Assert.IsTrue(all.Count() == 2); var allArray = all.ToArray(); var c0 = allArray[0]; var c1 = allArray[1]; Assert.AreNotSame(c0, c1); }
public void GetAllComponentsOfT() { var cs = _context.GetAllComponents <ISampleContract>(); Assert.IsNotNull(cs); Assert.IsTrue(cs.Count() == 0); }
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(); } }
public void RegisterSameManyTimesWithoutName() { _context.Register(typeof(SampleComponentOne)); _context.Register(typeof(SampleComponentOne)); _context.Register(typeof(SampleComponentOne)); var cs = _context.GetAllComponents <ISampleContract>(); Assert.IsNotNull(cs); Assert.AreEqual(3, cs.Count()); var ca = cs.ToArray(); Assert.IsNotNull(ca[0]); Assert.IsNotNull(ca[1]); Assert.IsNotNull(ca[2]); Assert.AreNotSame(ca[0], ca[1]); Assert.AreNotSame(ca[0], ca[2]); Assert.AreNotSame(ca[1], ca[2]); }