public override void ProcessResource(IResource source, IConfigurationStore store)
		{
			XmlProcessor.XmlProcessor processor;
			if (Kernel == null)
			{
				processor = new XmlProcessor.XmlProcessor(EnvironmentName);
			}
			else
			{
				var resourceSubSystem = Kernel.GetSubSystem(SubSystemConstants.ResourceKey) as IResourceSubSystem;
				processor = new XmlProcessor.XmlProcessor(EnvironmentName, resourceSubSystem);
			}

			try
			{
				XmlNode element = processor.Process(source);

				Deserialize(element, store);
			}
			catch(XmlProcessorException)
			{
				const string message = "Unable to process xml resource ";

				throw new Exception(message);
			}
		}
		public override object Create(object parent, object configContext, XmlNode section)
		{							
			XmlProcessor processor = new XmlProcessor();
			
			XmlNode result = processor.Process(section);

			return base.Create(parent, configContext, result);
		}
		public void InvalidFiles()
		{
			var files = Directory.GetFiles(GetFullPath(), "Invalid*.xml");
			Assert.IsNotEmpty(files);

			foreach (var fileName in files)
			{
				var doc = GetXmlDocument(fileName);
				var processor = new XmlProcessor();

				Assert.Throws(typeof(ConfigurationProcessingException), () =>
					processor.Process(doc.DocumentElement));

			}
		}
Ejemplo n.º 4
0
        public override void ProcessResource(IResource source, IConfigurationStore store, IKernel kernel)
        {
            var resourceSubSystem = kernel.GetSubSystem(SubSystemConstants.ResourceKey) as IResourceSubSystem;
            var processor         = new XmlProcessor.XmlProcessor(EnvironmentName, resourceSubSystem);

            try
            {
                var element   = processor.Process(source);
                var converter = kernel.GetConversionManager();
                Deserialize(element, store, converter);
            }
            catch (XmlProcessorException e)
            {
                throw new ConfigurationProcessingException("Unable to process xml resource.", e);
            }
        }
Ejemplo n.º 5
0
		public override void ProcessResource(IResource source, IConfigurationStore store, IKernel kernel)
		{
			var resourceSubSystem = kernel.GetSubSystem(SubSystemConstants.ResourceKey) as IResourceSubSystem;
			var processor = new XmlProcessor.XmlProcessor(EnvironmentName, resourceSubSystem);

			try
			{
				var element = processor.Process(source);
				var converter = kernel.GetConversionManager();
				Deserialize(element, store, converter);
			}
			catch (XmlProcessorException e)
			{
				throw new ConfigurationProcessingException("Unable to process xml resource.", e);
			}
		}
Ejemplo n.º 6
0
		public void InvalidFiles()
		{
			String dirFullPath = GetFullPath();

			foreach(String fileName in Directory.GetFiles(dirFullPath, "Invalid*.xml"))
			{
				try
				{
					XmlDocument doc = GetXmlDocument(fileName);
					XmlProcessor processor = new XmlProcessor();

					XmlNode result = processor.Process(doc.DocumentElement);

					Assert.Fail(fileName + " should throw an exception");
				}
				catch(ConfigurationProcessingException e)
				{
					Debug.WriteLine("Expected exception:" + e.Message);
				}
			}
		}
		public void RunTests()
		{
			var files = Directory.GetFiles(GetFullPath(), "*Test.xml");
			Assert.IsNotEmpty(files);

			foreach(var fileName in files)
			{

				if (fileName.EndsWith("PropertiesWithAttributesTest.xml"))
				{
					continue;
				}

				var doc = GetXmlDocument(fileName);

				var resultFileName = fileName.Substring(0, fileName.Length - 4) + "Result.xml";

				var resultDoc = GetXmlDocument(resultFileName);

				var processor = new XmlProcessor();

				try
				{
					var result = processor.Process(doc.DocumentElement);

					var resultDocStr = StripSpaces(resultDoc.OuterXml);
					var resultStr = StripSpaces(result.OuterXml);

					// Debug.WriteLine(resultDocStr);
					// Debug.WriteLine(resultStr);

					Assert.AreEqual(resultDocStr, resultStr);
				}
				catch(Exception e)
				{
					throw new Exception("Error processing " + fileName, e);
				}
			}
		}
Ejemplo n.º 8
0
		public void RunTests()
		{
			String dirFullPath = GetFullPath();

			foreach(String fileName in Directory.GetFiles(dirFullPath, "*Test.xml"))
			{
				// Debug.WriteLine("Running " + fileName.Substring( fileName.LastIndexOf("/") + 1 ));

				if (fileName.EndsWith("PropertiesWithAttributesTest.xml"))
				{
					continue;
				}

				XmlDocument doc = GetXmlDocument(fileName);

				String resultFileName = fileName.Substring(0, fileName.Length - 4) + "Result.xml";

				XmlDocument resultDoc = GetXmlDocument(resultFileName);

				XmlProcessor processor = new XmlProcessor();

				try
				{
					XmlNode result = processor.Process(doc.DocumentElement);

					String resultDocStr = StripSpaces(resultDoc.OuterXml);
					String resultStr = StripSpaces(result.OuterXml);

					// Debug.WriteLine(resultDocStr);
					// Debug.WriteLine(resultStr);

					Assert.AreEqual(resultDocStr, resultStr);
				}
				catch(Exception e)
				{
					throw new Exception("Error processing " + fileName, e);
				}
			}
		}