示例#1
0
        public void MakeUsingCtor_2()
        {
            var made = FactoryUtils.MakeUsingCtor <CTORClass>("node{arg0='7/1/1982'}".AsLaconicConfig());

            Aver.AreEqual(1982, made.A);
            Aver.AreEqual(7, made.B);
        }
示例#2
0
文件: Event.cs 项目: chadfords/nfx
        public virtual void Configure(IConfigSectionNode config)
        {
            if (Disposed)
            {
                return;
            }

            if (config == null)
            {
                return;
            }
            ConfigAttribute.Apply(this, config);

            var loc = config[TimeLocation.CONFIG_TIMELOCATION_SECTION];

            if (loc.Exists)
            {
                m_TimeLocation = FactoryUtils.MakeAndConfigure <TimeLocation>(loc, typeof(TimeLocation));
            }

            var ehnode = config[CONFIG_HANDLER_SECTION];

            if (ehnode.Exists)
            {
                EventHandler = FactoryUtils.MakeUsingCtor <IEventHandler>(ehnode);
            }
        }
示例#3
0
        public void MakeUsingCtor_1()
        {
            var made = FactoryUtils.MakeUsingCtor <CTORClass>("node{arg0=1 arg1=2}".AsLaconicConfig());

            Aver.AreEqual(1, made.A);
            Aver.AreEqual(2, made.B);
        }
示例#4
0
        public void MakeUsingCtor_3()
        {
            var made = FactoryUtils.MakeUsingCtor <CTORClass>("node{type='Azos.Tests.Nub.Configuration.CTORClassDerived, Azos.Tests.Nub' arg0=1 arg1=2}".AsLaconicConfig());

            Aver.IsTrue(made is CTORClassDerived);
            Aver.AreEqual(1, made.A);
            Aver.AreEqual(2, made.B);
        }
示例#5
0
        public void MakeUsingCtor_3()
        {
            var made = FactoryUtils.MakeUsingCtor <CTORClass>("node{type='NFX.NUnit.Config.CTORClassDerived, NFX.NUnit' arg0=1 arg1=2}".AsLaconicConfig());

            Assert.IsTrue(made is CTORClassDerived);
            Assert.AreEqual(1, made.A);
            Assert.AreEqual(2, made.B);
        }
示例#6
0
        public void MakeUsingCtor_7_typePattern()
        {
            var made = FactoryUtils.MakeUsingCtor <CTORClass>(
                "node{type='CTORClassDerived' arg0='12' arg1='234'}".AsLaconicConfig(), typePattern: "Azos.Tests.Nub.Configuration.*, Azos.Tests.Nub");

            Aver.IsTrue(made is CTORClassDerived);
            Aver.AreEqual(12, made.A);
            Aver.AreEqual(234, made.B);
        }
示例#7
0
        public void MakeUsingCtor_4()
        {
            var made = FactoryUtils.MakeUsingCtor <CTORClass>("node{type='Azos.Tests.Nub.Configuration.CTORClassDerived, Azos.Tests.Nub' arg0='7/1/1982'}".AsLaconicConfig());

            Aver.IsTrue(made is CTORClassDerived);
            Aver.AreEqual(1982, made.A);
            Aver.AreEqual(7, made.B);
            Aver.AreEqual(155, ((CTORClassDerived)made).C);
        }
示例#8
0
        public void MakeUsingCtor_7_typePattern()
        {
            var made = FactoryUtils.MakeUsingCtor <CTORClass>(
                "node{type='CTORClassDerived' arg0='12' arg1='234'}".AsLaconicConfig(), typePattern: "NFX.NUnit.Config.*, NFX.NUnit");

            Assert.IsTrue(made is CTORClassDerived);
            Assert.AreEqual(12, made.A);
            Assert.AreEqual(234, made.B);
        }
示例#9
0
        public void MakeUsingCtor_4()
        {
            var made = FactoryUtils.MakeUsingCtor <CTORClass>("node{type='NFX.NUnit.Config.CTORClassDerived, NFX.NUnit' arg0='7/1/1982'}".AsLaconicConfig());

            Assert.IsTrue(made is CTORClassDerived);
            Assert.AreEqual(1982, made.A);
            Assert.AreEqual(7, made.B);
            Assert.AreEqual(155, ((CTORClassDerived)made).C);
        }
示例#10
0
文件: Permissions.cs 项目: mjaric/nfx
        /// <summary>
        /// Makes multiple permissions from conf node
        /// </summary>
        public static IEnumerable <Permission> MultipleFromConf(IConfigSectionNode node)
        {
            if (node == null || !node.Exists)
            {
                return(Enumerable.Empty <Permission>());
            }
            var result = new List <Permission>();

            foreach (var pnode in node.Children.Where(cn => cn.IsSameName(CONFIG_PERMISSION_SECTION)))
            {
                result.Add(FactoryUtils.MakeUsingCtor <Permission>(pnode));
            }
            return(result);
        }
示例#11
0
        /// <summary>
        /// Makes multiple permissions from conf node
        /// </summary>
        public static IEnumerable <Permission> MultipleFromConf(IConfigSectionNode node,
                                                                string shortNodeName = null,
                                                                string typePattern   = null
                                                                )
        {
            if (node == null || !node.Exists)
            {
                return(Enumerable.Empty <Permission>());
            }

            var result = new List <Permission>();

            foreach (var pnode in node.Children.Where(cn => cn.IsSameName(CONFIG_PERMISSION_SECTION) ||
                                                      (shortNodeName.IsNotNullOrWhiteSpace() && cn.IsSameName(shortNodeName))))
            {
                result.Add(FactoryUtils.MakeUsingCtor <Permission>(pnode, typePattern));
            }

            return(result);
        }
示例#12
0
 public void MakeUsingCtor_5()
 {
     var made = FactoryUtils.MakeUsingCtor <CTORClass>("node{arg0=1}".AsLaconicConfig());
 }