Configuration section handler for the (recommended, Spring.NET standard) parsers config section.

Spring.NET allows the registration of custom configuration parsers that can be used to create simplified configuration schemas that better describe object definitions.

For example, Spring.NET uses this facility internally in order to define simplified schemas for various AOP, Data and Services definitions.

상속: IConfigurationSectionHandler
		public void ParseSectionWithNoChildParserNamespaceElements()
		{
			const string xml = @"<?xml version='1.0' encoding='UTF-8' ?>
<parsers>
	<!-- now't in here -->
</parsers>";

			NamespaceParsersSectionHandler handler = new NamespaceParsersSectionHandler();
			handler.Create(null, null, BuildConfigurationSection(xml));
		}
		public void ParseSectionWithBadTypeForHandler()
		{
			const string xml = @"<?xml version='1.0' encoding='UTF-8' ?>
<parsers>
	<parser namespace='http://schemas.springframework.net/2' type='Rubbish' schemaLocation='assembly://Spring.Core.Tests/Spring.Context.Support/testobject.xsd'/>
</parsers>";

			NamespaceParsersSectionHandler handler = new NamespaceParsersSectionHandler();
			handler.Create(null, null, BuildConfigurationSection(xml));
		}
		public void ParseSectionWithHandlerThatDoesNotImplement_IXmlObjectDefinitionParser()
		{
			const string xml = @"<?xml version='1.0' encoding='UTF-8' ?>
<parsers>
	<parser namespace='http://schemas.springframework.net/2' type='Spring.Context.Support.NamespaceParsersSectionHandlerTests, Spring.Core.Tests' schemaLocation='assembly://Spring.Core.Tests/Spring.Context.Support/testobject.xsd'/>
</parsers>";

			NamespaceParsersSectionHandler handler = new NamespaceParsersSectionHandler();
			handler.Create(null, null, BuildConfigurationSection(xml));
		}
예제 #4
0
        public void ParseSectionWithEmptyType()
        {
            const string xml = @"<?xml version='1.0' encoding='UTF-8' ?>
<parsers>
	<parser namespace='http://schemas.springframework.net/3' type='' schemaLocation='assembly://Spring.Core.Tests/Spring.Context.Support/testobject.xsd'/>
</parsers>";

            NamespaceParsersSectionHandler handler = new NamespaceParsersSectionHandler();

            handler.Create(null, null, BuildConfigurationSection(xml));
        }
예제 #5
0
        public void ParseSectionWithNoChildParserNamespaceElements()
        {
            const string xml = @"<?xml version='1.0' encoding='UTF-8' ?>
<parsers>
	<!-- now't in here -->
</parsers>";

            NamespaceParsersSectionHandler handler = new NamespaceParsersSectionHandler();

            handler.Create(null, null, BuildConfigurationSection(xml));
        }
예제 #6
0
        public void ParseSectionWithHandlerThatDoesNotImplement_IXmlObjectDefinitionParser()
        {
            const string xml = @"<?xml version='1.0' encoding='UTF-8' ?>
<parsers>
	<parser namespace='http://schemas.springframework.net/2' type='Spring.Context.Support.NamespaceParsersSectionHandlerTests, Spring.Core.Tests' schemaLocation='assembly://Spring.Core.Tests/Spring.Context.Support/testobject.xsd'/>
</parsers>";

            NamespaceParsersSectionHandler handler = new NamespaceParsersSectionHandler();

            handler.Create(null, null, BuildConfigurationSection(xml));
        }
예제 #7
0
        public void WithParserElementThatIsMissingTheTypeAttribute()
        {
            const string xml = @"<?xml version='1.0' encoding='UTF-8' ?>
<parsers>
	<parser namespace='http://schemas.springframework.net/3'/>
</parsers>";

            NamespaceParsersSectionHandler handler = new NamespaceParsersSectionHandler();

            handler.Create(null, null, BuildConfigurationSection(xml));
        }
예제 #8
0
        public void ParseSectionWithBadTypeForHandler()
        {
            const string xml = @"<?xml version='1.0' encoding='UTF-8' ?>
<parsers>
	<parser namespace='http://schemas.springframework.net/2' type='Rubbish' schemaLocation='assembly://Spring.Core.Tests/Spring.Context.Support/testobject.xsd'/>
</parsers>";

            NamespaceParsersSectionHandler handler = new NamespaceParsersSectionHandler();

            Assert.Throws <TypeLoadException>(() => handler.Create(null, null, BuildConfigurationSection(xml)));
        }
		public void WithParserElementThatIsMissingTheTypeAttribute()
		{
			const string xml = @"<?xml version='1.0' encoding='UTF-8' ?>
<parsers>
	<parser namespace='http://schemas.springframework.net/3'/>
</parsers>";

			NamespaceParsersSectionHandler handler = new NamespaceParsersSectionHandler();
			handler.Create(null, null, BuildConfigurationSection(xml));
		}
		public void ParseSectionWithEmptyType()
		{
			const string xml = @"<?xml version='1.0' encoding='UTF-8' ?>
<parsers>
	<parser namespace='http://schemas.springframework.net/3' type='' schemaLocation='assembly://Spring.Core.Tests/Spring.Context.Support/testobject.xsd'/>
</parsers>";

			NamespaceParsersSectionHandler handler = new NamespaceParsersSectionHandler();
			Assert.Throws<ArgumentNullException>(() => handler.Create(null, null, BuildConfigurationSection(xml)));
		}