Deserialize() 공개 메소드

Deserializes the specified section.
public Deserialize ( XmlNode section ) : void
section System.Xml.XmlNode The section.
리턴 void
		public void ShouldProcessAdditonalSourcesElement_IfConfiguringSingleViewEngine()
		{
			var configXml =
				@"
			<monorail>
	<controllers>
	  <assembly>Castle.MonoRail.Framework.Tests</assembly>
	</controllers>

	<viewEngine viewPathRoot=""" +
				viewFolder +
				@""">

	  <additionalSources>
		<assembly name=""Castle.MonoRail.Framework.Tests"" namespace=""Castle.MonoRail.Framework.Tests.Content"" />
	  </additionalSources>
	</viewEngine>
  </monorail>";

			var doc = new XmlDocument();
			doc.LoadXml(configXml);
			var config = new ViewEngineConfig();
			config.Deserialize(doc.DocumentElement);

			Assert.IsTrue(config.AssemblySources.Count > 0, "additonal sources not loaded");
		}
예제 #2
0
		public void ShouldProcessAdditonalPathSourcesElement_IfConfiguringSingleViewEngine()
		{
			string configXml =
				@"
			<monorail>
	<controllers>
	  <assembly>Castle.MonoRail.Framework.Tests</assembly>
	</controllers>

	<viewEngine viewPathRoot=""" +
				viewFolder +
				@""">

	  <additionalSources>
		<path location=""" + viewFolder + @""" />
	  </additionalSources>
	</viewEngine>
  </monorail>";

			XmlDocument doc = new XmlDocument();
			doc.LoadXml(configXml);
			ViewEngineConfig config = new ViewEngineConfig();
			config.Deserialize(doc.DocumentElement);

			Assert.IsTrue(config.PathSources.Count > 0, "additonal path sources not loaded");
			Assert.AreEqual(viewFolder, config.PathSources[0]);
		}
		public void ShouldProcessAdditionalSourcesElement_IfConfiguringMultipleViewEngines()
		{
			string configXml = @"
			<monorail>
    <controllers>
      <assembly>Castle.MonoRail.Framework.Tests</assembly>
    </controllers>

    <viewEngines viewPathRoot=""Views"">
		<add type=""Castle.MonoRail.Framework.Tests.Configuration.TestViewEngine, Castle.MonoRail.Framework.Tests"" />
      <additionalSources>
        <assembly name=""Castle.MonoRail.Framework.Tests"" namespace=""Castle.MonoRail.Framework.Tests.Content"" />
      </additionalSources>
    </viewEngines>
  </monorail>";

			XmlDocument doc = new XmlDocument();
			doc.LoadXml(configXml);
			ViewEngineConfig config = new ViewEngineConfig();
			config.Deserialize(doc.DocumentElement);

			Assert.IsTrue(config.Sources.Length > 0, "Additional sources not loaded");

		}
예제 #4
0
        /// <summary>
        /// Deserializes the specified node.
        /// </summary>
        /// <param name="node">The node.</param>
        public void Deserialize(XmlNode node)
        {
            viewEngineConfig.Deserialize(node);
            smtpConfig.Deserialize(node);
            controllersConfig.Deserialize(node);
            viewComponentsConfig.Deserialize(node);
            scaffoldConfig.Deserialize(node);
            urlConfig.Deserialize(node);

            extensions.Deserialize(node);
            routingRules.Deserialize(node);
            defaultUrls.Deserialize(node);

            ProcessFilterFactoryNode(node.SelectSingleNode("customFilterFactory"));
            ProcessMatchHostNameAndPath(node.SelectSingleNode("routing"));
            ProcessExcludeAppPath(node.SelectSingleNode("routing"));

            var services = node.SelectSingleNode("services");

            if (services != null)
            {
                servicesConfig = XmlConfigurationDeserializer.GetDeserializedNode(services);
            }
        }
		public void ShouldUseDirectoryNamedViews_IfNoViewPathRootGiven()
		{
			// Multiple view engine config
			string configXml = @"
<monorail>
	<viewEngines>
		<add type=""Castle.MonoRail.Framework.Tests.Configuration.TestViewEngine, Castle.MonoRail.Framework.Tests"" />
	</viewEngines>
</monorail>";

			XmlDocument doc = new XmlDocument();
			doc.LoadXml(configXml);
			ViewEngineConfig config = new ViewEngineConfig();
			config.Deserialize(doc.DocumentElement);

			Assert.AreEqual(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "views"), config.ViewPathRoot);

			// Single view engine config
			configXml = @"
<monorail>
	<viewEngine customEngine=""Castle.MonoRail.Framework.Tests.Configuration.TestViewEngine, Castle.MonoRail.Framework.Tests"" />
</monorail>";

			doc.LoadXml(configXml);

			config.Deserialize(doc.DocumentElement);

			Assert.AreEqual(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "views"), config.ViewPathRoot);
		}
		public void ConfigureWithSingleViewEngine_Should_Work_For_Backward_Compatibility()
		{
			var configXml =
				@"
				<monorail>
					<viewEngine customEngine=""Castle.MonoRail.Framework.Tests.Configuration.TestViewEngine,Castle.MonoRail.Framework.Tests"" viewPathRoot=""" + viewFolder + @"""/>
				</monorail>";

			var doc = new XmlDocument();
			doc.LoadXml(configXml);
			var config = new ViewEngineConfig();
			config.Deserialize(doc.DocumentElement);

			Assert.AreEqual(1, config.ViewEngines.Count);

			Assert.IsTrue(config.ViewEngines.Exists(TestViewEngineSpecification));
		}
		public void ConfigureWithMultipleViewEngines_AssignedEnginesToViewEnginesProperty()
		{
			var configXml =@"
<monorail>
	<controllers>
		<assembly>Castle.MonoRail.Framework.Tests</assembly>
	</controllers>
	<viewEngines viewPathRoot=""" + viewFolder + @""">
		<add
			type=""Castle.MonoRail.Framework.Tests.Configuration.TestViewEngine,
					Castle.MonoRail.Framework.Tests"" />
		<add
			type=""Castle.MonoRail.Framework.Views.Aspx.WebFormsViewEngine,
					Castle.MonoRail.Framework"" />
	</viewEngines>
</monorail>";

			var doc = new XmlDocument();
			doc.LoadXml(configXml);
			var config = new ViewEngineConfig();
			config.Deserialize(doc.DocumentElement);
			
			Assert.AreEqual(2, config.ViewEngines.Count);
			
			Assert.IsTrue(config.ViewEngines.Exists(TestViewEngineSpecification));
			
			Assert.IsTrue(config.ViewEngines.Exists(WebFormsViewEngineSpecification));
		}