public void TestGetComponent7() { try { ScriptComponentContainerBuilder builder = new ScriptComponentContainerBuilder(); builder.Script = "injection.vb"; builder.AddReference(Assembly.GetExecutingAssembly().Location); IMutableComponentContainer container = (IMutableComponentContainer)builder.Build(); container.GetComponent(typeof(TestClass3)); } catch (CompileErrorException e) { Console.WriteLine(e.GetType().Name); Console.WriteLine(e.Message); Console.WriteLine(e.StackTrace); foreach (CompileErrorInfo cei in e.GetCompileErrorInfos()) { Console.WriteLine("Source : " + cei.SourceName); Console.WriteLine("Desc : " + cei.Description); Console.WriteLine("Line : " + cei.ErrorLine); Console.WriteLine("LineText : " + cei.ErrorText); } Assert.Fail(); } }
/// <summary> /// コンポーネントをコンテナに登録する /// </summary> /// <param name="container">コンポーネントを登録するコンテナ</param> /// <param name="type">登録するコンポーネント</param> public void Register(IMutableComponentContainer container, Type type) { IComponentEntry entry = null; switch (instanceMode) { case ComponentInstanceMode.Prototype: if (componentName == null) { entry = new PrototypeComponentEntry(container, type); } else { entry = new PrototypeComponentEntry(container, type, componentName); } break; case ComponentInstanceMode.Singleton: if (componentName == null) { entry = new SingletonComponentEntry(container, type); } else { entry = new SingletonComponentEntry(container, type, componentName); } break; default: throw new InvlidComponentInstanceModeException(); } if (interfaceType == null) { container.Register(entry); } else { container.Register(interfaceType, entry); } }