/// <summary> /// コンポーネント作成処理の生成 /// </summary> /// <returns></returns> private IComponentCreator CreateComponentCreator() { // 設定ファイルから接続文字列を読み取り var config = QuillAppConfig.Load(); var generator = new ProxyGenerator(); var connectionString = config.GetValue("db.connection_string"); // コネクション生成処理を設定 // (デフォルトの動きは引数なしでnew) var creator = new ComponentCreators(); creator.AddCreator(typeof(IDataSource), t => { return(new DataSourceImpl(() => new SqlConnection(connectionString))); }); var componentTypeElements = config.GetElement("components").Elements().ToList(); componentTypeElements.ForEach(element => { var typeName = element.Value; var ifTypeName = element.Attribute("interface").Value; creator.AddCreator(TypeUtils.GetType(ifTypeName), t => Activator.CreateInstance(TypeUtils.GetType(typeName))); }); return(creator); }
public void Create_ArgumentComponent_Test() { // Arrange ComponentCreators target = new ComponentCreators(); // Act TU.ExecuteExcectedException <QuillException>( () => target.Create(typeof(ArgumentConstructorComponent))); }
public void AddCreator_NoCreatorIF_Test() { // Arrange ComponentCreators target = new ComponentCreators(); // Act TU.ExecuteExcectedException <QuillException>( () => target.Create(typeof(IComponentCreator))); }
public void Create_ComponentTypeNull_Test() { // Arrange ComponentCreators target = new ComponentCreators(); // Act TU.ExecuteExcectedException <ArgumentNullException>( () => target.Create(null)); }
public void Create_Default_Test() { // Arrange ComponentCreators target = new ComponentCreators(); // Act var actual = target.Create(typeof(NormalComponent)) as NormalComponent; // Assert Assert.IsNotNull(actual); }
private IComponentCreator CreateComponentCreator() { var creator = new ComponentCreators(); creator.AddCreator(typeof(IDataSource), t => { var source = new MultiDataSource(); source.RegisterDataSource("HogeSource", new DataSourceImpl(() => new ConnectionImpl())); return(source); }); return(creator); }
public void AddCreatorTest() { // Arrange ComponentCreators target = new ComponentCreators(); target.AddCreator(typeof(IComponentCreator), t => new ComponentCreators()); // Act var actual = target.Create(typeof(IComponentCreator)) as IComponentCreator; // Assert Assert.IsNotNull(actual); }
/// <summary> /// 既定の設定で初期化 /// </summary> public static void InitializeDefault() { Config = null; Container = new QuillContainer(); TypeMap = new TypeMapImpl(); ComponentCreator = new ComponentCreators(); Injector = new QuillInjector(); InjectionFilter = new InjectionFilterBase(); Message = QuillMessage.CreateForJPN(); OutputLog = OutputLogToConsole; // SQL Server用パラメータマーク ReplaceToParamMark = (paramName) => "@" + paramName; }
public override IReactComponent CreateComponent(string tag, string text) { ReactComponent res = null; if (ComponentCreators.TryGetValue(tag, out var creator)) { res = creator(tag, text, this); } else { res = defaultCreator(tag, text, this); } res.GameObject.name = $"<{tag}>"; return(res); }