当前位置: 首页>>代码示例>>C#>>正文


C# XmlObjectFactory.GetObjectDefinitionNames方法代码示例

本文整理汇总了C#中Spring.Objects.Factory.Xml.XmlObjectFactory.GetObjectDefinitionNames方法的典型用法代码示例。如果您正苦于以下问题:C# XmlObjectFactory.GetObjectDefinitionNames方法的具体用法?C# XmlObjectFactory.GetObjectDefinitionNames怎么用?C# XmlObjectFactory.GetObjectDefinitionNames使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Spring.Objects.Factory.Xml.XmlObjectFactory的用法示例。


在下文中一共展示了XmlObjectFactory.GetObjectDefinitionNames方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ReadsMongoAttributesCorrectly

        public void ReadsMongoAttributesCorrectly()
        {
            string xml = @"<?xml version='1.0' encoding='UTF-8' ?>
                           <objects xmlns='http://www.springframework.net' xmlns:mongo='http://www.springframework.net/mongo'>
                                <mongo:mongo url='mongodb://localhost' write-concern='WMajority' />
                           </objects>";
            var factory = new XmlObjectFactory(new StringResource(xml, Encoding.UTF8));

            Assert.That(factory.GetObjectDefinitionNames(), Contains.Item("Mongo"));

            IObjectDefinition definition = factory.GetObjectDefinition("Mongo");

            Assert.That(definition, Is.Not.Null);

            IList<PropertyValue> values = definition.PropertyValues.PropertyValues;

            Assert.That(values, Contains.Item(new PropertyValue("WriteConcern", "WMajority")));
            Assert.That(values, Contains.Item(new PropertyValue("Url", "mongodb://localhost")));
        }
开发者ID:thomast74,项目名称:spring-net-data-mongodb,代码行数:19,代码来源:MongoFactoryParserTests.cs

示例2: _ChildDefinitionWithoutIdOrNameOrALiasGetsOneAutogenerated

        private void _ChildDefinitionWithoutIdOrNameOrALiasGetsOneAutogenerated(out Stream stream)
        {
            const string xml =
                @"<?xml version='1.0' encoding='UTF-8' ?>
<objects xmlns='http://www.springframework.net' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
	xsi:schemaLocation='http://www.springframework.net http://www.springframework.net/xsd/spring-objects.xsd'>
	<object id='mother' abstract='true' type='Spring.Objects.TestObject, Spring.Core.Tests'/>
	<object parent='mother'/>
</objects>";
            stream = new MemoryStream(Encoding.UTF8.GetBytes(xml));
            XmlObjectFactory factory = new XmlObjectFactory(new InputStreamResource(stream, string.Empty));
            IList<string> names = factory.GetObjectDefinitionNames();
            // mmm, how is one to test this? I have no idea what the generated name is...
            Assert.AreEqual(2, names.Count, "Should have got two object names, one of which is autogenerated.");
        }
开发者ID:fgq841103,项目名称:spring-net,代码行数:15,代码来源:XmlObjectFactoryTests.cs

示例3: IfNoIdUseDefault

        public void IfNoIdUseDefault()
        {
            string xml = @"<?xml version='1.0' encoding='UTF-8' ?>
                            <objects xmlns='http://www.springframework.net' xmlns:mongo='http://www.springframework.net/mongo'>
                                <mongo:convention-profile />
                            </objects>";
            var factory = new XmlObjectFactory(new StringResource(xml, Encoding.UTF8));

            Assert.That(factory.GetObjectDefinitionNames(), Contains.Item("MongoConventionProfile"));

            var conventionProfile = factory.GetObject("MongoConventionProfile") as ConventionProfile;

            Assert.That(conventionProfile, Is.Not.Null);
            Assert.That(conventionProfile.DefaultValueConvention, Is.TypeOf<NullDefaultValueConvention>());
            Assert.That(conventionProfile.ElementNameConvention, Is.TypeOf<MemberNameElementNameConvention>());
            Assert.That(conventionProfile.ExtraElementsMemberConvention, Is.TypeOf<NamedExtraElementsMemberConvention>());
            Assert.That(conventionProfile.IdGeneratorConvention, Is.TypeOf<LookupIdGeneratorConvention>());
            Assert.That(conventionProfile.IdMemberConvention, Is.TypeOf<NamedIdMemberConvention>());
            Assert.That(conventionProfile.IgnoreExtraElementsConvention, Is.TypeOf<NeverIgnoreExtraElementsConvention>());
            Assert.That(conventionProfile.IgnoreIfDefaultConvention, Is.TypeOf<NeverIgnoreIfDefaultConvention>());
            Assert.That(conventionProfile.IgnoreIfNullConvention, Is.TypeOf<NeverIgnoreIfNullConvention>());
            Assert.That(conventionProfile.MemberFinderConvention, Is.TypeOf<PublicMemberFinderConvention>());
            Assert.That(conventionProfile.SerializationOptionsConvention, Is.TypeOf<NullSerializationOptionsConvention>());
        }
开发者ID:thomast74,项目名称:spring-net-data-mongodb,代码行数:24,代码来源:MongoConventionProfileParserTests.cs

示例4: ReadsReplicaSetCorrectly

        public void ReadsReplicaSetCorrectly()
        {
            string xml = @"<?xml version='1.0' encoding='UTF-8' ?>
                           <objects xmlns='http://www.springframework.net' xmlns:mongo='http://www.springframework.net/mongo'>
                              <mongo:mongo id='Mongo2' replica-set='127.0.0.1:4711,127.0.0.1:4712' />
                           </objects>";
            var factory = new XmlObjectFactory(new StringResource(xml, Encoding.UTF8));

            Assert.That(factory.GetObjectDefinitionNames(), Contains.Item("Mongo2"));

            var server = factory.GetObject<MongoServer>("Mongo2");

            Assert.That(server, Is.Not.Null);
            Assert.That(server.Settings.Servers, Contains.Item(new MongoServerAddress("127.0.0.1", 4711)));
            Assert.That(server.Settings.Servers, Contains.Item(new MongoServerAddress("127.0.0.1", 4712)));
        }
开发者ID:thomast74,项目名称:spring-net-data-mongodb,代码行数:16,代码来源:MongoFactoryParserTests.cs

示例5: AutoAliasing

        public void AutoAliasing()
        {
            IResource resource = new ReadOnlyXmlTestResource("collections.xml", GetType());
            XmlObjectFactory xof = new XmlObjectFactory(resource);
            IList<string> objectNames = xof.GetObjectDefinitionNames();
            TestObject tb1 = (TestObject) xof.GetObject("aliased");
            TestObject alias1 = (TestObject) xof.GetObject("myalias");
            Assert.IsTrue(tb1 == alias1);

            IList<string> tb1Aliases = xof.GetAliases("aliased");
            Assert.AreEqual(1, tb1Aliases.Count);
            Assert.IsTrue(tb1Aliases.Contains("myalias"));
            Assert.IsTrue(objectNames.Contains("aliased"));
            Assert.IsFalse(objectNames.Contains("myalias"));

            TestObject tb2 = (TestObject) xof.GetObject("multiAliased");
            TestObject alias2 = (TestObject) xof.GetObject("alias1");
            TestObject alias3 = (TestObject) xof.GetObject("alias2");
            Assert.IsTrue(tb2 == alias2);
            Assert.IsTrue(tb2 == alias3);
            IList<string> tb2Aliases = xof.GetAliases("multiAliased");
            Assert.AreEqual(2, tb2Aliases.Count);
            Assert.IsTrue(tb2Aliases.Contains("alias1"));
            Assert.IsTrue(tb2Aliases.Contains("alias2"));
            Assert.IsTrue(objectNames.Contains("multiAliased"));
            Assert.IsFalse(objectNames.Contains("alias1"));
            Assert.IsFalse(objectNames.Contains("alias2"));

            TestObject tb3 = (TestObject) xof.GetObject("aliasWithoutId1");
            TestObject alias4 = (TestObject) xof.GetObject("aliasWithoutId2");
            TestObject alias5 = (TestObject) xof.GetObject("aliasWithoutId3");
            Assert.IsTrue(tb3 == alias4);
            Assert.IsTrue(tb3 == alias5);

            IList<string> tb3Aliases = xof.GetAliases("aliasWithoutId1");
            Assert.AreEqual(2, tb2Aliases.Count);
            Assert.IsTrue(tb3Aliases.Contains("aliasWithoutId2"));
            Assert.IsTrue(tb3Aliases.Contains("aliasWithoutId3"));
            Assert.IsTrue(objectNames.Contains("aliasWithoutId1"));
            Assert.IsFalse(objectNames.Contains("aliasWithoutId2"));
            Assert.IsFalse(objectNames.Contains("aliasWithoutId3"));

            string className = typeof(TestObject).FullName;
            string targetName = className + ObjectDefinitionReaderUtils.GENERATED_OBJECT_NAME_SEPARATOR + "0";

            TestObject tb4 = (TestObject)xof.GetObject(targetName);
            Assert.AreEqual(null, tb4.Name);
        }
开发者ID:fgq841103,项目名称:spring-net,代码行数:48,代码来源:XmlObjectCollectionTests.cs


注:本文中的Spring.Objects.Factory.Xml.XmlObjectFactory.GetObjectDefinitionNames方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。