Exemplo n.º 1
0
        /// <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);
        }
Exemplo n.º 2
0
        public void Create_ArgumentComponent_Test()
        {
            // Arrange
            ComponentCreators target = new ComponentCreators();

            // Act
            TU.ExecuteExcectedException <QuillException>(
                () => target.Create(typeof(ArgumentConstructorComponent)));
        }
Exemplo n.º 3
0
        public void AddCreator_NoCreatorIF_Test()
        {
            // Arrange
            ComponentCreators target = new ComponentCreators();

            // Act
            TU.ExecuteExcectedException <QuillException>(
                () => target.Create(typeof(IComponentCreator)));
        }
Exemplo n.º 4
0
        public void Create_ComponentTypeNull_Test()
        {
            // Arrange
            ComponentCreators target = new ComponentCreators();

            // Act
            TU.ExecuteExcectedException <ArgumentNullException>(
                () => target.Create(null));
        }
Exemplo n.º 5
0
        public void Create_Default_Test()
        {
            // Arrange
            ComponentCreators target = new ComponentCreators();

            // Act
            var actual = target.Create(typeof(NormalComponent)) as NormalComponent;

            // Assert
            Assert.IsNotNull(actual);
        }
Exemplo n.º 6
0
        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);
        }
Exemplo n.º 7
0
        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);
        }
Exemplo n.º 8
0
        /// <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;
        }
Exemplo n.º 9
0
        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);
        }