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.

Inheritance: IConfigurationSectionHandler
コード例 #1
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));
		}
コード例 #2
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();
			handler.Create(null, null, BuildConfigurationSection(xml));
		}
コード例 #3
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));
		}
コード例 #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)));
        }
コード例 #9
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));
		}
コード例 #10
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();
			Assert.Throws<ArgumentNullException>(() => handler.Create(null, null, BuildConfigurationSection(xml)));
		}