From: <bo...@us...> - 2009-05-11 08:49:14
|
Revision: 312 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=312&view=rev Author: bodewig Date: 2009-05-11 08:49:05 +0000 (Mon, 11 May 2009) Log Message: ----------- Add classes corresponding to Java's Source implementations where ReaderSource corresponds to StAXSource Modified Paths: -------------- trunk/xmlunit/src/main/net-core/ISource.cs trunk/xmlunit/src/main/net-core/builder/Input.cs Added Paths: ----------- trunk/xmlunit/src/main/net-core/input/ trunk/xmlunit/src/main/net-core/input/AbstractSource.cs trunk/xmlunit/src/main/net-core/input/DOMSource.cs trunk/xmlunit/src/main/net-core/input/ReaderSource.cs trunk/xmlunit/src/main/net-core/input/StreamSource.cs Modified: trunk/xmlunit/src/main/net-core/ISource.cs =================================================================== --- trunk/xmlunit/src/main/net-core/ISource.cs 2009-05-04 15:43:53 UTC (rev 311) +++ trunk/xmlunit/src/main/net-core/ISource.cs 2009-05-11 08:49:05 UTC (rev 312) @@ -1,7 +1,4 @@ /* - Licensed to the XMLUnit developers under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. This file is licensed to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at Modified: trunk/xmlunit/src/main/net-core/builder/Input.cs =================================================================== --- trunk/xmlunit/src/main/net-core/builder/Input.cs 2009-05-04 15:43:53 UTC (rev 311) +++ trunk/xmlunit/src/main/net-core/builder/Input.cs 2009-05-11 08:49:05 UTC (rev 312) @@ -1,7 +1,4 @@ /* - Licensed to the XMLUnit developers under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. This file is licensed to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -14,22 +11,11 @@ See the License for the specific language governing permissions and limitations under the License. */ +using net.sf.xmlunit.input; using System.Xml; namespace net.sf.xmlunit.builder { public static class Input { - internal class Source : ISource { - private readonly XmlReader reader; - internal Source(XmlReader r) { - reader = r; - } - public XmlReader Reader { - get { - return reader; - } - } - } - public interface IBuilder { ISource Build(); } @@ -37,7 +23,7 @@ internal class DOMBuilder : IBuilder { private readonly ISource source; internal DOMBuilder(XmlDocument d) { - source = new Source(new XmlNodeReader(d)); + source = new DOMSource(d); } public ISource Build() { return source; Added: trunk/xmlunit/src/main/net-core/input/AbstractSource.cs =================================================================== --- trunk/xmlunit/src/main/net-core/input/AbstractSource.cs (rev 0) +++ trunk/xmlunit/src/main/net-core/input/AbstractSource.cs 2009-05-11 08:49:05 UTC (rev 312) @@ -0,0 +1,28 @@ +/* + This file is licensed to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +using System.Xml; + +namespace net.sf.xmlunit.input { + public abstract class AbstractSource : ISource { + private readonly XmlReader reader; + protected AbstractSource(XmlReader r) { + reader = r; + } + public XmlReader Reader { + get { + return reader; + } + } + } +} Added: trunk/xmlunit/src/main/net-core/input/DOMSource.cs =================================================================== --- trunk/xmlunit/src/main/net-core/input/DOMSource.cs (rev 0) +++ trunk/xmlunit/src/main/net-core/input/DOMSource.cs 2009-05-11 08:49:05 UTC (rev 312) @@ -0,0 +1,22 @@ +/* + This file is licensed to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +using System.Xml; + +namespace net.sf.xmlunit.input { + public class DOMSource : AbstractSource { + public DOMSource(XmlNode node) + : base(new XmlNodeReader(node)) { + } + } +} Added: trunk/xmlunit/src/main/net-core/input/ReaderSource.cs =================================================================== --- trunk/xmlunit/src/main/net-core/input/ReaderSource.cs (rev 0) +++ trunk/xmlunit/src/main/net-core/input/ReaderSource.cs 2009-05-11 08:49:05 UTC (rev 312) @@ -0,0 +1,22 @@ +/* + This file is licensed to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +using System.Xml; + +namespace net.sf.xmlunit.input { + public class ReaderSource : AbstractSource { + public ReaderSource(XmlReader rdr) + : base(rdr) { + } + } +} Added: trunk/xmlunit/src/main/net-core/input/StreamSource.cs =================================================================== --- trunk/xmlunit/src/main/net-core/input/StreamSource.cs (rev 0) +++ trunk/xmlunit/src/main/net-core/input/StreamSource.cs 2009-05-11 08:49:05 UTC (rev 312) @@ -0,0 +1,31 @@ +/* + This file is licensed to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +using System.IO; +using System.Xml; + +namespace net.sf.xmlunit.input { + public class StreamSource : AbstractSource { + public StreamSource(TextReader rdr) + : base(XmlReader.Create(rdr)) { + } + + public StreamSource(Stream stream) + : base(XmlReader.Create(stream)) { + } + + public StreamSource(string uri) + : base(XmlReader.Create(uri)) { + } + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bo...@us...> - 2009-05-12 10:46:57
|
Revision: 317 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=317&view=rev Author: bodewig Date: 2009-05-12 10:46:49 +0000 (Tue, 12 May 2009) Log Message: ----------- fix eol-style Modified Paths: -------------- trunk/xmlunit/src/main/net-core/ISource.cs trunk/xmlunit/src/main/net-core/builder/Input.cs trunk/xmlunit/src/main/net-core/input/AbstractSource.cs trunk/xmlunit/src/main/net-core/input/DOMSource.cs trunk/xmlunit/src/main/net-core/input/ReaderSource.cs trunk/xmlunit/src/main/net-core/input/StreamSource.cs Property Changed: ---------------- trunk/xmlunit/src/main/net-core/ISource.cs trunk/xmlunit/src/main/net-core/builder/Input.cs trunk/xmlunit/src/main/net-core/input/AbstractSource.cs trunk/xmlunit/src/main/net-core/input/DOMSource.cs trunk/xmlunit/src/main/net-core/input/ReaderSource.cs trunk/xmlunit/src/main/net-core/input/StreamSource.cs Modified: trunk/xmlunit/src/main/net-core/ISource.cs =================================================================== --- trunk/xmlunit/src/main/net-core/ISource.cs 2009-05-12 04:29:34 UTC (rev 316) +++ trunk/xmlunit/src/main/net-core/ISource.cs 2009-05-12 10:46:49 UTC (rev 317) @@ -1,20 +1,20 @@ -/* - This file is licensed to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ -using System.Xml; - -namespace net.sf.xmlunit { - public interface ISource { - XmlReader Reader {get;} - } -} +/* + This file is licensed to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +using System.Xml; + +namespace net.sf.xmlunit { + public interface ISource { + XmlReader Reader {get;} + } +} Property changes on: trunk/xmlunit/src/main/net-core/ISource.cs ___________________________________________________________________ Added: svn:eol-style + native Modified: trunk/xmlunit/src/main/net-core/builder/Input.cs =================================================================== --- trunk/xmlunit/src/main/net-core/builder/Input.cs 2009-05-12 04:29:34 UTC (rev 316) +++ trunk/xmlunit/src/main/net-core/builder/Input.cs 2009-05-12 10:46:49 UTC (rev 317) @@ -1,136 +1,136 @@ -/* - This file is licensed to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ -using System.IO; -using System.Xml; -using System.Xml.Xsl; -using net.sf.xmlunit.input; - -namespace net.sf.xmlunit.builder { - public static class Input { - public interface IBuilder { - ISource Build(); - } - - internal class DOMBuilder : IBuilder { - private readonly ISource source; - internal DOMBuilder(XmlDocument d) { - source = new DOMSource(d); - } - public ISource Build() { - return source; - } - } - - public static IBuilder FromDocument(XmlDocument d) { - return new DOMBuilder(d); - } - - internal class StreamBuilder : IBuilder { - private readonly ISource source; - internal StreamBuilder(string s) { - source = new StreamSource(s); - } - internal StreamBuilder(Stream s) { - source = new StreamSource(s); - } - internal StreamBuilder(TextReader r) { - source = new StreamSource(r); - } - public ISource Build() { - return source; - } - } - - public static IBuilder FromFile(string name) { - return new StreamBuilder(name); - } - - public static IBuilder FromStream(Stream s) { - return new StreamBuilder(s); - } - - public static IBuilder FromReader(TextReader r) { - return new StreamBuilder(r); - } - - public static IBuilder FromMemory(string s) { - return FromReader(new StringReader(s)); - } - - public static IBuilder FromMemory(byte[] b) { - return FromStream(new MemoryStream(b)); - } - - public static IBuilder FromURI(string uri) { - return new StreamBuilder(uri); - } - - public static IBuilder FromURI(System.Uri uri) { - return new StreamBuilder(uri.AbsoluteUri); - } - - public interface ITransformationBuilder : IBuilder { - ITransformationBuilder WithStylesheet(ISource s); - ITransformationBuilder WithExtensionObject(string namespaceUri, - object extension); - ITransformationBuilder WithParameter(string name, - string namespaceUri, - object parameter); - } - - internal class Transformation : ITransformationBuilder { - private readonly ISource source; - private ISource styleSheet; - private readonly XsltArgumentList args = new XsltArgumentList(); - internal Transformation(ISource s) { - source = s; - } - public ITransformationBuilder WithStylesheet(ISource s) { - this.styleSheet = styleSheet; - return this; - } - - public ITransformationBuilder WithExtensionObject(string namespaceUri, - object extension) { - args.AddExtensionObject(namespaceUri, extension); - return this; - } - - public ITransformationBuilder WithParameter(string name, - string namespaceUri, - object parameter) { - args.AddParam(name, namespaceUri, parameter); - return this; - } - - public ISource Build() { - XslCompiledTransform t = new XslCompiledTransform(); - if (styleSheet != null) { - t.Load(styleSheet.Reader); - } - MemoryStream ms = new MemoryStream(); - using (ms) { - t.Transform(source.Reader, - args, - ms); - } - return FromMemory(ms.ToArray()).Build(); - } - } - - public static ITransformationBuilder ByTransforming(ISource s) { - return new Transformation(s); - } - } -} +/* + This file is licensed to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +using System.IO; +using System.Xml; +using System.Xml.Xsl; +using net.sf.xmlunit.input; + +namespace net.sf.xmlunit.builder { + public static class Input { + public interface IBuilder { + ISource Build(); + } + + internal class DOMBuilder : IBuilder { + private readonly ISource source; + internal DOMBuilder(XmlDocument d) { + source = new DOMSource(d); + } + public ISource Build() { + return source; + } + } + + public static IBuilder FromDocument(XmlDocument d) { + return new DOMBuilder(d); + } + + internal class StreamBuilder : IBuilder { + private readonly ISource source; + internal StreamBuilder(string s) { + source = new StreamSource(s); + } + internal StreamBuilder(Stream s) { + source = new StreamSource(s); + } + internal StreamBuilder(TextReader r) { + source = new StreamSource(r); + } + public ISource Build() { + return source; + } + } + + public static IBuilder FromFile(string name) { + return new StreamBuilder(name); + } + + public static IBuilder FromStream(Stream s) { + return new StreamBuilder(s); + } + + public static IBuilder FromReader(TextReader r) { + return new StreamBuilder(r); + } + + public static IBuilder FromMemory(string s) { + return FromReader(new StringReader(s)); + } + + public static IBuilder FromMemory(byte[] b) { + return FromStream(new MemoryStream(b)); + } + + public static IBuilder FromURI(string uri) { + return new StreamBuilder(uri); + } + + public static IBuilder FromURI(System.Uri uri) { + return new StreamBuilder(uri.AbsoluteUri); + } + + public interface ITransformationBuilder : IBuilder { + ITransformationBuilder WithStylesheet(ISource s); + ITransformationBuilder WithExtensionObject(string namespaceUri, + object extension); + ITransformationBuilder WithParameter(string name, + string namespaceUri, + object parameter); + } + + internal class Transformation : ITransformationBuilder { + private readonly ISource source; + private ISource styleSheet; + private readonly XsltArgumentList args = new XsltArgumentList(); + internal Transformation(ISource s) { + source = s; + } + public ITransformationBuilder WithStylesheet(ISource s) { + this.styleSheet = styleSheet; + return this; + } + + public ITransformationBuilder WithExtensionObject(string namespaceUri, + object extension) { + args.AddExtensionObject(namespaceUri, extension); + return this; + } + + public ITransformationBuilder WithParameter(string name, + string namespaceUri, + object parameter) { + args.AddParam(name, namespaceUri, parameter); + return this; + } + + public ISource Build() { + XslCompiledTransform t = new XslCompiledTransform(); + if (styleSheet != null) { + t.Load(styleSheet.Reader); + } + MemoryStream ms = new MemoryStream(); + using (ms) { + t.Transform(source.Reader, + args, + ms); + } + return FromMemory(ms.ToArray()).Build(); + } + } + + public static ITransformationBuilder ByTransforming(ISource s) { + return new Transformation(s); + } + } +} Property changes on: trunk/xmlunit/src/main/net-core/builder/Input.cs ___________________________________________________________________ Added: svn:eol-style + native Modified: trunk/xmlunit/src/main/net-core/input/AbstractSource.cs =================================================================== --- trunk/xmlunit/src/main/net-core/input/AbstractSource.cs 2009-05-12 04:29:34 UTC (rev 316) +++ trunk/xmlunit/src/main/net-core/input/AbstractSource.cs 2009-05-12 10:46:49 UTC (rev 317) @@ -1,28 +1,28 @@ -/* - This file is licensed to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ -using System.Xml; - -namespace net.sf.xmlunit.input { - public abstract class AbstractSource : ISource { - private readonly XmlReader reader; - protected AbstractSource(XmlReader r) { - reader = r; - } - public XmlReader Reader { - get { - return reader; - } - } - } -} +/* + This file is licensed to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +using System.Xml; + +namespace net.sf.xmlunit.input { + public abstract class AbstractSource : ISource { + private readonly XmlReader reader; + protected AbstractSource(XmlReader r) { + reader = r; + } + public XmlReader Reader { + get { + return reader; + } + } + } +} Property changes on: trunk/xmlunit/src/main/net-core/input/AbstractSource.cs ___________________________________________________________________ Added: svn:eol-style + native Modified: trunk/xmlunit/src/main/net-core/input/DOMSource.cs =================================================================== --- trunk/xmlunit/src/main/net-core/input/DOMSource.cs 2009-05-12 04:29:34 UTC (rev 316) +++ trunk/xmlunit/src/main/net-core/input/DOMSource.cs 2009-05-12 10:46:49 UTC (rev 317) @@ -1,22 +1,22 @@ -/* - This file is licensed to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ -using System.Xml; - -namespace net.sf.xmlunit.input { - public class DOMSource : AbstractSource { - public DOMSource(XmlNode node) - : base(new XmlNodeReader(node)) { - } - } -} +/* + This file is licensed to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +using System.Xml; + +namespace net.sf.xmlunit.input { + public class DOMSource : AbstractSource { + public DOMSource(XmlNode node) + : base(new XmlNodeReader(node)) { + } + } +} Property changes on: trunk/xmlunit/src/main/net-core/input/DOMSource.cs ___________________________________________________________________ Added: svn:eol-style + native Modified: trunk/xmlunit/src/main/net-core/input/ReaderSource.cs =================================================================== --- trunk/xmlunit/src/main/net-core/input/ReaderSource.cs 2009-05-12 04:29:34 UTC (rev 316) +++ trunk/xmlunit/src/main/net-core/input/ReaderSource.cs 2009-05-12 10:46:49 UTC (rev 317) @@ -1,22 +1,22 @@ -/* - This file is licensed to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ -using System.Xml; - -namespace net.sf.xmlunit.input { - public class ReaderSource : AbstractSource { - public ReaderSource(XmlReader rdr) - : base(rdr) { - } - } -} +/* + This file is licensed to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +using System.Xml; + +namespace net.sf.xmlunit.input { + public class ReaderSource : AbstractSource { + public ReaderSource(XmlReader rdr) + : base(rdr) { + } + } +} Property changes on: trunk/xmlunit/src/main/net-core/input/ReaderSource.cs ___________________________________________________________________ Added: svn:eol-style + native Modified: trunk/xmlunit/src/main/net-core/input/StreamSource.cs =================================================================== --- trunk/xmlunit/src/main/net-core/input/StreamSource.cs 2009-05-12 04:29:34 UTC (rev 316) +++ trunk/xmlunit/src/main/net-core/input/StreamSource.cs 2009-05-12 10:46:49 UTC (rev 317) @@ -1,31 +1,31 @@ -/* - This file is licensed to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ -using System.IO; -using System.Xml; - -namespace net.sf.xmlunit.input { - public class StreamSource : AbstractSource { - public StreamSource(TextReader rdr) - : base(XmlReader.Create(rdr)) { - } - - public StreamSource(Stream stream) - : base(XmlReader.Create(stream)) { - } - - public StreamSource(string uri) - : base(XmlReader.Create(uri)) { - } - } -} +/* + This file is licensed to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +using System.IO; +using System.Xml; + +namespace net.sf.xmlunit.input { + public class StreamSource : AbstractSource { + public StreamSource(TextReader rdr) + : base(XmlReader.Create(rdr)) { + } + + public StreamSource(Stream stream) + : base(XmlReader.Create(stream)) { + } + + public StreamSource(string uri) + : base(XmlReader.Create(uri)) { + } + } +} Property changes on: trunk/xmlunit/src/main/net-core/input/StreamSource.cs ___________________________________________________________________ Added: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bo...@us...> - 2009-05-18 15:58:28
|
Revision: 323 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=323&view=rev Author: bodewig Date: 2009-05-18 15:58:23 +0000 (Mon, 18 May 2009) Log Message: ----------- add a base exception class Added Paths: ----------- trunk/xmlunit/src/main/net-core/exceptions/ trunk/xmlunit/src/main/net-core/exceptions/XMLUnitException.cs Copied: trunk/xmlunit/src/main/net-core/exceptions/XMLUnitException.cs (from rev 321, trunk/xmlunit/src/main/java-core/net/sf/xmlunit/exceptions/XMLUnitException.java) =================================================================== --- trunk/xmlunit/src/main/net-core/exceptions/XMLUnitException.cs (rev 0) +++ trunk/xmlunit/src/main/net-core/exceptions/XMLUnitException.cs 2009-05-18 15:58:23 UTC (rev 323) @@ -0,0 +1,47 @@ +/* + This file is licensed to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +using System; + +namespace net.sf.xmlunit.exceptions { + + /// <summary> + /// Base class of any Exception thrown within XMLUnit. + /// </summary> + public class XMLUnitException : Exception { + /// <summary> + /// Inititializes the exception. + /// </summary> + /// <param name="message">the detail message</param> + /// <param name="cause">the root cause of the exception</param> + public XMLUnitException(string message, Exception cause) : + base(message, cause) { + } + + /// <summary> + /// Inititializes an exception without cause. + /// </summary> + /// <param name="message">the detail message</param> + public XMLUnitException(string message) : + base(message, null) { + } + + ///<summary> + /// Inititializes an exception using the wrapped exception's message. + ///</summary> + /// <param name="cause">the root cause of the exception</param> + public XMLUnitException(Exception cause) : + base(cause != null ? cause.Message : null, cause) { + } + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bo...@us...> - 2009-05-25 15:42:43
|
Revision: 334 http://xmlunit.svn.sourceforge.net/xmlunit/?rev=334&view=rev Author: bodewig Date: 2009-05-25 15:42:30 +0000 (Mon, 25 May 2009) Log Message: ----------- validation infrastructure .NET style Added Paths: ----------- trunk/xmlunit/src/main/net-core/validation/ trunk/xmlunit/src/main/net-core/validation/Languages.cs trunk/xmlunit/src/main/net-core/validation/ValidationProblem.cs trunk/xmlunit/src/main/net-core/validation/ValidationResult.cs trunk/xmlunit/src/main/net-core/validation/Validator.cs Copied: trunk/xmlunit/src/main/net-core/validation/Languages.cs (from rev 333, trunk/xmlunit/src/main/java-core/net/sf/xmlunit/validation/Languages.java) =================================================================== --- trunk/xmlunit/src/main/net-core/validation/Languages.cs (rev 0) +++ trunk/xmlunit/src/main/net-core/validation/Languages.cs 2009-05-25 15:42:30 UTC (rev 334) @@ -0,0 +1,32 @@ +/* + This file is licensed to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +namespace net.sf.xmlunit.validation { + + /// <summary> + /// Constants for the languages supported by XMLUnit's schema + /// validation. + /// </summary> +public static class Languages { + + /// <summary>W3C XML Schema.</summary> + public const string W3C_XML_SCHEMA_NS_URI = + "http://www.w3.org/2001/XMLSchema"; + + /// <summary>DTD.</summary> + public const string XML_DTD_NS_URI = "http://www.w3.org/TR/REC-xml"; + + /// <summary>XDR.</summary> + public const string XDR_NS_URI = "xmlunit:validation:XDR"; +} +} Property changes on: trunk/xmlunit/src/main/net-core/validation/Languages.cs ___________________________________________________________________ Added: svn:mergeinfo + Added: svn:eol-style + native Copied: trunk/xmlunit/src/main/net-core/validation/ValidationProblem.cs (from rev 333, trunk/xmlunit/src/main/java-core/net/sf/xmlunit/validation/ValidationProblem.java) =================================================================== --- trunk/xmlunit/src/main/net-core/validation/ValidationProblem.cs (rev 0) +++ trunk/xmlunit/src/main/net-core/validation/ValidationProblem.cs 2009-05-25 15:42:30 UTC (rev 334) @@ -0,0 +1,72 @@ +/* + This file is licensed to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +using System.Xml.Schema; + +namespace net.sf.xmlunit.validation { + + /// <summary> + /// A validation "problem" which may be an error or a warning. + /// </summary> +public class ValidationProblem { + public const int UNKNOWN = -1; + + private readonly int line, column; + private readonly XmlSeverityType type; + private readonly string message; + + public ValidationProblem(string message, int line, int column, + XmlSeverityType type) { + this.message = message; + this.line = line; + this.column = column; + this.type = type; + } + + /// <summary> + /// The line where the problem occured or UNKNOWN. + /// </summary> + public int Line { + get { + return line; + } + } + + /// <summary> + /// The column where the problem occured or UNKNOWN. + /// </summary> + public int Column { + get { + return column; + } + } + + /// <summary> + /// Whether this is an error or a warning. + /// </summary> + public XmlSeverityType Type { + get { + return type; + } + } + + /// <summary> + /// The problem's message. + /// </summary> + public string Message { + get { + return message; + } + } +} +} Property changes on: trunk/xmlunit/src/main/net-core/validation/ValidationProblem.cs ___________________________________________________________________ Added: svn:mergeinfo + Added: svn:eol-style + native Copied: trunk/xmlunit/src/main/net-core/validation/ValidationResult.cs (from rev 333, trunk/xmlunit/src/main/java-core/net/sf/xmlunit/validation/ValidationResult.java) =================================================================== --- trunk/xmlunit/src/main/net-core/validation/ValidationResult.cs (rev 0) +++ trunk/xmlunit/src/main/net-core/validation/ValidationResult.cs 2009-05-25 15:42:30 UTC (rev 334) @@ -0,0 +1,50 @@ +/* + This file is licensed to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +using System.Collections.Generic; + +namespace net.sf.xmlunit.validation { + + /// <summary> + /// The result of a validation. + /// </summary> +public class ValidationResult { + private readonly bool valid; + private readonly IEnumerable<ValidationProblem> problems; + + public ValidationResult(bool valid, IEnumerable<ValidationProblem> problems) { + this.valid = valid; + this.problems = problems; + } + + /// <summary> + /// Has the validation been successful? + /// </summary> + public bool Valid { + get { + return valid; + } + } + + /// <summary> + /// Retrieves the problems that have been found. + /// </summary> + public IEnumerable<ValidationProblem> Problems { + get { + return problems; + } + } +} +} + Property changes on: trunk/xmlunit/src/main/net-core/validation/ValidationResult.cs ___________________________________________________________________ Added: svn:mergeinfo + Added: svn:eol-style + native Copied: trunk/xmlunit/src/main/net-core/validation/Validator.cs (from rev 333, trunk/xmlunit/src/main/java-core/net/sf/xmlunit/validation/Validator.java) =================================================================== --- trunk/xmlunit/src/main/net-core/validation/Validator.cs (rev 0) +++ trunk/xmlunit/src/main/net-core/validation/Validator.cs 2009-05-25 15:42:30 UTC (rev 334) @@ -0,0 +1,108 @@ +/* + This file is licensed to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +using System; +using System.Collections.Generic; +using System.Xml; + +namespace net.sf.xmlunit.validation { + + /// <summary> + /// Validates a piece of XML against a schema given in a supported + /// language or the defintion of such a schema itself. + /// </summary> +public class Validator { + private readonly ValidationType language; + private string schemaURI; + private ISource[] sourceLocations; + + private Validator(ValidationType language) { + this.language = language; + } + + /// <summary> + /// The URI (or for example the System ID in case of a DTD) that + /// identifies the schema to validate or use during validation. + /// </summary> + public virtual string SchemaURI { + set { + schemaURI = value; + } + get { + return schemaURI; + } + } + + /// <summary> + /// Where to find the schema. + /// </summary> + public virtual ISource[] SchemaSources { + set { + if (value != null) { + sourceLocations = new ISource[value.Length]; + Array.Copy(value, 0, sourceLocations, 0, value.Length); + } else { + sourceLocations = null; + } + } + get { + return sourceLocations; + } + } + + /// <summary> + /// Where to find the schema. + /// </summary> + public ISource SchemaSource { + set { + SchemaSources = value == null ? null : new ISource[] {value}; + } + } + + /// <summary> + /// Validates a schema. + /// </summary> + public virtual ValidationResult ValidateSchema() { + throw new NotImplementedException(); + } + + /// <summary> + /// Validates an instance against the schema. + /// </summary> + public virtual ValidationResult ValidateInstance(ISource instance) { + throw new NotImplementedException(); + } + + + private static readonly IDictionary<string, ValidationType> types; + + static Validator() { + types = new Dictionary<string, ValidationType>(); + types[Languages.W3C_XML_SCHEMA_NS_URI] = ValidationType.Schema; + types[Languages.XML_DTD_NS_URI] = ValidationType.DTD; + types[Languages.XDR_NS_URI] = ValidationType.XDR; + } + + /// <summary> + /// Factory that obtains a Validator instance based on the schema language. + /// </summary> + public static Validator ForLanguage(string language) { + ValidationType t; + if (types.TryGetValue(language, out t)) { + return new Validator(t); + } + // TODO pick a better exception type + throw new NotImplementedException(); + } +} +} Property changes on: trunk/xmlunit/src/main/net-core/validation/Validator.cs ___________________________________________________________________ Added: svn:mergeinfo + Added: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bo...@us...> - 2014-11-28 20:49:59
|
Revision: 551 http://sourceforge.net/p/xmlunit/code/551 Author: bodewig Date: 2014-11-28 20:49:57 +0000 (Fri, 28 Nov 2014) Log Message: ----------- More .NET 3.5 changes Modified Paths: -------------- trunk/xmlunit/src/main/net-core/diff/DifferenceEvaluators.cs trunk/xmlunit/src/main/net-core/diff/ElementSelectors.cs trunk/xmlunit/src/main/net-core/util/Linqy.cs Modified: trunk/xmlunit/src/main/net-core/diff/DifferenceEvaluators.cs =================================================================== --- trunk/xmlunit/src/main/net-core/diff/DifferenceEvaluators.cs 2014-11-28 20:49:33 UTC (rev 550) +++ trunk/xmlunit/src/main/net-core/diff/DifferenceEvaluators.cs 2014-11-28 20:49:57 UTC (rev 551) @@ -12,7 +12,9 @@ limitations under the License. */ +using System.Linq; using System.Xml; +using net.sf.xmlunit.util; namespace net.sf.xmlunit.diff { @@ -90,7 +92,7 @@ /// the documents in a similar state.</param> public static DifferenceEvaluator StopWhenDifferent(DifferenceEvaluator nestedEvaluator) { - return delegate(Comparison comparison, ComparisonResult outcome) { + return (comparison, outcome) => { ComparisonResult r = nestedEvaluator(comparison, outcome); return r == ComparisonResult.DIFFERENT ? ComparisonResult.CRITICAL : r; @@ -103,15 +105,12 @@ /// </summary> public static DifferenceEvaluator First(params DifferenceEvaluator[] evaluators) { - return delegate(Comparison comparison, ComparisonResult orig) { - foreach (DifferenceEvaluator ev in evaluators) { - ComparisonResult evaluated = ev(comparison, orig); - if (evaluated != orig) { - return evaluated; - } - } - return orig; - }; + return (comparison, orig) => + Linqy + .FirstOrDefaultValue(evaluators + .Select(ev => ev(comparison, orig)), + evaluated => evaluated != orig, + orig); } } } \ No newline at end of file Modified: trunk/xmlunit/src/main/net-core/diff/ElementSelectors.cs =================================================================== --- trunk/xmlunit/src/main/net-core/diff/ElementSelectors.cs 2014-11-28 20:49:33 UTC (rev 550) +++ trunk/xmlunit/src/main/net-core/diff/ElementSelectors.cs 2014-11-28 20:49:57 UTC (rev 551) @@ -14,6 +14,7 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Xml; using net.sf.xmlunit.util; @@ -72,11 +73,9 @@ if (attribs == null) { throw new ArgumentNullException("attribs"); } - XmlQualifiedName[] qs = new XmlQualifiedName[attribs.Length]; - for (int i = 0; i < attribs.Length; i++) { - qs[i] = new XmlQualifiedName(attribs[i]); - } - return ByNameAndAttributes(qs); + return ByNameAndAttributes(attribs + .Select(a => new XmlQualifiedName(a)) + .ToArray()); } /// <summary> @@ -91,14 +90,11 @@ } XmlQualifiedName[] qs = new XmlQualifiedName[attribs.Length]; Array.Copy(attribs, 0, qs, 0, qs.Length); - return delegate(XmlElement controlElement, XmlElement testElement) { - if (!ByName(controlElement, testElement)) { - return false; - } - return MapsEqualForKeys(Nodes.GetAttributes(controlElement), - Nodes.GetAttributes(testElement), - qs); - }; + return (controlElement, testElement) => + ByName(controlElement, testElement) && + MapsEqualForKeys(Nodes.GetAttributes(controlElement), + Nodes.GetAttributes(testElement), + qs); } /// <summary> @@ -117,7 +113,7 @@ throw new ArgumentNullException("attribs"); } List<string> ats = new List<string>(attribs); - return delegate(XmlElement controlElement, XmlElement testElement) { + return (controlElement, testElement) => { if (!ByName(controlElement, testElement)) { return false; } @@ -243,16 +239,11 @@ MapsEqualForKeys(IDictionary<XmlQualifiedName, string> control, IDictionary<XmlQualifiedName, string> test, IEnumerable<XmlQualifiedName> keys) { - foreach (XmlQualifiedName q in keys) { + return !keys.Any(q => { string c, t; - if (control.TryGetValue(q, out c) != test.TryGetValue(q, out t)) { - return false; - } - if (!BothNullOrEqual(c, t)) { - return false; - } - } - return true; + return control.TryGetValue(q, out c) != test.TryGetValue(q, out t) + || !BothNullOrEqual(c, t); + }); } private static bool IsText(XmlNode n) { Modified: trunk/xmlunit/src/main/net-core/util/Linqy.cs =================================================================== --- trunk/xmlunit/src/main/net-core/util/Linqy.cs 2014-11-28 20:49:33 UTC (rev 550) +++ trunk/xmlunit/src/main/net-core/util/Linqy.cs 2014-11-28 20:49:57 UTC (rev 551) @@ -12,6 +12,8 @@ limitations under the License. */ +using System; +using System.Linq; using System.Collections.Generic; namespace net.sf.xmlunit.util { @@ -27,5 +29,28 @@ yield return t; } + /// <summary> + /// Like Enumerable.FirstOrDefault but with a configurable default value. + /// </summary> + public static T FirstOrDefault<T>(IEnumerable<T> enumerable, + Func<T, bool> predicate, + T defaultValue) + where T : class { + return enumerable.FirstOrDefault(predicate) ?? defaultValue; + } + + /// <summary> + /// Like Enumerable.FirstOrDefault but with a configurable default value. + /// </summary> + public static T FirstOrDefaultValue<T>(IEnumerable<T> enumerable, + Func<T, bool> predicate, + T defaultValue) + where T : struct { + return enumerable.SkipWhile(t => !predicate(t)) + .Take(1) + .DefaultIfEmpty(defaultValue) + .Single(); + } + } } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |