You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(174) |
Nov
(85) |
Dec
(14) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(56) |
Feb
|
Mar
|
Apr
|
May
(4) |
Jun
(1) |
Jul
(132) |
Aug
(5) |
Sep
|
Oct
(314) |
Nov
(133) |
Dec
(18) |
2006 |
Jan
(6) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Oleg T. <he...@us...> - 2005-11-02 13:21:51
|
Update of /cvsroot/mvp-xml/WebSite/common In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1958/common Modified Files: index.html Log Message: Index: index.html =================================================================== RCS file: /cvsroot/mvp-xml/WebSite/common/index.html,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- index.html 15 Jan 2005 14:41:42 -0000 1.5 +++ index.html 2 Nov 2005 13:21:26 -0000 1.6 @@ -8,14 +8,15 @@ <h1><a href="../index.html">Mvp.Xml Project</a>: Common module<br> </h1> The Common module includes a set of commonly useful classes in <span - style="font-family: monospace;">Mvp.Xml.Common</span> -and <span style="font-family: monospace;">Mvp.Xml.Common.XPath</span> + style="font-family: monospace;">Mvp.Xml.Common,</span> +<span style="font-family: monospace;">Mvp.Xml.Common.XPath</span> and <span style="font-family: Courier New"> + Mvp.Xml.Common.Xsl </span> namespaces, which extend the .NET functionality available through the <a target="_blank" href="http://msdn.microsoft.com/library/en-us/cpref/html/frlrfsystemxml.asp"> System.Xml</a> and related namespaces.<br> <br> -The following is a list of features, a short explanation and a link to +The following is a list of key features, a short explanation and a link to its corresponding full explanation:<br> <br> <span style="font-family: monospace; font-weight: bold;">Mvp.Xml.Common</span> @@ -58,14 +59,6 @@ instances from <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemXmlXPathXPathNodeIteratorClassTopic.asp">XPathNodeIterator</a> objects. </li> - <li><a - href="file:///%20See:%20http://www.tkachenko.com/blog/archives/000112.html">XmlTransformingReader</a>: -XmlReader, transforming input XML stream according to given XSLT -stylesheet.</li> - <li><a href="Mvp.Xml.Common.XmlParsedWriter.html">XmlParsedWriter</a>: -writes XML to a memory buffer that can be retrieved as a pre-parsed <a - href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemXmlXmlReaderClassTopic.asp">XmlReader</a> -for fast processing. </li> </ul> <p><span style="font-family: monospace; font-weight: bold;">Mvp.Xml.Common.Serialization</span> namespace:<br> @@ -99,11 +92,11 @@ for scenarios involving queries with sort expressions. </li> <li> <a target="_blank" href="http://www.tkachenko.com/blog/archives/000194.html">IndexingXPathNavigator</a>: -allows the use of the XSLT key function to create indexes for fast +allows the use of the XSLT key() function to create indexes for fast querying. Very handy for query intensive applications that need to repeatedly look for elements and matches. It yields an amazing 10 x performance improvement at a minimum. </li> - <li> <a target="_blank" + <li> <span style="color: #ff3366">(v1.X only)</span> <a target="_blank" href="http://weblogs.asp.net/cazzu/archive/2004/04/19/115966.aspx">XPathNavigatorReader</a>: implements an <a target="_blank" href="http://msdn.microsoft.com/library/en-us/cpref/html/frlrfsystemxmlxmltextreaderclasstopic.asp"> @@ -122,7 +115,7 @@ href="http://msdn.microsoft.com/library/en-us/cpref/html/frlrfsystemxmlserializationixmlserializableclasstopic.asp"> IXmlSerializable</a> interface. Of course you can also use just to query for the XML string representation from an arbitrary navigator ;).</li> - <li> <a target="_blank" + <li> <span style="color: #ff3366">(v1.X only) </span><a target="_blank" href="http://www.tkachenko.com/blog/archives/000117.html">XmlNodeNavigator</a>: the <a target="_blank" href="http://msdn.microsoft.com/library/en-us/cpref/html/frlrfsystemxmlxmlnodeclasstopic.asp"> @@ -157,7 +150,21 @@ the <a target="_blank" href="http://weblogs.asp.net/cazzu/archive/2004/05/31/144922.aspx"> XmlNodeFactory</a>.</li> + <li><span style="color: #ff3366">(since v2.0) </span>EmptyXPathNodeIterator: Empty XPathNodeIterator, + used to represent empty node sequence.</li> + <li><span style="color: #ff3366">(since v2.0) <span style="color: #000000">SingletonXPathNodeIterator: + XPathNodeIterator over a single node.</span></span></li> </ul> + <p> + <strong><span style="font-family: Courier New">Mvp.Xml.Common.Xsl</span></strong> + namespace:</p> + <ul> + <li><span style="color: #ff3366"><span style="color: #000000"><span style="color: #ff3366"> + (since v2.0) </span>XslReader: allows to obtain XSLT output as XmlReader in .NET + 2.0. XslReader can work in either fully buffering or concurrent mode, is very + efficient and fast. Contributed by Sergey Dubinets from the <a href="http://blogs.msdn.com/xmlteam"> + Microsoft XML Team</a>.</span></span></li> + </ul> <hr style="width: 100%; height: 2px;"> <p> The project is hosted at <a target="_blank" href="http://www.sourceforge.net"> |
From: Oleg T. <he...@us...> - 2005-11-02 13:21:51
|
Update of /cvsroot/mvp-xml/WebSite In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1958 Modified Files: index.html Log Message: Index: index.html =================================================================== RCS file: /cvsroot/mvp-xml/WebSite/index.html,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- index.html 19 Jul 2005 21:17:57 -0000 1.12 +++ index.html 2 Nov 2005 13:21:27 -0000 1.13 @@ -39,11 +39,8 @@ </p> <ul> <li><a href="common/index.html">Common</a> module</li> - <li><a href="xinclude/index.html">XInclude.NET</a> module<br> - </li> - <li><a href="xpointer/index.html">XPointer.NET</a> module</li> - <li><a href="exslt/index.html">EXSLT.NET</a> module<br> - </li> + <li><a href="exslt/index.html">EXSLT.NET</a> module</li> + <li><a href="xinclude/index.html">XInclude.NET</a> module</li><li><a href="xpointer/index.html">XPointer.NET</a> module</li> </ul> <h2><a class="mozTocH2" name="mozTocId421746"></a>2. News</h2> Mvp.Xml News: <a @@ -71,7 +68,9 @@ (general discussion list for Mvp.Xml users), <a href="http://sourceforge.net/mailarchive/forum.php?forum=mvp-xml-help">(online archive)</a>.</li> - <li>Tracker: <a + <li><a href="http://www.xmllab.net/Forum/tabid/70/Default.aspx">Mvp.Xml Forums</a> at + the <a href="http://www.xmllab.net/">XML Lab</a>.</li> + <li>Tracker: <a href="http://sourceforge.net/tracker/?group_id=102352&atid=633328">Bugs</a>.</li> <li>Tracker: <a href="http://sourceforge.net/tracker/?group_id=102352&atid=633331">Feature @@ -89,8 +88,7 @@ in one archive) or releases for separate modules.<br> <h2><a class="mozTocH2" name="mozTocId620586"></a>5. License</h2> -The Mvp.Xml library is a subject to the <a href="license.html">Common -Public License</a> - <a +The Mvp.Xml library is a subject to the <a href="license.html">BSD License</a> - <a href="http://www.opensource.org/licenses/index.php">OSI approved</a> free open-source license.<br> <br> |
From: Oleg T. <he...@us...> - 2005-11-02 13:21:51
|
Update of /cvsroot/mvp-xml/WebSite/xpointer In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1958/xpointer Modified Files: index.html Log Message: Index: index.html =================================================================== RCS file: /cvsroot/mvp-xml/WebSite/xpointer/index.html,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- index.html 17 Jan 2005 07:55:42 -0000 1.5 +++ index.html 2 Nov 2005 13:21:27 -0000 1.6 @@ -22,26 +22,18 @@ module</a>, but it can be used on its own.<br> <h2>Requirements</h2> -<p>XPointer.NET module as well as a whole Mvp.Xml library is .NET -Framework application and requires <a - href="http://msdn.microsoft.com/netframework/" target="_top"> .NET -Framework</a> version 1.0 or 1.1 to be installed. -</p> +<p> + XInclude.NET module as well as a whole Mvp.Xml library is .NET +Framework application and requires <a href="http://msdn.microsoft.com/netframework/" target="_top">.NET Framework</a> + version 1.X or 2.0 to be installed.</p> <h2>Download</h2> -Go to the <a - href="http://sourceforge.net/project/showfiles.php?group_id=102352">Downloads</a> -page. You can download XPointer.NET module separately (with no -dependencies on other modules) or as part of the Mvp.Xml library -release (all modules in one). -<h2>Installation and Documentation</h2> -<p>Find precompiled <font style="font-family: monospace;" - face="Courier New">Mvp.Xml.XPointer.dll</font> (or <span - style="font-family: monospace;">Mvp.Xml.dll</span> if you've -downloaded full Mvp.Xml library) library in the "<font - style="font-family: monospace;" face="Courier New">bin</font>" -directiory. The "<font style="font-family: monospace;" - face="Courier New">src</font>" directory contains XPointer.NET sources -in Visual Studio .NET 2003 solution form. The documentation can be +Go to the <a href="http://sourceforge.net/project/showfiles.php?group_id=102352">Downloads</a> +page. XPointer.NET module is a part of the Mvp.Xml library release.<h2>Installation and Documentation</h2> +<p>Find precompiled <span style="font-family: monospace">Mvp.Xml.dll</span> assembly + in the "<font face="Courier New" style="font-family: monospace">bin</font>" +directiory. The "<font face="Courier New" style="font-family: monospace">src</font>" directory contains XPointer.NET sources +in Visual Studio .NET 2003 (XPointer/src/v1) and Visual Studio + 2005 (XPointer/src/v2) solution form. The documentation can be found in the "<span style="font-family: monospace;">doc</span>" directory (<a href="http://mvp-xml.sourceforge.net/xpointer/index.html">online version</a>). Samples and test @@ -69,7 +61,11 @@ xpointer() Scheme</a></li> </ul> <h2>History</h2> -Done since 1.2 release:<br> +Done in 2.0 release:<br /> + <ul> + <li>The codebase has been ported to .NET 2.0. </li> + </ul> + Done since 1.2 release:<br> <ul> <li>The new home - <a href="http://mvp-xml.sf.net/">Mvp.Xml project</a> and so the new namespace - <a @@ -194,31 +190,27 @@ XPointer xpointer() Scheme</a> is currently supported. </li> </ol> <h2>License</h2> -<p>XPointer.NET as part of the <a href="http://mvp-xml.sf.net/">Mvp.Xml -project</a> is subject to the <a href="../license.html">Common -Public License</a> - <a - href="http://www.opensource.org/licenses/index.php">OSI approved</a> +<p>XPointer.NET as part of the <a href="http://mvp-xml.sf.net/">Mvp.Xml project</a> + is subject to the <a href="../license.html">GPL License</a> - <a href="http://www.opensource.org/licenses/index.php"> + OSI approved</a> free open-source license. -It's distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR -CONDITIONS OF ANY -KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY -WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR -FITNESS FOR A PARTICULAR PURPOSE.</p> -<h2>Bug reports</h2> -<p>Please feel free to report any bugs to the Mvp.Xml project's <a - href="http://sourceforge.net/tracker/?group_id=102352&atid=633328"> -Bug Tracker</a>. Feature requests are also <a - href="http://sourceforge.net/tracker/?group_id=102352&atid=633331">welcome</a>.<br> -</p> -<h2>Feedback</h2> -<p>We appreciate any kind of feedback, feel free to post any questions -or comments about XPointer.NET and Mvp.Xml project in general in -the <a - href="https://lists.sourceforge.net/mailman/listinfo/mvp-xml-help">mvp-xml-help</a> -mailing list <a - href="http://sourceforge.net/mailarchive/forum.php?forum=mvp-xml-help">(online -archive)</a>.<br> </p> +<h2> + Support</h2> + <p> + You can get support on using XInclude.NET module using the following options:</p> + <ul> + <li><a href="http://www.xmllab.net/Forum/tabid/70/Default.aspx">XInclude.NET/XPointer.NET + Forum</a> at the <a href="http://www.xmllab.net/">XML Lab</a> </li> + <li>Mailing list: <a href="https://lists.sourceforge.net/mailman/listinfo/mvp-xml-help"> + mvp-xml-help</a> (general discussion list for Mvp.Xml users), <a href="http://sourceforge.net/mailarchive/forum.php?forum=mvp-xml-help"> + (online +archive)</a>. </li> + <li>Please feel free to report any bugs to the Mvp.Xml project's <a href="http://sourceforge.net/tracker/?group_id=102352&atid=633328"> +Bug Tracker</a>. </li> + <li>Feature requests are also <a href="http://sourceforge.net/tracker/?group_id=102352&atid=633331"> + welcome</a>.</li> + </ul> <hr style="width: 100%; height: 2px;"> <p> The project is hosted at <a target="_blank" href="http://www.sourceforge.net"> |
From: Oleg T. <he...@us...> - 2005-11-02 13:21:51
|
Update of /cvsroot/mvp-xml/WebSite/xinclude In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1958/xinclude Modified Files: index.html Log Message: Index: index.html =================================================================== RCS file: /cvsroot/mvp-xml/WebSite/xinclude/index.html,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- index.html 20 Jul 2005 20:53:29 -0000 1.7 +++ index.html 2 Nov 2005 13:21:27 -0000 1.8 @@ -29,8 +29,8 @@ <p>XInclude.NET has been thoroughly tested against <a href="http://www.w3.org/XML/Test/XInclude/">XML Inclusions (XInclude) Version 1.0, W3C Conformance Test Suite (2004-11-03)</a> under -Microsoft .NET 1.0 and 1.1 on Windows 2000 and Windows Server 2003.<br> -</p> +Microsoft .NET 1.0, 1.1 + and 2.0 on Windows 2000, Windows XP and Windows Server 2003.</p> <p style="font-weight: bold;">Contents:</p> <ol> <li><a href="#mozTocId537061">Requirements</a></li> @@ -43,31 +43,28 @@ <li><a href="#mozTocId893216">XPointer</a></li> <li><a href="#mozTocId299036">Conformance Issues </a></li> <li><a href="#mozTocId670936">License</a></li> - <li><a href="#mozTocId666501">Bug reports</a></li> - <li><a href="#mozTocId594662">Feedback</a></li> + <li><a href="#mozTocId666501">Support</a></li> </ol> <h2><a class="mozTocH2" name="mozTocId537061"></a>1. Requirements</h2> <p>XInclude.NET module as well as a whole Mvp.Xml library is .NET Framework application and requires <a href="http://msdn.microsoft.com/netframework/" target="_top"> .NET -Framework</a> version 1.0 or 1.1 to be installed.<br> +Framework</a> version 1.X or 2.0 to be installed.<br> </p> <h2><a class="mozTocH2" name="mozTocId172804"></a>2. Download</h2> Go to the <a href="http://sourceforge.net/project/showfiles.php?group_id=102352">Downloads</a> -page. You can download XInclude.NET module separately (with no -dependencies on other modules) or as part of the Mvp.Xml library -release (all modules in one dll).<br> +page. + XInclude.NET module is a part of the Mvp.Xml library release.<br> <h2><a class="mozTocH2" name="mozTocId593736"></a>3. Installation and Documentation</h2> -<p>Find precompiled <font style="font-family: monospace;" - face="Courier New">Mvp.Xml.XInclude.dll</font> (or <span - style="font-family: monospace;">Mvp.Xml.dll</span> if you've -downloaded full Mvp.Xml library) library in the "<font +<p>Find precompiled <span + style="font-family: monospace;">Mvp.Xml.dll</span> assembly + in the "<font style="font-family: monospace;" face="Courier New">bin</font>" directiory. The "<font style="font-family: monospace;" face="Courier New">src</font>" directory contains XInclude.NET sources -in Visual Studio .NET 2003 solution form. The documentation can be +in Visual Studio .NET 2003 (XInclude/src/v1) and Visual Studio 2005 (XInclude/src/v2) solution form. The documentation can be found in the "<span style="font-family: monospace;">doc</span>" directory (<a href="http://mvp-xml.sourceforge.net/xinclude/index.html">online version</a>). Test cases can be @@ -97,7 +94,14 @@ xpointer() Scheme</a></li> </ul> <h2><a class="mozTocH2" name="mozTocId209347"></a>4. History</h2> -Done since 1.2 release:<br> +Done in 2.0 release:<br /> + <ul> + <li>The codebase has been ported to .NET 2.0.</li> + <li>A <a href="http://sourceforge.net/tracker/index.php?func=detail&aid=1236851&group_id=102352&atid=633328"> + bug</a> with custom XmlResolver has been fixed.</li> + </ul> + <br /> + Done since 1.2 release:<br> <ul> <li>The new home - <a href="http://mvp-xml.sf.net/">Mvp.Xml project</a> and so the new namespace - <a href="../api/Mvp.Xml.XInclude.html"><span @@ -170,7 +174,7 @@ <pre>XmlReader reader = new XIncludingReader("source.xml");<br>while (reader.Read()) {<br> ... <br> </pre> <p>XML inclusion while building <span style="font-family: monospace;">XmlDocument</span>:</p> <p><code></code></p> -<pre>XmlReader reader = new XIncludingReader(new XmlTextReader("source.xml"));<br>XmlDocument doc = new XmlDocument(); <br>doc.Load(reader);<br>... <br> </pre> +<pre>XmlReader reader = new XIncludingReader(XmlReader.Create("source.xml"));<br>XmlDocument doc = new XmlDocument(); <br>doc.Load(reader);<br>... <br> </pre> <p>XML inclusion before an XSL Transformation:</p> <p><code></code></p> <pre>XslTransform xslt = new XslTransform();<br>xslt.Load("stylesheet.xsl");<br>XmlReader reader = new XIncludingReader("source.xml");<br>XPathDocument xdoc = new XPathDocument(reader);<br>xslt.Transform(xdoc, null, new StreamWriter("result.xml"));<br>...</pre> @@ -256,30 +260,27 @@ </ol> <h2><a class="mozTocH2" name="mozTocId670936"></a>9. License</h2> <p>XInclude.NET as part of the <a href="http://mvp-xml.sf.net/">Mvp.Xml -project</a> is subject to the <a href="../license.html">Common -Public License</a> - <a +project</a> is subject to the <a href="../license.html">GPL License</a> - <a href="http://www.opensource.org/licenses/index.php">OSI approved</a> free open-source license. -It's distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR -CONDITIONS OF ANY -KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY -WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR -FITNESS FOR A PARTICULAR PURPOSE.</p> -<h2><a class="mozTocH2" name="mozTocId666501"></a>10. Bug reports</h2> -<p>Please feel free to report any bugs to the Mvp.Xml project's <a +</p> +<h2><a class="mozTocH2" name="mozTocId666501"></a>10. Support</h2> +<p> + You can get support on using XInclude.NET module using the following options:</p> + <ul> + <li><a href="http://www.xmllab.net/Forum/tabid/70/Default.aspx">XInclude.NET Forum</a> + at the <a href="http://www.xmllab.net/">XML Lab</a></li> + <li>Mailing list: <a href="https://lists.sourceforge.net/mailman/listinfo/mvp-xml-help"> + mvp-xml-help</a> (general discussion list for Mvp.Xml users), <a href="http://sourceforge.net/mailarchive/forum.php?forum=mvp-xml-help"> + (online +archive)</a>. </li> + <li>Please feel free to report any bugs to the Mvp.Xml project's <a href="http://sourceforge.net/tracker/?group_id=102352&atid=633328"> -Bug Tracker</a>. Feature requests are also <a +Bug Tracker</a>. </li> + <li>Feature requests are also <a href="http://sourceforge.net/tracker/?group_id=102352&atid=633331">welcome</a>.<br> -</p> -<h2><a class="mozTocH2" name="mozTocId594662"></a>11. Feedback</h2> -<p>We appreciate any kind of feedback, feel free to post any questions -or comments about XInclude.NET module and Mvp.Xml project in general in -the <a - href="https://lists.sourceforge.net/mailman/listinfo/mvp-xml-help">mvp-xml-help</a> -mailing list <a - href="http://sourceforge.net/mailarchive/forum.php?forum=mvp-xml-help">(online -archive)</a>. -</p> + </li> + </ul> <hr style="width: 100%; height: 2px;"> <p> The project is hosted at <a target="_blank" href="http://www.sourceforge.net"> |
From: Oleg T. <he...@us...> - 2005-11-02 13:21:50
|
Update of /cvsroot/mvp-xml/WebSite/exslt In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1958/exslt Modified Files: index.html Log Message: Index: index.html =================================================================== RCS file: /cvsroot/mvp-xml/WebSite/exslt/index.html,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- index.html 19 Jul 2005 20:58:40 -0000 1.1 +++ index.html 2 Nov 2005 13:21:27 -0000 1.2 @@ -33,28 +33,24 @@ </li> <li> <a href="#multiout">Multiple Output</a> </li> <li> <a href="#credits">License</a></li> - <li><a href="#bugs">Bug Reports</a></li> - <li><a href="#feedback">Feedback</a><br> - </li> + <li><a href="#bugs">Support</a></li> <li> <a href="#refs">References</a></li> </ol> <h2>1<a name="new">. What's New In This Version</a></h2> -<p>Since version 1.3 EXSLT.NET is a module of the <a - href="http://mvp-xml.sf.net">Mvp.Xml library</a>. The only change done -during codebase transition is new namespace: <font face="Courier New">Mvp.Xml.Exslt</font> -instead of <font face="Courier New"> GotDotnet.Exslt</font>. Note -that XML namespace of proprietary EXSLT.NET -extention functions remains unchanged and still starts with "<a - href="http://gotdotnet.com/exslt">http://gotdotnet.com/exslt</a>".</p> +<p> + Version 2.0 is the first EXSLT.NET release for the .NET 2.0 Framework. What's new + in this version:</p> + <ul> + <li>EXSLT.NET now works with new .NET 2.0 XSLT processor - XslCompiledTransform class</li> + <li>Performance improvements</li> + </ul> <h2>2<a name="install">. Installation</a></h2> <p>EXSLT.NET is designed as a component for .NET Framework and actually -doesn't require any installation. You can use <font face="Courier New">Mvp.Xml.Exslt.dll</font> +doesn't require any installation. You can use <font face="Courier New">Mvp.Xml.dll</font> assembly as is in your application by referencing it in Visual Studio -.NET. If you want to install the dll into the GAC, run <font - face="Courier New">Exslt\install.cmd</font> script. To uninstall the -dll, run <font face="Courier New">Exslt\uninstall.cmd</font> script.</p> +.NET.</p> <h2>3<a name="build">. Building</a></h2> -<p>EXSLT.NET source distribution contains Visual Studio .NET 2003 +<p>EXSLT.NET source distribution contains Visual Studio solution, consisting of four projects: <font face="Courier New">Exslt</font>, which is the core EXSLT.NET implementation, <font face="Courier New">ExsltTest</font> - a collection of NUnit tests for each EXSLT.NET function along with @@ -73,7 +69,7 @@ face="Courier New">date-time()</font>) and assemble it back.</p> <p>You can also build EXSLT.NET in command line using provided <font face="Courier New"> Makefile</font> files. To build any of EXSLT.NET -projects, run command prompt (use Visual Studio .NET 2003 Command +projects, run command prompt (use Visual Studio Command Prompt or make sure <font face="Courier New"> csc.exe</font>, <font face="Courier New">ildasm.exe</font> and <font face="Courier New">ilasm.exe</font> are in your PATH), change directory to a project directory and run @@ -82,9 +78,10 @@ <p>Typically you are using EXSLT.NET module in your application via <code><font face="Courier New"> Mvp.Xml</font>.Exslt.ExsltTransform</code> class, which encapsulates EXSLT implementation under the guise of -standard <code>XslTransform</code> class (<code>ExsltTransform</code> -class completely duplicates <code>XslTransform</code> API from -.NET 1.0 you are familiar with). So the rules of the <code>ExsltTransform</code> +standard <code>XslCompiledTransform</code> class (<code>ExsltTransform</code> +class completely duplicates <code>XslCompiledTransform</code> API from +.NET 2.0 + you are familiar with). So the rules of the <code>ExsltTransform</code> usage are simple: just use it instead of standard <code>XslTransform</code> class:</p> <pre class="code">using System;<br>using System.Xml.XPath;<br>using <font @@ -177,31 +174,26 @@ href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnexxml/html/xml06162003.asp"> "Producing Multiple Outputs from an XSL Transformation"</a> article.</p> <h2>7<a name="credits">. License</a></h2> -<p>EXSLT.NET as part of the <a href="http://mvp-xml.sf.net/">Mvp.Xml -project</a> is subject to the <a href="../license.html">Common Public -License</a> - <a href="http://www.opensource.org/licenses/index.php"> -OSI approved</a> free open-source license. It's distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER -EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR -CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A -PARTICULAR PURPOSE.<br> -</p> -<h2><a class="mozTocH2" name="bugs"></a>8. Bug reports</h2> -<p>Please feel free to report any bugs to the Mvp.Xml project's <a - href="http://sourceforge.net/tracker/?group_id=102352&atid=633328"> -Bug Tracker</a>. Feature requests are also <a - href="http://sourceforge.net/tracker/?group_id=102352&atid=633331">welcome</a>.<br> -</p> -<h2><a class="mozTocH2" name="feedback"></a>9. Feedback</h2> -<p>We appreciate any kind of feedback, feel free to post any questions -or comments about EXSLT.NET module and Mvp.Xml project in general in -the <a - href="https://lists.sourceforge.net/mailman/listinfo/mvp-xml-help">mvp-xml-help</a> -mailing list <a - href="http://sourceforge.net/mailarchive/forum.php?forum=mvp-xml-help">(online -archive)</a>.<br> +<p>EXSLT.NET as part of the <a href="http://mvp-xml.sf.net/">Mvp.Xml project</a> is subject to the <a href="../license.html">GPL License</a> - <a href="http://www.opensource.org/licenses/index.php"> +OSI approved</a> free open-source license. <br> </p> -<h2>10<a name="refs">. References</a></h2> +<h2><a class="mozTocH2" name="bugs"></a>8. Support</h2> + <p> + You can get support on using XInclude.NET module using the following options:</p> + <ul> + <li><a href="http://www.xmllab.net/Forum/tabid/70/Default.aspx">EXSLT.NET Forum</a> + at the <a href="http://www.xmllab.net/">XML Lab</a> </li> + <li>Mailing list: <a href="https://lists.sourceforge.net/mailman/listinfo/mvp-xml-help"> + mvp-xml-help</a> (general discussion list for Mvp.Xml users), <a href="http://sourceforge.net/mailarchive/forum.php?forum=mvp-xml-help"> + (online +archive)</a>. </li> + <li>Please feel free to report any bugs to the Mvp.Xml project's <a href="http://sourceforge.net/tracker/?group_id=102352&atid=633328"> +Bug Tracker</a>. </li> + <li>Feature requests are also <a href="http://sourceforge.net/tracker/?group_id=102352&atid=633331"> + welcome</a>.</li> + </ul> +<h2> + 9<a name="refs">. References</a></h2> <ol> <li><!--StartFragment --> EXSLT community initiative - <a href="http://www.exslt.org/"> http://www.exslt.org</a>. </li> @@ -218,8 +210,6 @@ href="http://www.xmllab.net/Products/nxslt/tabid/62/Default.aspx">nxslt.exe</a> - EXSLT.NET enabled command line XSLT utility.</li> </ol> -<p><br> -</p> <hr style="width: 100%; height: 2px;"> <p> The project is hosted at <a target="_blank" href="http://www.sourceforge.net"> |
From: Daniel C. \(kzu\) <dca...@us...> - 2005-11-01 06:44:50
|
Update of /cvsroot/mvp-xml/Design/v2/src/CustomTools/XGen In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11928/v2/src/CustomTools/XGen Modified Files: XmlSerializerGenerator.cs Log Message: Generated code does not produce more compiler warnings (had to resort to pragmas :S) Index: XmlSerializerGenerator.cs =================================================================== RCS file: /cvsroot/mvp-xml/Design/v2/src/CustomTools/XGen/XmlSerializerGenerator.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- XmlSerializerGenerator.cs 31 Oct 2005 12:28:17 -0000 1.3 +++ XmlSerializerGenerator.cs 1 Nov 2005 06:44:41 -0000 1.4 @@ -272,7 +272,10 @@ output = NestTypesOnSerialier(output, rootObject); output = FixInstantiationOfNestedTypes(output, rootObject); - output = "\r\n#pragma warning disable 0642, 0219\r\n" + output + "\r\n#pragma warning restore 0642, 0219"; + output = @" +#pragma warning disable 0642, 0219 +" + output + @" +#pragma warning restore 0642, 0219"; output = CustomTool.GetToolGeneratedCodeWarning(typeof(XGenTool)) + output; |
From: Daniel C. \(kzu\) <dca...@us...> - 2005-11-01 06:44:50
|
Update of /cvsroot/mvp-xml/Design/v2/src/CustomTools/XsdToClasses In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11928/v2/src/CustomTools/XsdToClasses Modified Files: XsdCodeGenerator.cs Log Message: Generated code does not produce more compiler warnings (had to resort to pragmas :S) Index: XsdCodeGenerator.cs =================================================================== RCS file: /cvsroot/mvp-xml/Design/v2/src/CustomTools/XsdToClasses/XsdCodeGenerator.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- XsdCodeGenerator.cs 31 Oct 2005 11:15:24 -0000 1.2 +++ XsdCodeGenerator.cs 1 Nov 2005 06:44:41 -0000 1.3 @@ -36,7 +36,16 @@ protected override string OnGenerateCode(string inputFileName, string inputFileContent) { CodeNamespace ns = ExportCode(); - return GenerateSource(ns); + string output = GenerateSource(ns); + + // Workaround for known bug with fixed attributes: http://lab.msdn.microsoft.com/productfeedback/viewfeedback.aspx?feedbackid=d457a36e-0ce8-4368-9a27-92762860d8e1 + output = @"// Workaround for bug http://lab.msdn.microsoft.com/productfeedback/viewfeedback.aspx?feedbackid=d457a36e-0ce8-4368-9a27-92762860d8e1 +#pragma warning disable 1591 +" + output + @" +#pragma warning restore 1591"; + output = CustomTool.GetToolGeneratedCodeWarning(typeof(XsdCodeGenerator)) + output; + + return output; } private string GenerateSource(CodeNamespace ns) |
From: Daniel C. \(kzu\) <dca...@us...> - 2005-10-31 12:28:33
|
Update of /cvsroot/mvp-xml/Design/v2/src/CustomTools/XGen In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32177/v2/src/CustomTools/XGen Modified Files: XGenRunner.cs XGenTool.cs XmlSerializerGenerator.cs Log Message: Updated for multiple types. Index: XGenRunner.cs =================================================================== RCS file: /cvsroot/mvp-xml/Design/v2/src/CustomTools/XGen/XGenRunner.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- XGenRunner.cs 31 Oct 2005 09:31:24 -0000 1.1 +++ XGenRunner.cs 31 Oct 2005 12:28:17 -0000 1.2 @@ -11,12 +11,18 @@ /// <summary> /// Generates the code for the received type. /// </summary> - public XGenRunner(string outputFile, string forType, string targetNamespace) + public XGenRunner(string outputFile, string[] forTypes, string targetNamespace) { using (StreamWriter writer = new StreamWriter(outputFile)) { + Type[] types = new Type[forTypes.Length]; + for (int i = 0; i < forTypes.Length; i++) + { + types[i] = Type.GetType(forTypes[i], true); + } + writer.Write(XmlSerializerGenerator.GenerateCode( - Type.GetType(forType, true), targetNamespace)); + types, targetNamespace)); } } } Index: XGenTool.cs =================================================================== RCS file: /cvsroot/mvp-xml/Design/v2/src/CustomTools/XGen/XGenTool.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- XGenTool.cs 31 Oct 2005 11:49:18 -0000 1.4 +++ XGenTool.cs 31 Oct 2005 12:28:17 -0000 1.5 @@ -105,16 +105,29 @@ appSetup.ApplicationBase = outputPath; appSetup.ConfigurationFile = ConfigFile; - foreach (Selection selection in selections) - { - GetSerializationCode(appSetup, output, selection); - } + string[] targetTypes = GetTypesFromSelection(selections); + + GetSerializationCode(appSetup, output, targetTypes); + + DeleteDesignFromOutput(outputPath); SaveSelections(selections); return output.ToString(); } + private string[] GetTypesFromSelection(SelectionCollection selections) + { + string assemblyName = CurrentItem.ContainingProject.Properties.Item("AssemblyName").Value.ToString(); + string[] types = new string[selections.Count]; + for (int i = 0; i < selections.Count; i++) + { + types[i] = selections[i].ClassName + ", " + assemblyName; + } + + return types; + } + private void SaveSelections(SelectionCollection selections) { string key = BuildItemKey(CurrentItem); @@ -122,7 +135,7 @@ CurrentItem.ContainingProject.Globals.set_VariablePersists(key, true); } - private void GetSerializationCode(AppDomainSetup appSetup, StringBuilder output, Selection selection) + private void GetSerializationCode(AppDomainSetup appSetup, StringBuilder output, string[] targetTypes) { string codefile = Path.GetTempFileName(); AppDomain domain = AppDomain.CreateDomain(appSetup.ApplicationName, null, appSetup); @@ -134,9 +147,8 @@ typeof(XGenRunner).FullName, false, 0, null, new object[] { codefile, - selection.ClassName + ", " + - CurrentItem.ContainingProject.Properties.Item("AssemblyName").Value.ToString(), - selection.TargetNamespace }, + targetTypes, + base.FileNameSpace }, null, null, null); using (StreamReader reader = new StreamReader(codefile)) @@ -193,6 +205,20 @@ } } + private void DeleteDesignFromOutput(string outputPath) + { + string asmfile = GetAssemblyPath(Assembly.GetExecutingAssembly()); + try + { + File.Delete(Path.Combine(outputPath, Path.GetFileName(asmfile))); + } + catch (Exception ex) + { + // May already exist, be locked, etc. + System.Diagnostics.Debug.WriteLine(ex.ToString()); + } + } + private void ThrowIfNoClassFound() { if (CurrentItem.FileCodeModel == null || CurrentItem.FileCodeModel.CodeElements == null) Index: XmlSerializerGenerator.cs =================================================================== RCS file: /cvsroot/mvp-xml/Design/v2/src/CustomTools/XGen/XmlSerializerGenerator.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- XmlSerializerGenerator.cs 31 Oct 2005 11:49:18 -0000 1.2 +++ XmlSerializerGenerator.cs 31 Oct 2005 12:28:17 -0000 1.3 @@ -6,6 +6,7 @@ using System.Reflection; using System.Text.RegularExpressions; using System.Xml.Serialization; +using System.Text; namespace Mvp.Xml.Design.CustomTools.XGen { @@ -224,7 +225,19 @@ #region Private helper methods - public static string GenerateCode(Type type, string targetNamespace) + public static string GenerateCode(Type[] types, string targetNamespace) + { + string output = String.Empty; + + foreach (Type type in types) + { + output += GenerateCodeForType(type, targetNamespace, output); + } + + return output; + } + + private static string GenerateCodeForType(Type type, string targetNamespace, string previousOutput) { string output = GetXmlSerializerOutput(type); @@ -244,7 +257,7 @@ output = AppendReaderWriterMembersToObjectSerializer(type, output, rootObject); - CodeTypeDeclaration readerDeclaration = CreateAndAddEventRisingReader(targetNamespace, output, ns, rootObject); + CodeTypeDeclaration readerDeclaration = CreateAndAddEventRisingReader(targetNamespace, ns, rootObject, output, previousOutput); output = PrivateReadMethodsToProtectedVirtual(output); CodeTypeDeclaration writerDeclaration = CreateAndAddTypedWriter(targetNamespace, ns, rootObject); @@ -273,7 +286,6 @@ #else return output; #endif - //"\r\n#pragma warning disable 0642, 0219\r\n" + endlines.ToString() + "#pragma warning restore 0642, 0219"; } private static string MakeSerializerPartial(string output, string rootObject) @@ -371,7 +383,7 @@ return output; } - private static CodeTypeDeclaration CreateAndAddTypedWriter(string targetNamespace, System.CodeDom.CodeNamespace ns, string rootObject) + private static CodeTypeDeclaration CreateAndAddTypedWriter(string targetNamespace, CodeNamespace ns, string rootObject) { CodeTypeDeclaration writerDeclaration = new CodeTypeDeclaration(rootObject + "Writer"); writerDeclaration.BaseTypes.Add(rootObject + "Serializer.BaseWriter"); @@ -381,7 +393,8 @@ return writerDeclaration; } - private static CodeTypeDeclaration CreateAndAddEventRisingReader(string targetNamespace, string output, System.CodeDom.CodeNamespace ns, string rootObject) + private static CodeTypeDeclaration CreateAndAddEventRisingReader(string targetNamespace, CodeNamespace ns, + string rootObject, string output, string previousOutput) { CodeTypeDeclaration readerDeclaration = new CodeTypeDeclaration(rootObject + "Reader"); readerDeclaration.BaseTypes.Add(rootObject + "Serializer.BaseReader"); @@ -401,21 +414,25 @@ continue; } - // Create a delegate for the event to expose. - // public delegate void [objectBeingRead]DeserializedHandler(Mvp.Xml.Design.Tests.Customer customer); - CodeTypeDelegate del = new CodeTypeDelegate(objectBeingRead + "DeserializedHandler"); - del.Parameters.Add(new CodeParameterDeclarationExpression( - readMethodMatch.Groups[ReadMethodReturnType].Value, - MakeFirstLower(objectBeingRead))); - del.Comments.Add(new CodeCommentStatement("/// <remarks/>", true)); - ns.Types.Add(del); + string delegateName = objectBeingRead + "DeserializedHandler"; + if (!previousOutput.Contains(delegateName)) + { + // Create a delegate for the event to expose. + // public delegate void [objectBeingRead]DeserializedHandler(Mvp.Xml.Design.Tests.Customer customer); + CodeTypeDelegate del = new CodeTypeDelegate(delegateName); + del.Parameters.Add(new CodeParameterDeclarationExpression( + readMethodMatch.Groups[ReadMethodReturnType].Value, + MakeFirstLower(objectBeingRead))); + del.Comments.Add(new CodeCommentStatement("/// <remarks/>", true)); + ns.Types.Add(del); + } // Expose event. // public event [objectBeingRead]DeserializedHandler [objectBeingRead]Deserialized; CodeMemberEvent ev = new CodeMemberEvent(); ev.Name = objectBeingRead + "Deserialized"; ev.Attributes = MemberAttributes.Public; - ev.Type = new CodeTypeReference(del.Name); + ev.Type = new CodeTypeReference(delegateName); ev.Comments.Add(new CodeCommentStatement("/// <remarks/>", true)); readerDeclaration.Members.Add(ev); @@ -424,7 +441,7 @@ TemplateMethodOverride, readMethodMatch.Groups[ReadMethodReturnType].Value, readMethodMatch.Groups[ReadMethodName].Value, - del.Name, + delegateName, ev.Name, readMethodMatch.Groups[ReadMethodArguments].Value, // Arguments contain type + parameter name. Remove type for method call. |
From: Daniel C. \(kzu\) <dca...@us...> - 2005-10-31 12:28:33
|
Update of /cvsroot/mvp-xml/Design/v2/tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32177/v2/tests Modified Files: CustomerSchema.Serialization.cs Mvp.Xml.Design.Tests.csproj Log Message: Updated for multiple types. Index: CustomerSchema.Serialization.cs =================================================================== RCS file: /cvsroot/mvp-xml/Design/v2/tests/CustomerSchema.Serialization.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- CustomerSchema.Serialization.cs 31 Oct 2005 11:49:18 -0000 1.2 +++ CustomerSchema.Serialization.cs 31 Oct 2005 12:28:17 -0000 1.3 @@ -402,4 +402,307 @@ } +#pragma warning restore 0642, 0219//------------------------------------------------------------------------------ +// <autogenerated> +// This code was generated by the Mvp.Xml.XGen tool. +// Tool Version: 1.1.1.0 +// Runtime Version: 2.0.50727.42 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// </autogenerated> +//------------------------------------------------------------------------------ + +#pragma warning disable 0642, 0219 +namespace CustomerSchemaSerialization +{ + using System.Xml.Serialization; + using System; + + + /// /// <summary>Custom reader for CustomerSchemaOrders instances.</summary> + internal class CustomerSchemaOrdersReader : CustomerSchemaOrdersSerializer.BaseReader + { + + + /// <remarks/> + protected override global::Mvp.Xml.Design.Tests.CustomerSchemaOrders Read2_CustomerSchemaOrders(bool isNullable, bool checkType) + { + global::Mvp.Xml.Design.Tests.CustomerSchemaOrders obj = base.Read2_CustomerSchemaOrders(isNullable, checkType); + CustomerSchemaOrdersDeserializedHandler handler = CustomerSchemaOrdersDeserialized; + if (handler != null) + handler(obj); + + return obj; + } + + /// <summary>Reads an object of type Mvp.Xml.Design.Tests.CustomerSchemaOrders.</summary> + internal Mvp.Xml.Design.Tests.CustomerSchemaOrders Read() + { + return (Mvp.Xml.Design.Tests.CustomerSchemaOrders) Read3_CustomerSchemaOrders(); + } + + /// /// <remarks/> + public event CustomerSchemaOrdersDeserializedHandler CustomerSchemaOrdersDeserialized; + } + + /// /// <summary>Custom writer for CustomerSchemaOrders instances.</summary> + internal class CustomerSchemaOrdersWriter : CustomerSchemaOrdersSerializer.BaseWriter + { + + + /// <summary>Writes an object of type Mvp.Xml.Design.Tests.CustomerSchemaOrders.</summary> + internal void Write(Mvp.Xml.Design.Tests.CustomerSchemaOrders value) + { + Write3_CustomerSchemaOrders(value); + } + } +} +#if _DYNAMIC_XMLSERIALIZER_COMPILATION +[assembly:System.Security.AllowPartiallyTrustedCallers()] +[assembly:System.Security.SecurityTransparent()] +#endif + +namespace CustomerSchemaSerialization { + + internal partial class CustomerSchemaOrdersSerializer { + internal class BaseWriter : System.Xml.Serialization.XmlSerializationWriter { + + protected internal void Write3_CustomerSchemaOrders(object o) { + WriteStartDocument(); + if (o == null) { + WriteNullTagLiteral(@"CustomerSchemaOrders", @""); + return; + } + TopLevelElement(); + Write2_CustomerSchemaOrders(@"CustomerSchemaOrders", @"", ((global::Mvp.Xml.Design.Tests.CustomerSchemaOrders)o), true, false); + } + + void Write2_CustomerSchemaOrders(string n, string ns, global::Mvp.Xml.Design.Tests.CustomerSchemaOrders o, bool isNullable, bool needType) { + if ((object)o == null) { + if (isNullable) WriteNullTagLiteral(n, ns); + return; + } + if (!needType) { + System.Type t = o.GetType(); + if (t == typeof(global::Mvp.Xml.Design.Tests.CustomerSchemaOrders)) { + } + else { + throw CreateUnknownTypeException(o); + } + } + WriteStartElement(n, ns, o, false, null); + if (needType) WriteXsiType(null, @""); + WriteElementStringRaw(@"Date", @"", FromDateTime(((global::System.DateTime)o.@Date))); + WriteEndElement(o); + } + + protected override void InitCallbacks() { + } + } + } + + internal partial class CustomerSchemaOrdersSerializer { + internal class BaseReader : System.Xml.Serialization.XmlSerializationReader { + + protected internal object Read3_CustomerSchemaOrders() { + object o = null; + Reader.MoveToContent(); + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { + if (((object) Reader.LocalName == (object)id1_CustomerSchemaOrders && (object) Reader.NamespaceURI == (object)id2_Item)) { + o = Read2_CustomerSchemaOrders(true, true); + } + else { + throw CreateUnknownNodeException(); + } + } + else { + UnknownNode(null, @":CustomerSchemaOrders"); + } + return (object)o; + } + + /// <remarks/> + protected virtual global::Mvp.Xml.Design.Tests.CustomerSchemaOrders Read2_CustomerSchemaOrders(bool isNullable, bool checkType) { + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + bool isNull = false; + if (isNullable) isNull = ReadNull(); + if (checkType) { + if (xsiType == null || ((object) ((System.Xml.XmlQualifiedName)xsiType).Name == (object)id2_Item && (object) ((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)id2_Item)) { + } + else + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); + } + if (isNull) return null; + global::Mvp.Xml.Design.Tests.CustomerSchemaOrders o; + o = new global::Mvp.Xml.Design.Tests.CustomerSchemaOrders(); + bool[] paramsRead = new bool[1]; + while (Reader.MoveToNextAttribute()) { + if (!IsXmlnsAttribute(Reader.Name)) { + UnknownNode((object)o); + } + } + Reader.MoveToElement(); + if (Reader.IsEmptyElement) { + Reader.Skip(); + return o; + } + Reader.ReadStartElement(); + Reader.MoveToContent(); + int whileIterations0 = 0; + int readerCount0 = ReaderCount; + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { + if (!paramsRead[0] && ((object) Reader.LocalName == (object)id3_Date && (object) Reader.NamespaceURI == (object)id2_Item)) { + { + o.@Date = ToDateTime(Reader.ReadElementString()); + } + paramsRead[0] = true; + } + else { + UnknownNode((object)o, @":Date"); + } + } + else { + UnknownNode((object)o, @":Date"); + } + Reader.MoveToContent(); + CheckReaderCount(ref whileIterations0, ref readerCount0); + } + ReadEndElement(); + return o; + } + + protected override void InitCallbacks() { + } + + string id1_CustomerSchemaOrders; + string id3_Date; + string id2_Item; + + protected override void InitIDs() { + id1_CustomerSchemaOrders = Reader.NameTable.Add(@"CustomerSchemaOrders"); + id3_Date = Reader.NameTable.Add(@"Date"); + id2_Item = Reader.NameTable.Add(@""); + } + } + } + + internal abstract class CustomerSchemaOrdersSerializerBase : System.Xml.Serialization.XmlSerializer { + protected override System.Xml.Serialization.XmlSerializationReader CreateReader() { + return new CustomerSchemaOrdersSerializer.BaseReader(); + } + protected override System.Xml.Serialization.XmlSerializationWriter CreateWriter() { + return new CustomerSchemaOrdersSerializer.BaseWriter(); + } + } + + internal sealed partial class CustomerSchemaOrdersSerializer : CustomerSchemaOrdersSerializerBase { + + CustomerSchemaOrdersReader _reader; + CustomerSchemaOrdersWriter _writer; + + /// <summary>Constructs the serializer.</summary> + public CustomerSchemaOrdersSerializer() + { + } + + /// <summary>Constructs the serializer with a pre-built reader.</summary> + public CustomerSchemaOrdersSerializer(CustomerSchemaOrdersReader reader) + { + _reader = reader; + } + + /// <summary>Constructs the serializer with a pre-built writer.</summary> + public CustomerSchemaOrdersSerializer(CustomerSchemaOrdersWriter writer) + { + _writer = writer; + } + + /// <summary>Constructs the serializer with pre-built reader and writer.</summary> + public CustomerSchemaOrdersSerializer(CustomerSchemaOrdersReader reader, CustomerSchemaOrdersWriter writer) + { + _reader = reader; + _writer = writer; + } + + /// <remarks/> + protected override System.Xml.Serialization.XmlSerializationReader CreateReader() + { + if (_reader != null) return _reader; + + return base.CreateReader(); + } + + /// <remarks/> + protected override System.Xml.Serialization.XmlSerializationWriter CreateWriter() + { + if (_writer != null) return _writer; + + return base.CreateWriter(); + } + + public override System.Boolean CanDeserialize(System.Xml.XmlReader xmlReader) { + return xmlReader.IsStartElement(@"CustomerSchemaOrders", @""); + } + + protected override void Serialize(object objectToSerialize, System.Xml.Serialization.XmlSerializationWriter writer) { + ((BaseWriter)writer).Write3_CustomerSchemaOrders(objectToSerialize); + } + + protected override object Deserialize(System.Xml.Serialization.XmlSerializationReader reader) { + return ((BaseReader)reader).Read3_CustomerSchemaOrders(); + } + } + + internal partial class CustomerSchemaOrdersSerializer { + internal class XmlSerializerContract : global::System.Xml.Serialization.XmlSerializerImplementation { + public override global::System.Xml.Serialization.XmlSerializationReader Reader { get { return new CustomerSchemaOrdersSerializer.BaseReader(); } } + public override global::System.Xml.Serialization.XmlSerializationWriter Writer { get { return new CustomerSchemaOrdersSerializer.BaseWriter(); } } + System.Collections.Hashtable readMethods = null; + public override System.Collections.Hashtable ReadMethods { + get { + if (readMethods == null) { + System.Collections.Hashtable _tmp = new System.Collections.Hashtable(); + _tmp[@"Mvp.Xml.Design.Tests.CustomerSchemaOrders::"] = @"Read3_CustomerSchemaOrders"; + if (readMethods == null) readMethods = _tmp; + } + return readMethods; + } + } + System.Collections.Hashtable writeMethods = null; + public override System.Collections.Hashtable WriteMethods { + get { + if (writeMethods == null) { + System.Collections.Hashtable _tmp = new System.Collections.Hashtable(); + _tmp[@"Mvp.Xml.Design.Tests.CustomerSchemaOrders::"] = @"Write3_CustomerSchemaOrders"; + if (writeMethods == null) writeMethods = _tmp; + } + return writeMethods; + } + } + System.Collections.Hashtable typedSerializers = null; + public override System.Collections.Hashtable TypedSerializers { + get { + if (typedSerializers == null) { + System.Collections.Hashtable _tmp = new System.Collections.Hashtable(); + _tmp.Add(@"Mvp.Xml.Design.Tests.CustomerSchemaOrders::", new CustomerSchemaOrdersSerializer()); + if (typedSerializers == null) typedSerializers = _tmp; + } + return typedSerializers; + } + } + public override System.Boolean CanSerialize(System.Type type) { + if (type == typeof(global::Mvp.Xml.Design.Tests.CustomerSchemaOrders)) return true; + return false; + } + public override System.Xml.Serialization.XmlSerializer GetSerializer(System.Type type) { + if (type == typeof(global::Mvp.Xml.Design.Tests.CustomerSchemaOrders)) return new CustomerSchemaOrdersSerializer(); + return null; + } + } + } +} + + #pragma warning restore 0642, 0219 Index: Mvp.Xml.Design.Tests.csproj =================================================================== RCS file: /cvsroot/mvp-xml/Design/v2/tests/Mvp.Xml.Design.Tests.csproj,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- Mvp.Xml.Design.Tests.csproj 31 Oct 2005 11:49:18 -0000 1.2 +++ Mvp.Xml.Design.Tests.csproj 31 Oct 2005 12:28:17 -0000 1.3 @@ -123,7 +123,7 @@ </PropertyGroup> <ProjectExtensions> <VisualStudio> - <UserProperties Mvp__Xml__Design__Tests___CustomerSchema__xsd___CustomerSchema__cs="Mvp.Xml.Design.Tests.CustomerSchema;CustomerSchemaSerialization" Mvp__Xml__Design__Tests___Customer__cs="Mvp.Xml.Design.Tests.Customer;Mvp.Xml.Design.Tests" /> + <UserProperties Mvp__Xml__Design__Tests___CustomerSchema__xsd___CustomerSchema__cs="Mvp.Xml.Design.Tests.CustomerSchema;CustomerSchemaSerialization|Mvp.Xml.Design.Tests.CustomerSchemaOrders;CustomerSchemaSerialization" Mvp__Xml__Design__Tests___Customer__cs="Mvp.Xml.Design.Tests.Customer;Mvp.Xml.Design.Tests" /> </VisualStudio> </ProjectExtensions> </Project> \ No newline at end of file |
From: Daniel C. \(kzu\) <dca...@us...> - 2005-10-31 11:49:34
|
Update of /cvsroot/mvp-xml/Design/v2/tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24252/v2/tests Modified Files: CustomerSchema.Serialization.cs Mvp.Xml.Design.Tests.csproj Log Message: Fixed replacement of code. Index: CustomerSchema.Serialization.cs =================================================================== RCS file: /cvsroot/mvp-xml/Design/v2/tests/CustomerSchema.Serialization.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- CustomerSchema.Serialization.cs 31 Oct 2005 09:31:24 -0000 1.1 +++ CustomerSchema.Serialization.cs 31 Oct 2005 11:49:18 -0000 1.2 @@ -1 +1,405 @@ -// Containing project \ No newline at end of file +//------------------------------------------------------------------------------ +// <autogenerated> +// This code was generated by the Mvp.Xml.XGen tool. +// Tool Version: 1.1.1.0 +// Runtime Version: 2.0.50727.42 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// </autogenerated> +//------------------------------------------------------------------------------ + +#pragma warning disable 0642, 0219 +namespace CustomerSchemaSerialization +{ + using System.Xml.Serialization; + using System; + + + /// /// <summary>Custom reader for CustomerSchema instances.</summary> + internal class CustomerSchemaReader : CustomerSchemaSerializer.BaseReader + { + + + /// <remarks/> + protected override global::Mvp.Xml.Design.Tests.CustomerSchema Read3_CustomerSchema(bool isNullable, bool checkType) + { + global::Mvp.Xml.Design.Tests.CustomerSchema obj = base.Read3_CustomerSchema(isNullable, checkType); + CustomerSchemaDeserializedHandler handler = CustomerSchemaDeserialized; + if (handler != null) + handler(obj); + + return obj; + } + + /// <remarks/> + protected override global::Mvp.Xml.Design.Tests.CustomerSchemaOrders Read2_CustomerSchemaOrders(bool isNullable, bool checkType) + { + global::Mvp.Xml.Design.Tests.CustomerSchemaOrders obj = base.Read2_CustomerSchemaOrders(isNullable, checkType); + CustomerSchemaOrdersDeserializedHandler handler = CustomerSchemaOrdersDeserialized; + if (handler != null) + handler(obj); + + return obj; + } + + /// <summary>Reads an object of type Mvp.Xml.Design.Tests.CustomerSchema.</summary> + internal Mvp.Xml.Design.Tests.CustomerSchema Read() + { + return (Mvp.Xml.Design.Tests.CustomerSchema) Read4_CustomerSchema(); + } + + /// /// <remarks/> + public event CustomerSchemaDeserializedHandler CustomerSchemaDeserialized; + + /// /// <remarks/> + public event CustomerSchemaOrdersDeserializedHandler CustomerSchemaOrdersDeserialized; + } + + /// /// <remarks/> + public delegate void CustomerSchemaDeserializedHandler(global::Mvp.Xml.Design.Tests.CustomerSchema customerSchema); + + /// /// <remarks/> + public delegate void CustomerSchemaOrdersDeserializedHandler(global::Mvp.Xml.Design.Tests.CustomerSchemaOrders customerSchemaOrders); + + /// /// <summary>Custom writer for CustomerSchema instances.</summary> + internal class CustomerSchemaWriter : CustomerSchemaSerializer.BaseWriter + { + + + /// <summary>Writes an object of type Mvp.Xml.Design.Tests.CustomerSchema.</summary> + internal void Write(Mvp.Xml.Design.Tests.CustomerSchema value) + { + Write4_CustomerSchema(value); + } + } +} +#if _DYNAMIC_XMLSERIALIZER_COMPILATION +[assembly:System.Security.AllowPartiallyTrustedCallers()] +[assembly:System.Security.SecurityTransparent()] +#endif + +namespace CustomerSchemaSerialization { + + internal partial class CustomerSchemaSerializer { + internal class BaseWriter : System.Xml.Serialization.XmlSerializationWriter { + + protected internal void Write4_CustomerSchema(object o) { + WriteStartDocument(); + if (o == null) { + WriteEmptyTag(@"CustomerSchema", @"http://tempuri.org/CustomerSchema.xsd"); + return; + } + TopLevelElement(); + Write3_CustomerSchema(@"CustomerSchema", @"http://tempuri.org/CustomerSchema.xsd", ((global::Mvp.Xml.Design.Tests.CustomerSchema)o), false, false); + } + + void Write3_CustomerSchema(string n, string ns, global::Mvp.Xml.Design.Tests.CustomerSchema o, bool isNullable, bool needType) { + if ((object)o == null) { + if (isNullable) WriteNullTagLiteral(n, ns); + return; + } + if (!needType) { + System.Type t = o.GetType(); + if (t == typeof(global::Mvp.Xml.Design.Tests.CustomerSchema)) { + } + else { + throw CreateUnknownTypeException(o); + } + } + WriteStartElement(n, ns, o, false, null); + if (needType) WriteXsiType(null, @"http://tempuri.org/CustomerSchema.xsd"); + WriteElementString(@"Name", @"http://tempuri.org/CustomerSchema.xsd", ((global::System.String)o.@Name)); + Write2_CustomerSchemaOrders(@"Orders", @"http://tempuri.org/CustomerSchema.xsd", ((global::Mvp.Xml.Design.Tests.CustomerSchemaOrders)o.@Orders), false, false); + WriteEndElement(o); + } + + void Write2_CustomerSchemaOrders(string n, string ns, global::Mvp.Xml.Design.Tests.CustomerSchemaOrders o, bool isNullable, bool needType) { + if ((object)o == null) { + if (isNullable) WriteNullTagLiteral(n, ns); + return; + } + if (!needType) { + System.Type t = o.GetType(); + if (t == typeof(global::Mvp.Xml.Design.Tests.CustomerSchemaOrders)) { + } + else { + throw CreateUnknownTypeException(o); + } + } + WriteStartElement(n, ns, o, false, null); + if (needType) WriteXsiType(null, @"http://tempuri.org/CustomerSchema.xsd"); + WriteElementStringRaw(@"Date", @"http://tempuri.org/CustomerSchema.xsd", FromDateTime(((global::System.DateTime)o.@Date))); + WriteEndElement(o); + } + + protected override void InitCallbacks() { + } + } + } + + internal partial class CustomerSchemaSerializer { + internal class BaseReader : System.Xml.Serialization.XmlSerializationReader { + + protected internal object Read4_CustomerSchema() { + object o = null; + Reader.MoveToContent(); + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { + if (((object) Reader.LocalName == (object)id1_CustomerSchema && (object) Reader.NamespaceURI == (object)id2_Item)) { + o = Read3_CustomerSchema(false, true); + } + else { + throw CreateUnknownNodeException(); + } + } + else { + UnknownNode(null, @"http://tempuri.org/CustomerSchema.xsd:CustomerSchema"); + } + return (object)o; + } + + /// <remarks/> + protected virtual global::Mvp.Xml.Design.Tests.CustomerSchema Read3_CustomerSchema(bool isNullable, bool checkType) { + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + bool isNull = false; + if (isNullable) isNull = ReadNull(); + if (checkType) { + if (xsiType == null || ((object) ((System.Xml.XmlQualifiedName)xsiType).Name == (object)id3_Item && (object) ((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)id2_Item)) { + } + else + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); + } + if (isNull) return null; + global::Mvp.Xml.Design.Tests.CustomerSchema o; + o = new global::Mvp.Xml.Design.Tests.CustomerSchema(); + bool[] paramsRead = new bool[2]; + while (Reader.MoveToNextAttribute()) { + if (!IsXmlnsAttribute(Reader.Name)) { + UnknownNode((object)o); + } + } + Reader.MoveToElement(); + if (Reader.IsEmptyElement) { + Reader.Skip(); + return o; + } + Reader.ReadStartElement(); + Reader.MoveToContent(); + int whileIterations0 = 0; + int readerCount0 = ReaderCount; + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { + if (!paramsRead[0] && ((object) Reader.LocalName == (object)id4_Name && (object) Reader.NamespaceURI == (object)id2_Item)) { + { + o.@Name = Reader.ReadElementString(); + } + paramsRead[0] = true; + } + else if (!paramsRead[1] && ((object) Reader.LocalName == (object)id5_Orders && (object) Reader.NamespaceURI == (object)id2_Item)) { + o.@Orders = Read2_CustomerSchemaOrders(false, true); + paramsRead[1] = true; + } + else { + UnknownNode((object)o, @"http://tempuri.org/CustomerSchema.xsd:Name, http://tempuri.org/CustomerSchema.xsd:Orders"); + } + } + else { + UnknownNode((object)o, @"http://tempuri.org/CustomerSchema.xsd:Name, http://tempuri.org/CustomerSchema.xsd:Orders"); + } + Reader.MoveToContent(); + CheckReaderCount(ref whileIterations0, ref readerCount0); + } + ReadEndElement(); + return o; + } + + /// <remarks/> + protected virtual global::Mvp.Xml.Design.Tests.CustomerSchemaOrders Read2_CustomerSchemaOrders(bool isNullable, bool checkType) { + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + bool isNull = false; + if (isNullable) isNull = ReadNull(); + if (checkType) { + if (xsiType == null || ((object) ((System.Xml.XmlQualifiedName)xsiType).Name == (object)id3_Item && (object) ((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)id2_Item)) { + } + else + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); + } + if (isNull) return null; + global::Mvp.Xml.Design.Tests.CustomerSchemaOrders o; + o = new global::Mvp.Xml.Design.Tests.CustomerSchemaOrders(); + bool[] paramsRead = new bool[1]; + while (Reader.MoveToNextAttribute()) { + if (!IsXmlnsAttribute(Reader.Name)) { + UnknownNode((object)o); + } + } + Reader.MoveToElement(); + if (Reader.IsEmptyElement) { + Reader.Skip(); + return o; + } + Reader.ReadStartElement(); + Reader.MoveToContent(); + int whileIterations1 = 0; + int readerCount1 = ReaderCount; + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { + if (!paramsRead[0] && ((object) Reader.LocalName == (object)id6_Date && (object) Reader.NamespaceURI == (object)id2_Item)) { + { + o.@Date = ToDateTime(Reader.ReadElementString()); + } + paramsRead[0] = true; + } + else { + UnknownNode((object)o, @"http://tempuri.org/CustomerSchema.xsd:Date"); + } + } + else { + UnknownNode((object)o, @"http://tempuri.org/CustomerSchema.xsd:Date"); + } + Reader.MoveToContent(); + CheckReaderCount(ref whileIterations1, ref readerCount1); + } + ReadEndElement(); + return o; + } + + protected override void InitCallbacks() { + } + + string id1_CustomerSchema; + string id4_Name; + string id2_Item; + string id6_Date; + string id3_Item; + string id5_Orders; + + protected override void InitIDs() { + id1_CustomerSchema = Reader.NameTable.Add(@"CustomerSchema"); + id4_Name = Reader.NameTable.Add(@"Name"); + id2_Item = Reader.NameTable.Add(@"http://tempuri.org/CustomerSchema.xsd"); + id6_Date = Reader.NameTable.Add(@"Date"); + id3_Item = Reader.NameTable.Add(@""); + id5_Orders = Reader.NameTable.Add(@"Orders"); + } + } + } + + internal abstract class CustomerSchemaSerializerBase : System.Xml.Serialization.XmlSerializer { + protected override System.Xml.Serialization.XmlSerializationReader CreateReader() { + return new CustomerSchemaSerializer.BaseReader(); + } + protected override System.Xml.Serialization.XmlSerializationWriter CreateWriter() { + return new CustomerSchemaSerializer.BaseWriter(); + } + } + + internal sealed partial class CustomerSchemaSerializer : CustomerSchemaSerializerBase { + + CustomerSchemaReader _reader; + CustomerSchemaWriter _writer; + + /// <summary>Constructs the serializer.</summary> + public CustomerSchemaSerializer() + { + } + + /// <summary>Constructs the serializer with a pre-built reader.</summary> + public CustomerSchemaSerializer(CustomerSchemaReader reader) + { + _reader = reader; + } + + /// <summary>Constructs the serializer with a pre-built writer.</summary> + public CustomerSchemaSerializer(CustomerSchemaWriter writer) + { + _writer = writer; + } + + /// <summary>Constructs the serializer with pre-built reader and writer.</summary> + public CustomerSchemaSerializer(CustomerSchemaReader reader, CustomerSchemaWriter writer) + { + _reader = reader; + _writer = writer; + } + + /// <remarks/> + protected override System.Xml.Serialization.XmlSerializationReader CreateReader() + { + if (_reader != null) return _reader; + + return base.CreateReader(); + } + + /// <remarks/> + protected override System.Xml.Serialization.XmlSerializationWriter CreateWriter() + { + if (_writer != null) return _writer; + + return base.CreateWriter(); + } + + public override System.Boolean CanDeserialize(System.Xml.XmlReader xmlReader) { + return xmlReader.IsStartElement(@"CustomerSchema", @"http://tempuri.org/CustomerSchema.xsd"); + } + + protected override void Serialize(object objectToSerialize, System.Xml.Serialization.XmlSerializationWriter writer) { + ((BaseWriter)writer).Write4_CustomerSchema(objectToSerialize); + } + + protected override object Deserialize(System.Xml.Serialization.XmlSerializationReader reader) { + return ((BaseReader)reader).Read4_CustomerSchema(); + } + } + + internal partial class CustomerSchemaSerializer { + internal class XmlSerializerContract : global::System.Xml.Serialization.XmlSerializerImplementation { + public override global::System.Xml.Serialization.XmlSerializationReader Reader { get { return new CustomerSchemaSerializer.BaseReader(); } } + public override global::System.Xml.Serialization.XmlSerializationWriter Writer { get { return new CustomerSchemaSerializer.BaseWriter(); } } + System.Collections.Hashtable readMethods = null; + public override System.Collections.Hashtable ReadMethods { + get { + if (readMethods == null) { + System.Collections.Hashtable _tmp = new System.Collections.Hashtable(); + _tmp[@"Mvp.Xml.Design.Tests.CustomerSchema:http://tempuri.org/CustomerSchema.xsd::False:"] = @"Read4_CustomerSchema"; + if (readMethods == null) readMethods = _tmp; + } + return readMethods; + } + } + System.Collections.Hashtable writeMethods = null; + public override System.Collections.Hashtable WriteMethods { + get { + if (writeMethods == null) { + System.Collections.Hashtable _tmp = new System.Collections.Hashtable(); + _tmp[@"Mvp.Xml.Design.Tests.CustomerSchema:http://tempuri.org/CustomerSchema.xsd::False:"] = @"Write4_CustomerSchema"; + if (writeMethods == null) writeMethods = _tmp; + } + return writeMethods; + } + } + System.Collections.Hashtable typedSerializers = null; + public override System.Collections.Hashtable TypedSerializers { + get { + if (typedSerializers == null) { + System.Collections.Hashtable _tmp = new System.Collections.Hashtable(); + _tmp.Add(@"Mvp.Xml.Design.Tests.CustomerSchema:http://tempuri.org/CustomerSchema.xsd::False:", new CustomerSchemaSerializer()); + if (typedSerializers == null) typedSerializers = _tmp; + } + return typedSerializers; + } + } + public override System.Boolean CanSerialize(System.Type type) { + if (type == typeof(global::Mvp.Xml.Design.Tests.CustomerSchema)) return true; + return false; + } + public override System.Xml.Serialization.XmlSerializer GetSerializer(System.Type type) { + if (type == typeof(global::Mvp.Xml.Design.Tests.CustomerSchema)) return new CustomerSchemaSerializer(); + return null; + } + } + } +} + + +#pragma warning restore 0642, 0219 Index: Mvp.Xml.Design.Tests.csproj =================================================================== RCS file: /cvsroot/mvp-xml/Design/v2/tests/Mvp.Xml.Design.Tests.csproj,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- Mvp.Xml.Design.Tests.csproj 31 Oct 2005 09:31:24 -0000 1.1 +++ Mvp.Xml.Design.Tests.csproj 31 Oct 2005 11:49:18 -0000 1.2 @@ -123,7 +123,7 @@ </PropertyGroup> <ProjectExtensions> <VisualStudio> - <UserProperties Mvp__Xml__Design__Tests___Customer__cs="Mvp.Xml.Design.Tests.Customer;Mvp.Xml.Design.Tests" Mvp__Xml__Design__Tests___CustomerSchema__xsd___CustomerSchema__cs="Mvp.Xml.Design.Tests.CustomerSchema;CustomerSchemaSerialization" /> + <UserProperties Mvp__Xml__Design__Tests___CustomerSchema__xsd___CustomerSchema__cs="Mvp.Xml.Design.Tests.CustomerSchema;CustomerSchemaSerialization" Mvp__Xml__Design__Tests___Customer__cs="Mvp.Xml.Design.Tests.Customer;Mvp.Xml.Design.Tests" /> </VisualStudio> </ProjectExtensions> </Project> \ No newline at end of file |
From: Daniel C. \(kzu\) <dca...@us...> - 2005-10-31 11:49:34
|
Update of /cvsroot/mvp-xml/Design/v2/src/CustomTools/XGen In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24252/v2/src/CustomTools/XGen Modified Files: XGenTool.cs XmlSerializerGenerator.cs Log Message: Fixed replacement of code. Index: XGenTool.cs =================================================================== RCS file: /cvsroot/mvp-xml/Design/v2/src/CustomTools/XGen/XGenTool.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- XGenTool.cs 31 Oct 2005 11:15:24 -0000 1.3 +++ XGenTool.cs 31 Oct 2005 11:49:18 -0000 1.4 @@ -84,7 +84,8 @@ if (CurrentItem.DTE.Solution.SolutionBuild.LastBuildInfo == 1) { - return Properties.Resources.XGenTool_ProjectDoesNotCompile + inputFileContent; + return Properties.Resources.XGenTool_ProjectDoesNotCompile + + File.ReadAllText(Path.ChangeExtension(InputFilePath, GetDefaultExtension())); } CopyDesignToOutput(outputPath); Index: XmlSerializerGenerator.cs =================================================================== RCS file: /cvsroot/mvp-xml/Design/v2/src/CustomTools/XGen/XmlSerializerGenerator.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- XmlSerializerGenerator.cs 31 Oct 2005 09:31:24 -0000 1.1 +++ XmlSerializerGenerator.cs 31 Oct 2005 11:49:18 -0000 1.2 @@ -476,8 +476,8 @@ rootObject + "Reader", rootObject + "Writer", type.FullName); - output = output.Replace(": " + rootObject + "BaseSerializer {", - ": " + rootObject + "BaseSerializer {\n" + readerWriterMembers); + output = output.Replace(": " + rootObject + "SerializerBase {", + ": " + rootObject + "SerializerBase {\n" + readerWriterMembers); return output; } |
From: Daniel C. \(kzu\) <dca...@us...> - 2005-10-31 11:15:50
|
Update of /cvsroot/mvp-xml/Design/v2/setup In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17946/v2/setup Modified Files: Setup.vdproj Log Message: Updated .NET version in setup. Fixed errors in generators. Updated solution to compile MSI when in release mode automatically. Index: Setup.vdproj =================================================================== RCS file: /cvsroot/mvp-xml/Design/v2/setup/Setup.vdproj,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- Setup.vdproj 31 Oct 2005 09:31:24 -0000 1.1 +++ Setup.vdproj 31 Oct 2005 11:15:23 -0000 1.2 @@ -234,7 +234,7 @@ { "Name" = "8:.NET Framework" "Message" = "8:[VSDNETMSG]" - "Version" = "8:2.0.50110" + "Version" = "8:2.0.50727" "AllowLaterVersions" = "11:TRUE" "InstallUrl" = "8:http://go.microsoft.com/fwlink/?LinkId=9832" "SupportedRuntimes" = "8:1.1.4322" @@ -1084,7 +1084,7 @@ } "{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_2090D92F765D47F7BADD9F4AADA8FDA1" { - "SourcePath" = "8:..\\src\\obj\\Debug\\Mvp.Xml.Design.dll" + "SourcePath" = "8:..\\src\\obj\\Release\\Mvp.Xml.Design.dll" "TargetName" = "8:" "Tag" = "8:" "Folder" = "8:_0E15C1344F794F8F931126EC4B60D776" |
From: Daniel C. \(kzu\) <dca...@us...> - 2005-10-31 11:15:50
|
Update of /cvsroot/mvp-xml/Design/v2/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17946/v2/src Modified Files: Mvp.Xml.Design.sln Log Message: Updated .NET version in setup. Fixed errors in generators. Updated solution to compile MSI when in release mode automatically. Index: Mvp.Xml.Design.sln =================================================================== RCS file: /cvsroot/mvp-xml/Design/v2/src/Mvp.Xml.Design.sln,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- Mvp.Xml.Design.sln 31 Oct 2005 09:31:24 -0000 1.1 +++ Mvp.Xml.Design.sln 31 Oct 2005 11:15:24 -0000 1.2 @@ -16,6 +16,7 @@ {A379C40D-C984-4E63-933A-BE96E9A599B7}.Release|Default.Build.0 = Release|Any CPU {0836E643-A9ED-421E-8426-1CB68F125B66}.Debug|Default.ActiveCfg = Debug {0836E643-A9ED-421E-8426-1CB68F125B66}.Release|Default.ActiveCfg = Release + {0836E643-A9ED-421E-8426-1CB68F125B66}.Release|Default.Build.0 = Release EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE |
From: Daniel C. \(kzu\) <dca...@us...> - 2005-10-31 11:15:49
|
Update of /cvsroot/mvp-xml/Design/v2/src/CustomTools/XGen In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17946/v2/src/CustomTools/XGen Modified Files: XGenTool.cs Log Message: Updated .NET version in setup. Fixed errors in generators. Updated solution to compile MSI when in release mode automatically. Index: XGenTool.cs =================================================================== RCS file: /cvsroot/mvp-xml/Design/v2/src/CustomTools/XGen/XGenTool.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- XGenTool.cs 31 Oct 2005 10:16:59 -0000 1.2 +++ XGenTool.cs 31 Oct 2005 11:15:24 -0000 1.3 @@ -84,7 +84,7 @@ if (CurrentItem.DTE.Solution.SolutionBuild.LastBuildInfo == 1) { - return Properties.Resources.XGenTool_ProjectDoesNotCompile; + return Properties.Resources.XGenTool_ProjectDoesNotCompile + inputFileContent; } CopyDesignToOutput(outputPath); |
From: Daniel C. \(kzu\) <dca...@us...> - 2005-10-31 11:15:49
|
Update of /cvsroot/mvp-xml/Design/v2/src/CustomTools/XsdToClasses In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17946/v2/src/CustomTools/XsdToClasses Modified Files: XsdCodeGenerator.cs Log Message: Updated .NET version in setup. Fixed errors in generators. Updated solution to compile MSI when in release mode automatically. Index: XsdCodeGenerator.cs =================================================================== RCS file: /cvsroot/mvp-xml/Design/v2/src/CustomTools/XsdToClasses/XsdCodeGenerator.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- XsdCodeGenerator.cs 31 Oct 2005 09:31:24 -0000 1.1 +++ XsdCodeGenerator.cs 31 Oct 2005 11:15:24 -0000 1.2 @@ -22,7 +22,7 @@ /// Uses the XsdGeneratorLibrary to process XSD files and generate the corresponding /// classes. /// </summary> - [Guid("F19A34B8-2CAF-459d-8080-FC85157A1165")] + [Guid("39215CF7-DA75-49f1-809E-7D027E1AB24D")] [ComVisible(true)] [CustomTool("Mvp.Xml.XsdGen", "Mvp.Xml XSD to Classes Generator", true)] [VersionSupport("8.0")] @@ -91,7 +91,7 @@ private void LoadSchemas(out XmlSchema xsd, out XmlSchemas schemas) { - using (FileStream fs = new FileStream(base.InputFilePath, FileMode.Open)) + using (FileStream fs = File.OpenRead(base.InputFilePath)) { xsd = XmlSchema.Read(fs, null); xsd.Compile(null); |
From: Daniel C. \(kzu\) <dca...@us...> - 2005-10-31 11:15:49
|
Update of /cvsroot/mvp-xml/Design/v2/src/Properties In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17946/v2/src/Properties Modified Files: Resources.Designer.cs Resources.resx Log Message: Updated .NET version in setup. Fixed errors in generators. Updated solution to compile MSI when in release mode automatically. Index: Resources.resx =================================================================== RCS file: /cvsroot/mvp-xml/Design/v2/src/Properties/Resources.resx,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- Resources.resx 31 Oct 2005 09:31:24 -0000 1.1 +++ Resources.resx 31 Oct 2005 11:15:24 -0000 1.2 @@ -188,7 +188,8 @@ <value xml:space="preserve">The selected element doesn't contain any class definitions.</value> </data> <data name="XGenTool_ProjectDoesNotCompile"> - <value xml:space="preserve">// Containing project could not be compiled successfully.</value> + <value xml:space="preserve">#warning Containing project could not be compiled successfully. Generated code may be outdated. +</value> </data> <data name="XGenTool_UnclosedBrackets"> <value xml:space="preserve">Could not find a matching closing bracket in input string.</value> Index: Resources.Designer.cs =================================================================== RCS file: /cvsroot/mvp-xml/Design/v2/src/Properties/Resources.Designer.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- Resources.Designer.cs 31 Oct 2005 09:31:24 -0000 1.1 +++ Resources.Designer.cs 31 Oct 2005 11:15:24 -0000 1.2 @@ -280,7 +280,8 @@ } /// <summary> - /// Looks up a localized string similar to // Containing project could not be compiled successfully.. + /// Looks up a localized string similar to #warning Containing project could not be compiled successfully. Generated code may be outdated. + ///. /// </summary> internal static string XGenTool_ProjectDoesNotCompile { get { |
From: Daniel C. \(kzu\) <dca...@us...> - 2005-10-31 10:17:12
|
Update of /cvsroot/mvp-xml/Design/v2/src/CustomTools/XGen In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6761/v2/src/CustomTools/XGen Modified Files: XGenTool.cs Log Message: Updated XGen default extension name. Index: XGenTool.cs =================================================================== RCS file: /cvsroot/mvp-xml/Design/v2/src/CustomTools/XGen/XGenTool.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- XGenTool.cs 31 Oct 2005 09:31:24 -0000 1.1 +++ XGenTool.cs 31 Oct 2005 10:16:59 -0000 1.2 @@ -230,7 +230,7 @@ /// </summary> public override string GetDefaultExtension() { - return "Serialization." + base.CodeProvider.FileExtension; + return ".Serialization." + base.CodeProvider.FileExtension; } #endregion GetDefaultExtension |
From: Daniel C. \(kzu\) <dca...@us...> - 2005-10-31 09:38:36
|
Update of /cvsroot/mvp-xml/Global In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30385 Added Files: how-to-sign.txt Log Message: Instructions on code signing. --- NEW FILE: how-to-sign.txt --- 1. Open Visual Studio command prompt 2. Sign assembly using .spc and .pvk files: signcode -spc myCertificate.spc -v myKey.pvk -t http://timestamp.verisign.com/scripts/timstamp.dll Mvp.Xml.dll Note: "-t http://timestamp.verisign.com/scripts/timstamp.dll" is an optional. 3. Verify signature chktrust -v Mvp.Xml.dll |
From: Daniel C. \(kzu\) <dca...@us...> - 2005-10-31 09:31:37
|
Update of /cvsroot/mvp-xml/Design/v2/src/CustomTools/XGen In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29101/v2/src/CustomTools/XGen Added Files: ClassPicker.cs ClassPicker.resx XGenRunner.cs XGenTool.cs XmlSerializerGenerator.cs Log Message: Finished port to v2 of XGen and XsdGen. Removed XmlValidate as the new XML editor has built-in support for validation. --- NEW FILE: ClassPicker.cs --- using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Text; using EnvDTE; namespace Mvp.Xml.Design.CustomTools.XGen { internal class ClassPicker : System.Windows.Forms.Form { #region Designer Stuff private System.Windows.Forms.Label label1; private System.Windows.Forms.Button btnCancel; private System.Windows.Forms.Button btnAccept; private Mvp.Xml.Design.ListViewEx lstClasses; private System.Windows.Forms.TextBox txtEditor; private System.Windows.Forms.ColumnHeader colClass; private System.Windows.Forms.ColumnHeader colTargetNs; /// <summary> /// Required designer variable. /// </summary> private System.ComponentModel.Container components = null; public ClassPicker() { // // Required for Windows Form Designer support // InitializeComponent(); // // TODO: Add any constructor code after InitializeComponent call // } /// <summary> /// Clean up any resources being used. /// </summary> protected override void Dispose( bool disposing ) { if( disposing ) { if(components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region Windows Form Designer generated code /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.label1 = new System.Windows.Forms.Label(); this.btnCancel = new System.Windows.Forms.Button(); this.btnAccept = new System.Windows.Forms.Button(); this.lstClasses = new Mvp.Xml.Design.ListViewEx(); this.colClass = new System.Windows.Forms.ColumnHeader(); this.colTargetNs = new System.Windows.Forms.ColumnHeader(); this.txtEditor = new System.Windows.Forms.TextBox(); this.SuspendLayout(); // // label1 // this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.label1.Location = new System.Drawing.Point(8, 8); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(624, 48); this.label1.TabIndex = 1; this.label1.Text = "Select the classes you will use as the root of a deserialization process. A custo" + "m XmlSerializer and supporting classes will be generated for each of the selecte" + "d ones:"; // // btnCancel // this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; this.btnCancel.Location = new System.Drawing.Point(395, 280); this.btnCancel.Name = "btnCancel"; this.btnCancel.Size = new System.Drawing.Size(75, 23); this.btnCancel.TabIndex = 2; this.btnCancel.Text = "&Cancel"; this.btnCancel.Visible = false; // // btnAccept // this.btnAccept.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.btnAccept.DialogResult = System.Windows.Forms.DialogResult.OK; this.btnAccept.Location = new System.Drawing.Point(557, 280); this.btnAccept.Name = "btnAccept"; this.btnAccept.Size = new System.Drawing.Size(75, 23); this.btnAccept.TabIndex = 3; this.btnAccept.Text = "&OK"; // // lstClasses // this.lstClasses.AllowColumnReorder = true; this.lstClasses.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.lstClasses.CheckBoxes = true; this.lstClasses.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { this.colClass, this.colTargetNs}); this.lstClasses.DoubleClickActivation = false; this.lstClasses.FullRowSelect = true; this.lstClasses.Location = new System.Drawing.Point(8, 56); this.lstClasses.Name = "lstClasses"; this.lstClasses.Size = new System.Drawing.Size(624, 216); this.lstClasses.Sorting = System.Windows.Forms.SortOrder.Ascending; this.lstClasses.TabIndex = 0; this.lstClasses.UseCompatibleStateImageBehavior = false; this.lstClasses.View = System.Windows.Forms.View.Details; this.lstClasses.SubItemClicked += new Mvp.Xml.Design.SubItemEventHandler(this.lstClasses_SubItemClicked); // // colClass // this.colClass.Text = "Class"; this.colClass.Width = 344; // // colTargetNs // this.colTargetNs.Text = "Target Namespace"; this.colTargetNs.Width = 273; // // txtEditor // this.txtEditor.Location = new System.Drawing.Point(12, 280); this.txtEditor.Name = "txtEditor"; this.txtEditor.Size = new System.Drawing.Size(100, 20); this.txtEditor.TabIndex = 4; this.txtEditor.Visible = false; // // ClassPicker // this.AcceptButton = this.btnAccept; this.CancelButton = this.btnCancel; this.ClientSize = new System.Drawing.Size(640, 309); this.Controls.Add(this.txtEditor); this.Controls.Add(this.lstClasses); this.Controls.Add(this.btnAccept); this.Controls.Add(this.btnCancel); this.Controls.Add(this.label1); this.Name = "ClassPicker"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = " Class Picker"; this.ResumeLayout(false); this.PerformLayout(); } #endregion #endregion Designer Stuff string defaultNs; public ClassPicker(CodeElements elements, string defaultNs, SelectionCollection selections) { InitializeComponent(); // Add all classes. this.defaultNs = defaultNs; IterateElements(elements); if (lstClasses.Items.Count == 1) { lstClasses.Items[0].Checked = true; } if (selections != null) { foreach (Selection sel in selections) { foreach (ListViewItem item in lstClasses.Items) { if (item.Text == sel.ClassName) { item.Checked = true; } } } } } private void IterateElements(CodeElements elements) { foreach (CodeElement element in elements) { if (element is CodeNamespace) { IterateElements(((CodeNamespace)element).Members); } else if (element is CodeClass) { lstClasses.Items.Add(new ListViewItem( new string[] { ((CodeClass)element).FullName, this.defaultNs })); } } } public SelectionCollection Selections { get { SelectionCollection col = new SelectionCollection(); foreach (ListViewItem item in lstClasses.Items) { if (item.Checked) { col.Add(new Selection(item.Text, item.SubItems[1].Text)); } } return col; } } private void lstClasses_SubItemClicked(object sender, Mvp.Xml.Design.SubItemEventArgs e) { if (e.SubItem != 0) { lstClasses.StartEditing(txtEditor, e.Item, e.SubItem); } } } internal class SelectionCollection : CollectionBase { public static SelectionCollection FromString(string serializedData) { string[] items = serializedData.Split('|'); SelectionCollection col = new SelectionCollection(); foreach (string item in items) { col.Add(Selection.FromString(item)); } return col; } public int Add(Selection selection) { return base.InnerList.Add(selection); } public void Remove(Selection selection) { base.InnerList.Remove(selection); } public Selection this[int idx] { get { return (Selection)base.InnerList[idx]; } set { base.InnerList[idx] = value; } } public override string ToString() { string[] items = new string[base.Count]; for (int i = 0; i < items.Length; i++) { items[i] = base.InnerList[i].ToString(); } return String.Join("|", items); } } internal class Selection { public static Selection FromString(string serializedData) { string[] values = serializedData.Split(';'); return new Selection(values[0], values[1]); } public Selection(string className, string targetNs) { this.ClassName = className; this.TargetNamespace = targetNs; } public override string ToString() { return this.ClassName + ";" + this.TargetNamespace; } public string ClassName; public string TargetNamespace; } } --- NEW FILE: XGenRunner.cs --- using System; using System.IO; namespace Mvp.Xml.Design.CustomTools.XGen { /// <summary> /// Class that performs the actual code generation in the isolated design domain. /// </summary> internal class XGenRunner : MarshalByRefObject { /// <summary> /// Generates the code for the received type. /// </summary> public XGenRunner(string outputFile, string forType, string targetNamespace) { using (StreamWriter writer = new StreamWriter(outputFile)) { writer.Write(XmlSerializerGenerator.GenerateCode( Type.GetType(forType, true), targetNamespace)); } } } } --- NEW FILE: ClassPicker.resx --- <?xml version="1.0" encoding="utf-8"?> <root> <!-- Microsoft ResX Schema Version 2.0 The primary goals of this format is to allow a simple XML format that is mostly human readable. The generation and parsing of the various data types are done through the TypeConverter classes associated with the data types. Example: ... ado.net/XML headers & schema ... <resheader name="resmimetype">text/microsoft-resx</resheader> <resheader name="version">2.0</resheader> <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> <value>[base64 mime encoded serialized .NET Framework object]</value> </data> <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> <comment>This is a comment</comment> </data> There are any number of "resheader" rows that contain simple name/value pairs. Each data row contains a name, and value. The row also contains a type or mimetype. Type corresponds to a .NET class that support text/value conversion through the TypeConverter architecture. Classes that don't support this are serialized and stored with the mimetype set. The mimetype is used for serialized objects, and tells the ResXResourceReader how to depersist the object. This is currently not extensible. For a given mimetype the value must be set accordingly: Note - application/x-microsoft.net.object.binary.base64 is the format that the ResXResourceWriter will generate, however the reader can read any of the formats listed below. mimetype: application/x-microsoft.net.object.binary.base64 value : The object must be serialized with : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter : and then encoded with base64 encoding. mimetype: application/x-microsoft.net.object.soap.base64 value : The object must be serialized with : System.Runtime.Serialization.Formatters.Soap.SoapFormatter : and then encoded with base64 encoding. mimetype: application/x-microsoft.net.object.bytearray.base64 value : The object must be serialized into a byte array : using a System.ComponentModel.TypeConverter : and then encoded with base64 encoding. --> <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> <xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> <xsd:element name="root" msdata:IsDataSet="true"> <xsd:complexType> <xsd:choice maxOccurs="unbounded"> <xsd:element name="metadata"> <xsd:complexType> <xsd:sequence> <xsd:element name="value" type="xsd:string" minOccurs="0" /> </xsd:sequence> <xsd:attribute name="name" use="required" type="xsd:string" /> <xsd:attribute name="type" type="xsd:string" /> <xsd:attribute name="mimetype" type="xsd:string" /> <xsd:attribute ref="xml:space" /> </xsd:complexType> </xsd:element> <xsd:element name="assembly"> <xsd:complexType> <xsd:attribute name="alias" type="xsd:string" /> <xsd:attribute name="name" type="xsd:string" /> </xsd:complexType> </xsd:element> <xsd:element name="data"> <xsd:complexType> <xsd:sequence> <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> </xsd:sequence> <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> <xsd:attribute ref="xml:space" /> </xsd:complexType> </xsd:element> <xsd:element name="resheader"> <xsd:complexType> <xsd:sequence> <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> </xsd:sequence> <xsd:attribute name="name" type="xsd:string" use="required" /> </xsd:complexType> </xsd:element> </xsd:choice> </xsd:complexType> </xsd:element> </xsd:schema> <resheader name="resmimetype"> <value>text/microsoft-resx</value> </resheader> <resheader name="version"> <value>2.0</value> </resheader> <resheader name="reader"> <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> </resheader> <resheader name="writer"> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> </resheader> </root> --- NEW FILE: XGenTool.cs --- #region Usage /* Usage: * On any C# code file, set: * Custom Tool: XsdCodeGen * Custom Tool Namespace: [Optional override for default namespace that matches the C# file namespace] * * Author: Daniel Cazzulino - kz...@gm... */ #endregion Usage using System; using System.Collections; using System.ComponentModel; using System.ComponentModel.Design; using System.IO; using System.Reflection; using System.Runtime.InteropServices; using System.Text; using System.Xml; using System.Xml.Schema; using EnvDTE; using VSLangProj; using System.Globalization; namespace Mvp.Xml.Design.CustomTools.XGen { /// <summary> /// Generates custom typed XmlSerializers. /// </summary> /// <remarks> /// On any class set the Custom Tool property to "Mvp.Xml.XGen". /// This tool supports C# projects only, as that's the code generated /// by the XmlSerializer class. /// </remarks> [Guid("B393315E-C463-41cd-A274-CEB18DB7073C")] [CustomTool("Mvp.Xml.XGen", "Mvp.Xml Project XmlSerializer Generation Tool", true)] [ComVisible(true)] [VersionSupport("8.0")] [CategorySupport(CategorySupportAttribute.CSharpCategory)] public class XGenTool : CustomTool { static string ConfigFile; const string XGenPrefix = "Mvp_Xml_XGen__"; #region Static config initialization static XGenTool() { AssemblyName name = Assembly.GetExecutingAssembly().GetName(); ConfigFile = Path.GetTempFileName() + ".config"; using (StreamWriter sw = new StreamWriter(ConfigFile)) { // Keep serialization files. Required for SGen to work. sw.Write(@"<?xml version='1.0' encoding='utf-8' ?> <configuration> <system.diagnostics> <switches> <add name='XmlSerialization.Compilation' value='4'/> </switches> </system.diagnostics> </configuration>"); } } #endregion Static config initialization #region GenerateCode /// <summary> /// Generates the output. /// </summary> protected override string OnGenerateCode(string inputFileName, string inputFileContent) { ThrowIfNoClassFound(); string outputPath = GetProjectOutputFullPath(); // Force compilation of the current project. We need the type in the output. CurrentItem.DTE.Solution.SolutionBuild.BuildProject( CurrentItem.DTE.Solution.SolutionBuild.ActiveConfiguration.Name, CurrentItem.ContainingProject.UniqueName, true); if (CurrentItem.DTE.Solution.SolutionBuild.LastBuildInfo == 1) { return Properties.Resources.XGenTool_ProjectDoesNotCompile; } CopyDesignToOutput(outputPath); SelectionCollection selections = GetSerializedSelection(); selections = ShowSelectionUI(selections); if (selections == null || selections.Count == 0) { return String.Empty; } StringBuilder output = new StringBuilder(); AppDomainSetup appSetup = new AppDomainSetup(); appSetup.ApplicationName = typeof(XGenTool).Namespace; appSetup.ApplicationBase = outputPath; appSetup.ConfigurationFile = ConfigFile; foreach (Selection selection in selections) { GetSerializationCode(appSetup, output, selection); } SaveSelections(selections); return output.ToString(); } private void SaveSelections(SelectionCollection selections) { string key = BuildItemKey(CurrentItem); CurrentItem.ContainingProject.Globals[key] = selections.ToString(); CurrentItem.ContainingProject.Globals.set_VariablePersists(key, true); } private void GetSerializationCode(AppDomainSetup appSetup, StringBuilder output, Selection selection) { string codefile = Path.GetTempFileName(); AppDomain domain = AppDomain.CreateDomain(appSetup.ApplicationName, null, appSetup); try { // Runner ctor will dump the output to the file we pass. domain.CreateInstance( Assembly.GetExecutingAssembly().FullName, typeof(XGenRunner).FullName, false, 0, null, new object[] { codefile, selection.ClassName + ", " + CurrentItem.ContainingProject.Properties.Item("AssemblyName").Value.ToString(), selection.TargetNamespace }, null, null, null); using (StreamReader reader = new StreamReader(codefile)) { output.Append(reader.ReadToEnd()).Append(Environment.NewLine); } } finally { AppDomain.Unload(domain); } } private SelectionCollection ShowSelectionUI(SelectionCollection selections) { ClassPicker picker = new ClassPicker(CurrentItem.FileCodeModel.CodeElements, base.FileNameSpace, selections); if (picker.ShowDialog() == System.Windows.Forms.DialogResult.OK) { selections = picker.Selections; } return selections; } private SelectionCollection GetSerializedSelection() { string key = BuildItemKey(CurrentItem); string serialized = String.Empty; if (CurrentItem.ContainingProject.Globals.get_VariableExists(key)) { serialized = (string)CurrentItem.ContainingProject.Globals[key]; } SelectionCollection selections = null; if (serialized.Length > 0) { selections = SelectionCollection.FromString(serialized); } return selections; } private void CopyDesignToOutput(string outputPath) { // Copy Design assembly to output for the isolated AppDomain. string asmfile = GetAssemblyPath(Assembly.GetExecutingAssembly()); try { File.Copy(asmfile, Path.Combine(outputPath, Path.GetFileName(asmfile)), true); } catch (Exception ex) { // May already exist, be locked, etc. System.Diagnostics.Debug.WriteLine(ex.ToString()); } } private void ThrowIfNoClassFound() { if (CurrentItem.FileCodeModel == null || CurrentItem.FileCodeModel.CodeElements == null) { throw new InvalidOperationException(Properties.Resources.XGenTool_NoClassFound); } } private string GetProjectOutputFullPath() { string outputPath = base.CurrentItem.ContainingProject.ConfigurationManager.ActiveConfiguration.Properties.Item("OutputPath").Value.ToString(); outputPath = Path.Combine(base.CurrentItem.ContainingProject.Properties.Item("FullPath").Value.ToString(), outputPath); return outputPath; } private string BuildItemKey(ProjectItem item) { string itemVirtualPath = DteHelper.BuildPath(item); itemVirtualPath = itemVirtualPath.Replace(".", "__").Replace("\\", "___"); return itemVirtualPath; } private string GetAssemblyPath(Assembly assembly) { Uri uri = new Uri(assembly.CodeBase); return uri.LocalPath; } #endregion GenerateCode #region GetDefaultExtension /// <summary> /// This tool generates code, and the default extension equals that of the current code provider. /// </summary> public override string GetDefaultExtension() { return "Serialization." + base.CodeProvider.FileExtension; } #endregion GetDefaultExtension #region Registration and Installation /// <summary> /// Registers the generator. /// </summary> [ComRegisterFunction] public static void RegisterClass(Type type) { CustomTool.Register(typeof(XGenTool)); } /// <summary> /// Unregisters the generator. /// </summary> [ComUnregisterFunction] public static void UnregisterClass(Type t) { CustomTool.UnRegister(typeof(XGenTool)); } #endregion Registration and Installation } } --- NEW FILE: XmlSerializerGenerator.cs --- using System; using System.Collections; using System.CodeDom; using System.CodeDom.Compiler; using System.IO; using System.Reflection; using System.Text.RegularExpressions; using System.Xml.Serialization; namespace Mvp.Xml.Design.CustomTools.XGen { internal class XmlSerializerGenerator { #region Constants /// <summary> /// In the <see cref="PrivateReadMethods"/> regular expression, /// the return type of the read method. /// </summary> const string ReadMethodReturnType = "return"; /// <summary> /// In the <see cref="PrivateReadMethods"/> regular expression, /// full method signature excluding return type. /// </summary> const string ReadMethodFullSignature = "method"; /// <summary> /// In the <see cref="PrivateReadMethods"/> regular expression, /// matched method name. /// </summary> const string ReadMethodName = "name"; /// <summary> /// In the <see cref="PrivateReadMethods"/> regular expression, /// matched method arguments. /// </summary> const string ReadMethodArguments = "arguments"; /// <summary> /// In the <see cref="PublicRead"/> or <see cref="PublicWrite"/> regular expressions, /// matched name of the object being read or written. /// </summary> const string MethodObjectName = "object"; /// <summary> /// In the <see cref="PublicRead"/> or <see cref="PublicWrite"/> regular expressions, /// the name of the matched public read or write method. /// </summary> const string MethodName = "method"; /// <summary> /// In the <see cref="ClassDeclaration"/> regular expression, /// the matched name of the class being declared. /// </summary> const string ClassDeclarationName = "className"; /// <summary> /// In the <see cref="ClassDeclaration"/> regular expression, /// the matched name of the base class of the class being declared. /// </summary> const string ClassDeclarationBaseType = "baseClass"; #endregion #region Regular Expressions /// <summary> /// Matches all non-void methods called Read_[identifier]([...arguments...]) /// </summary> static Regex PrivateReadMethods = new Regex(@" # Returned type # (?<return>[^\s]+)\s # Method call start # (?<method> (?<name>Read\d+_ # Object being read # (?<object>[^\(]+))\( # Method arguments # (?<arguments>[^\)]+) # Method call end # \))\s{", RegexOptions.IgnorePatternWhitespace | RegexOptions.Compiled | RegexOptions.Multiline); /// <summary> /// Matches a public object Read_[object] method. /// </summary> static Regex PublicRead = new Regex(@"public object (?<method>Read\d+_(?<object>[^\(]+))", RegexOptions.Compiled | RegexOptions.Multiline); /// <summary> /// Matches a public void Write_[object] method. /// </summary> static Regex PublicWrite = new Regex(@"public void (?<method>Write\d+_(?<object>[^\(]+))", RegexOptions.Compiled | RegexOptions.Multiline); /// <summary> /// Matches an assembly level AssemblyVersionAttribute attribute declaration. /// </summary> static Regex AssemblyVersion = new Regex(@"\[assembly:System.Reflection.AssemblyVersionAttribute[^\]]*\]", RegexOptions.Compiled | RegexOptions.Multiline); /// <summary> /// Matches an identifier previous to a space or coma. /// </summary> static Regex RemoveTypeFromArguments = new Regex(@"[^\s,]+[\s]", RegexOptions.Compiled); /// <summary> /// Matches the full class declaration, capturing the class name and base type. /// </summary> static Regex ClassDeclaration = new Regex(@"public( abstract)?( sealed)? class (?<className>[^\s]+) :\s?(?<baseClass>[^\s]+)", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.ExplicitCapture); /// <summary> /// Matches only the "public [modifiers] class" part. Used for replacing the visibility. /// </summary> static Regex SimpleClassDeclaration = new Regex(@"public(?<modifiers>( abstract)?( sealed)?( partial)?) class", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.ExplicitCapture); #endregion #region Code templates /// <summary> /// Template for the override for each element being read. /// {0}=Return type /// {1}=Method name /// {2}=Delegate name /// {3}=Event name /// {4}=Arguments with type definition /// {5}=Arguments with no type /// </summary> const string TemplateMethodOverride = @" /// <remarks/> protected override {0} {1}({4}) {{ {0} obj = base.{1}({5}); {2} handler = {3}; if (handler != null) handler(obj); return obj; }}"; /// <summary> /// Template for the public Read method for the root object /// in the custom reader firing events. /// {0}=Return type /// {1}=Read method name generated by serializer for root object. /// </summary> const string TemplateReadMethod = @" /// <summary>Reads an object of type {0}.</summary> internal {0} Read() {{ return ({0}) {1}(); }}"; /// <summary> /// Template for the public Write method for the root object /// in the custom writer. /// {0}=Object type name /// {1}=Write method name generated by serializer for root object. /// </summary> const string TemplateWriteMethod = @" /// <summary>Writes an object of type {0}.</summary> internal void Write({0} value) {{ {1}(value); }}"; /// <summary> /// Template for custom serializer class members. /// {0}=Name of the serializer class /// {1}=Reader type name /// {2}=Writer type name /// {3}=Root object type /// </summary> const string TemplateCustomSerializer = @" {1} _reader; {2} _writer; /// <summary>Constructs the serializer.</summary> public {0}() {{ }} /// <summary>Constructs the serializer with a pre-built reader.</summary> public {0}({1} reader) {{ _reader = reader; }} /// <summary>Constructs the serializer with a pre-built writer.</summary> public {0}({2} writer) {{ _writer = writer; }} /// <summary>Constructs the serializer with pre-built reader and writer.</summary> public {0}({1} reader, {2} writer) {{ _reader = reader; _writer = writer; }} /// <remarks/> protected override System.Xml.Serialization.XmlSerializationReader CreateReader() {{ if (_reader != null) return _reader; return base.CreateReader(); }} /// <remarks/> protected override System.Xml.Serialization.XmlSerializationWriter CreateWriter() {{ if (_writer != null) return _writer; return base.CreateWriter(); }}"; #endregion Code templates #region Private helper methods public static string GenerateCode(Type type, string targetNamespace) { string output = GetXmlSerializerOutput(type); System.CodeDom.CodeNamespace ns = InitializeCodeDom(targetNamespace); output = CleanupXmlSerializerCode(targetNamespace, output); // Find the methods that are the entry points for reading and writing the object. Match readMatch = PublicRead.Match(output); Match writeMatch = PublicWrite.Match(output); string rootObject = readMatch.Groups[MethodObjectName].Value; output = MakeSerializerPartial(output, rootObject); output = RenameClasses(output, rootObject); output = NestTypesOnSerialier(output, rootObject); output = AppendReaderWriterMembersToObjectSerializer(type, output, rootObject); CodeTypeDeclaration readerDeclaration = CreateAndAddEventRisingReader(targetNamespace, output, ns, rootObject); output = PrivateReadMethodsToProtectedVirtual(output); CodeTypeDeclaration writerDeclaration = CreateAndAddTypedWriter(targetNamespace, ns, rootObject); // Renders TemplateReadMethod (see that constant declaration) output = AddTypedRead(readerDeclaration, type, output, readMatch); // Renders TemplateWriteMethod (see that constant declaration) output = AddTypedWrite(writerDeclaration, type, output, writeMatch); output = MergeOutputWithCodeDom(output, ns); output = MakeClassesInternal(output); output = NormalizeLineEndings(output); output = NestTypesOnSerialier(output, rootObject); output = FixInstantiationOfNestedTypes(output, rootObject); output = "\r\n#pragma warning disable 0642, 0219\r\n" + output + "\r\n#pragma warning restore 0642, 0219"; output = CustomTool.GetToolGeneratedCodeWarning(typeof(XGenTool)) + output; #if DEBUG return @"#region Original XmlSerializer code /* ------------------------------------------------------------------------------------- " + GetXmlSerializerOutput(type) + @" -------------------------------------------------------------------------------------*/ " + @"#endregion " + output; #else return output; #endif //"\r\n#pragma warning disable 0642, 0219\r\n" + endlines.ToString() + "#pragma warning restore 0642, 0219"; } private static string MakeSerializerPartial(string output, string rootObject) { string rootSerializer = rootObject + "Serializer"; return output.Replace("public sealed class " + rootSerializer, "public sealed partial class " + rootSerializer); } private static string FixInstantiationOfNestedTypes(string output, string rootObject) { output = output.Replace("new BaseWriter", "new " + rootObject + "Serializer.BaseWriter"); output = output.Replace("new BaseReader", "new " + rootObject + "Serializer.BaseReader"); return output; } private static string NormalizeLineEndings(string output) { // Sometimes VS doesn't like the line endings we got from the XmlSerializer code... StringWriter endlines = new StringWriter(); using (StringReader sr = new StringReader(output)) { string line; while ((line = sr.ReadLine()) != null) { endlines.WriteLine(line); } } output = endlines.ToString(); return output; } private static string MakeClassesInternal(string output) { // Make all classes internal instead of public. return SimpleClassDeclaration.Replace(output, "internal${modifiers} class"); } private static string MergeOutputWithCodeDom(string output, System.CodeDom.CodeNamespace ns) { CodeGeneratorOptions opt = new CodeGeneratorOptions(); opt.BracingStyle = "C"; StringWriter finalcode = new StringWriter(); new Microsoft.CSharp.CSharpCodeProvider().GenerateCodeFromNamespace(ns, finalcode, opt); finalcode.WriteLine(output); return finalcode.ToString(); } private static string NestTypesOnSerialier(string output, string rootObject) { string rootSerializer = rootObject + "Serializer"; // Nest public reader/writer classes first MatchCollection classMatches = ClassDeclaration.Matches(output); for (int i = classMatches.Count - 1; i >= 0; i--) { Match m = classMatches[i]; // Skip the serializer itself if (m.Groups[ClassDeclarationName].Value.StartsWith(rootObject)) { continue; } int closePosition = FindClosingBracketPosition(output, output.IndexOf('{', m.Index)); output = output.Insert(++closePosition, "\n\t}"); output = output.Insert(m.Index, "public partial class " + rootSerializer + " {\n\t"); } return output; } private static int FindClosingBracketPosition(string output, int openPosition) { int openCount = 0; for (int i = openPosition; i < output.Length; i++) { if (output[i] == '{') openCount++; if (output[i] == '}') openCount--; if (openCount == 0) return i; } throw new ArgumentException(Properties.Resources.XGenTool_UnclosedBrackets); } private static string PrivateReadMethodsToProtectedVirtual(string output) { // Turn all private methods into protected virtual, as they are overriden // by the custom event rising reader. output = PrivateReadMethods.Replace(output, @"/// <remarks/> protected virtual ${return} ${method} {"); return output; } private static CodeTypeDeclaration CreateAndAddTypedWriter(string targetNamespace, System.CodeDom.CodeNamespace ns, string rootObject) { CodeTypeDeclaration writerDeclaration = new CodeTypeDeclaration(rootObject + "Writer"); writerDeclaration.BaseTypes.Add(rootObject + "Serializer.BaseWriter"); writerDeclaration.Comments.Add(new CodeCommentStatement( "/// <summary>Custom writer for " + rootObject + " instances.</summary>", true)); ns.Types.Add(writerDeclaration); return writerDeclaration; } private static CodeTypeDeclaration CreateAndAddEventRisingReader(string targetNamespace, string output, System.CodeDom.CodeNamespace ns, string rootObject) { CodeTypeDeclaration readerDeclaration = new CodeTypeDeclaration(rootObject + "Reader"); readerDeclaration.BaseTypes.Add(rootObject + "Serializer.BaseReader"); readerDeclaration.Comments.Add(new CodeCommentStatement( "/// <summary>Custom reader for " + rootObject + " instances.</summary>", true)); ns.Types.Add(readerDeclaration); // For each read method Match readMethodMatch = PrivateReadMethods.Match(output); while (readMethodMatch.Success) { string objectBeingRead = readMethodMatch.Groups[MethodObjectName].Value; // Skip the generic reading method. if (objectBeingRead.ToLower() == "object") { readMethodMatch = readMethodMatch.NextMatch(); continue; } // Create a delegate for the event to expose. // public delegate void [objectBeingRead]DeserializedHandler(Mvp.Xml.Design.Tests.Customer customer); CodeTypeDelegate del = new CodeTypeDelegate(objectBeingRead + "DeserializedHandler"); del.Parameters.Add(new CodeParameterDeclarationExpression( readMethodMatch.Groups[ReadMethodReturnType].Value, MakeFirstLower(objectBeingRead))); del.Comments.Add(new CodeCommentStatement("/// <remarks/>", true)); ns.Types.Add(del); // Expose event. // public event [objectBeingRead]DeserializedHandler [objectBeingRead]Deserialized; CodeMemberEvent ev = new CodeMemberEvent(); ev.Name = objectBeingRead + "Deserialized"; ev.Attributes = MemberAttributes.Public; ev.Type = new CodeTypeReference(del.Name); ev.Comments.Add(new CodeCommentStatement("/// <remarks/>", true)); readerDeclaration.Members.Add(ev); // Override base method. string methodOverride = String.Format( TemplateMethodOverride, readMethodMatch.Groups[ReadMethodReturnType].Value, readMethodMatch.Groups[ReadMethodName].Value, del.Name, ev.Name, readMethodMatch.Groups[ReadMethodArguments].Value, // Arguments contain type + parameter name. Remove type for method call. RemoveTypeFromArguments.Replace( readMethodMatch.Groups[ReadMethodArguments].Value, "")); readerDeclaration.Members.Add(new CodeSnippetTypeMember(methodOverride)); readMethodMatch = readMethodMatch.NextMatch(); } return readerDeclaration; } private static string AddTypedRead(CodeTypeDeclaration reader, Type type, string output, Match readMatch) { // Add the "final" public read method. reader.Members.Add(new CodeSnippetTypeMember( String.Format(TemplateReadMethod, type.FullName, readMatch.Groups[MethodName].Value))); // Turn original public method into internal protected output = PublicRead.Replace(output, "protected internal object ${method}"); return output; } private static string AddTypedWrite(CodeTypeDeclaration writer, Type type, string output, Match writeMatch) { // Add the "final" public write method. writer.Members.Add(new CodeSnippetTypeMember( String.Format(TemplateWriteMethod, type.FullName, writeMatch.Groups[MethodName].Value))); // Turn original public method into internal protected output = PublicWrite.Replace(output, "protected internal void ${method}"); return output; } private static string MakeFirstLower(string value) { char[] name = value.ToCharArray(); name[0] = Char.ToLower(name[0]); return new string(name); } private static string AppendReaderWriterMembersToObjectSerializer(Type type, string output, string rootObject) { string readerWriterMembers = String.Format( TemplateCustomSerializer, rootObject + "Serializer", rootObject + "Reader", rootObject + "Writer", type.FullName); output = output.Replace(": " + rootObject + "BaseSerializer {", ": " + rootObject + "BaseSerializer {\n" + readerWriterMembers); return output; } private static string RenameClasses(string output, string rootObject) { // Give generated classes more friendly names. output = output.Replace("XmlSerializationWriter" + rootObject, "BaseWriter"); output = output.Replace("XmlSerializationReader" + rootObject, "BaseReader"); output = output.Replace("XmlSerializer1", rootObject + "SerializerBase"); return output; } private static string CleanupXmlSerializerCode(string targetNamespace, string output) { // Remove assembly version attribute. output = AssemblyVersion.Replace(output, ""); // Replace namespace. output = output.Replace("Microsoft.Xml.Serialization.GeneratedAssembly", targetNamespace); return output; } private static System.CodeDom.CodeNamespace InitializeCodeDom(string targetNamespace) { System.CodeDom.CodeNamespace ns = new System.CodeDom.CodeNamespace(targetNamespace); ns.Imports.Add(new CodeNamespaceImport("System.Xml.Serialization")); ns.Imports.Add(new CodeNamespaceImport("System")); // CodeTypeDeclaration serializer = new CodeTypeDeclaration(type.Name + "Serializer"); // serializer.BaseTypes.Add(typeof(XmlSerializer)); // serializer.Comments.Add(new CodeCommentStatement( // "<summary>Custom serializer for " + type.Name + " type.</summary", true)); // ns.Types.Add(serializer); return ns; } private static string GetXmlSerializerOutput(Type type) { string output; XmlSerializer ser = new XmlSerializer(type); // Here starts the horrible reflection hacks! //ser.tempAssembly.assembly.Location FieldInfo fitempasm = ser.GetType().GetField("tempAssembly", BindingFlags.NonPublic | BindingFlags.Instance); object tempasm = fitempasm.GetValue(ser); FieldInfo fiasm = tempasm.GetType().GetField("assembly", BindingFlags.NonPublic | BindingFlags.Instance); Assembly asm = (Assembly)fiasm.GetValue(tempasm); string codebase = new Uri(asm.CodeBase).LocalPath; string code = Path.Combine( Path.GetDirectoryName(codebase), Path.GetFileNameWithoutExtension(codebase) + ".0.cs"); string original; using (StreamReader sr = new StreamReader(code)) { output = sr.ReadToEnd(); original = output; } return output; } #endregion } } |
From: Daniel C. \(kzu\) <dca...@us...> - 2005-10-31 09:31:37
|
Update of /cvsroot/mvp-xml/Design/v2/tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29101/v2/tests Added Files: .cvsignore AssemblyInfo.cs CustomerSchema.Serialization.cs CustomerSchema.cs CustomerSchema.xsd CustomerSchema.xsx CustomerSchemaBehavior.cs Mvp.Xml.Design.Tests.csproj Mvp.Xml.Design.Tests.sln Tests.cs changelog.txt license.txt Log Message: Finished port to v2 of XGen and XsdGen. Removed XmlValidate as the new XML editor has built-in support for validation. --- NEW FILE: CustomerSchema.xsx --- <?xml version="1.0" encoding="utf-8"?> <!--This file is auto-generated by the XML Schema Designer. It holds layout information for components on the designer surface.--> <XSDDesignerLayout Style="LeftRight" layoutVersion="2" viewPortLeft="0" viewPortTop="0" zoom="100"> <CustomerSchema_XmlElement left="9049" top="4021" width="5292" height="2752" selected="0" zOrder="1" index="0" expanded="1"> <Orders_XmlElement left="14975" top="4021" width="5291" height="2751" selected="0" zOrder="3" index="1" expanded="1" /> </CustomerSchema_XmlElement> </XSDDesignerLayout> --- NEW FILE: .cvsignore --- bin obj *.user *.suo --- NEW FILE: CustomerSchema.Serialization.cs --- // Containing project --- NEW FILE: Mvp.Xml.Design.Tests.csproj --- (This appears to be a binary file; contents omitted.) --- NEW FILE: changelog.txt --- --------------------------------------------------------- October 31, 2005 Finished port to v2 of XGen and XsdGen. --------------------------------------------------------- April 01, 2004 Initial setup. Folder should preferably contain NUnit tests. --- NEW FILE: Tests.cs --- (This appears to be a binary file; contents omitted.) --- NEW FILE: CustomerSchema.cs --- namespace Mvp.Xml.Design.Tests { /// <remarks/> [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "2.0.50727.42")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)] [System.Xml.Serialization.XmlRootAttribute(Namespace="http://tempuri.org/CustomerSchema.xsd", IsNullable=false)] public partial class CustomerSchema { private string nameField; private CustomerSchemaOrders ordersField; /// <remarks/> public string Name { get { return this.nameField; } set { this.nameField = value; } } /// <remarks/> public CustomerSchemaOrders Orders { get { return this.ordersField; } set { this.ordersField = value; } } } /// <remarks/> [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "2.0.50727.42")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)] public partial class CustomerSchemaOrders { private System.DateTime dateField; /// <remarks/> public System.DateTime Date { get { return this.dateField; } set { this.dateField = value; } } } } --- NEW FILE: AssemblyInfo.cs --- using System.Reflection; using System.Runtime.CompilerServices; // // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. // [assembly: AssemblyTitle("")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("")] [assembly: AssemblyCopyright("")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] // // Version information for an assembly consists of the following four values: // // Major Version // Minor Version // Build Number // Revision // // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: [assembly: AssemblyVersion("1.0.*")] // // In order to sign your assembly you must specify a key to use. Refer to the // Microsoft .NET Framework documentation for more information on assembly signing. // // Use the attributes below to control which key is used for signing. // // Notes: // (*) If no key is specified, the assembly is not signed. // (*) KeyName refers to a key that has been installed in the Crypto Service // Provider (CSP) on your machine. KeyFile refers to a file which contains // a key. // (*) If the KeyFile and the KeyName values are both specified, the // following processing occurs: // (1) If the KeyName can be found in the CSP, that key is used. // (2) If the KeyName does not exist and the KeyFile does exist, the key // in the KeyFile is installed into the CSP and used. // (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility. // When specifying the KeyFile, the location of the KeyFile should be // relative to the project output directory which is // %Project Directory%\obj\<configuration>. For example, if your KeyFile is // located in the project directory, you would specify the AssemblyKeyFile // attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")] // (*) Delay Signing is an advanced option - see the Microsoft .NET Framework // documentation for more information on this. // [assembly: AssemblyDelaySign(false)] [assembly: AssemblyKeyFile("")] [assembly: AssemblyKeyName("")] --- NEW FILE: CustomerSchema.xsd --- (This appears to be a binary file; contents omitted.) --- NEW FILE: Mvp.Xml.Design.Tests.sln --- (This appears to be a binary file; contents omitted.) --- NEW FILE: license.txt --- Common Public License Version 1.0 THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS COMMON PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. 1. DEFINITIONS "Contribution" means: a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and b) in the case of each subsequent Contributor: i) changes to the Program, and ii) additions to the Program; where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program. "Contributor" means any person or entity that distributes the Program. "Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program. "Program" means the Contributions distributed in accordance with this Agreement. "Recipient" means anyone who receives the Program under this Agreement, including all Contributors. 2. GRANT OF RIGHTS a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form. b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder. c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program. d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement. 3. REQUIREMENTS A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that: a) it complies with the terms and conditions of this Agreement; and b) its license agreement: i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose; ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits; iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange. When the Program is made available in source code form: a) it must be made available under this Agreement; and b) a copy of this Agreement must be included with each copy of the Program. Contributors may not remove or alter any copyright notices contained within the Program. Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution. 4. COMMERCIAL DISTRIBUTION Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense. For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages. 5. NO WARRANTY EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement, including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations. 6. DISCLAIMER OF LIABILITY EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 7. GENERAL If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable. If Recipient institutes patent litigation against a Contributor with respect to a patent applicable to software (including a cross-claim or counterclaim in a lawsuit), then any patent licenses granted by that Contributor to such Recipient under this Agreement shall terminate as of the date such litigation is filed. In addition, if Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed. All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive. Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. IBM is the initial Agreement Steward. IBM may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved. This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation. --- NEW FILE: CustomerSchemaBehavior.cs --- (This appears to be a binary file; contents omitted.) |
From: Daniel C. \(kzu\) <dca...@us...> - 2005-10-31 09:31:37
|
Update of /cvsroot/mvp-xml/Design/v2/src/VisualStudio In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29101/v2/src/VisualStudio Added Files: IProfferService.cs Readme.txt ServiceContainer.cs Site.cs Log Message: Finished port to v2 of XGen and XsdGen. Removed XmlValidate as the new XML editor has built-in support for validation. --- NEW FILE: Site.cs --- using System; using System.ComponentModel; namespace Mvp.Xml.Design.VisualStudio { /// <summary> /// Basic <see cref="ISite"/> implementation. Passes all service /// requests to the parent service provider. /// </summary> public class Site : ISite { #region Field & Ctor IServiceProvider _provider; /// <summary> /// Constructs a site. /// </summary> /// <param name="provider">The object providing services to this site.</param> /// <param name="component">The component this site is being associated with.</param> /// <param name="name">A name for the site.</param> public Site(IServiceProvider provider, IComponent component, string name) { if (provider == null) throw new ArgumentNullException("provider"); if (component == null) throw new ArgumentNullException("component"); _component = component; // Pull the container from the service provider (if any). _container = (IContainer) provider.GetService(typeof(IContainer)); _provider = provider; _name = name; } #endregion Field & Ctor #region ISite Members /// <summary> /// See <see cref="ISite.Component"/>. /// </summary> public IComponent Component { get { return _component; } } IComponent _component; /// <summary> /// See <see cref="ISite.Container"/>. /// </summary> public IContainer Container { get { return _container; } } IContainer _container; /// <summary> /// Always returns <c>false</c>. /// </summary> public bool DesignMode { get { return false; } } /// <summary> /// See <see cref="ISite.Name"/>. /// </summary> public string Name { get { return _name; } set { _name = value; } } string _name; #endregion #region IServiceProvider Members /// <summary> /// See <see cref="IServiceProvider.GetService"/>. /// </summary> public virtual object GetService(Type service) { if (service != typeof(ISite)) return _provider.GetService(service); return this; } #endregion } } --- NEW FILE: ServiceContainer.cs --- using System; using System.Collections; using System.ComponentModel; using System.ComponentModel.Design; namespace Mvp.Xml.Design.VisualStudio { /// <summary> /// Implements a generic container for services. /// </summary> public abstract class ServiceContainer : IServiceContainer, IServiceProvider, IOleServiceProvider, IDisposable { #region Fields & Ctors IServiceProvider _provider; IServiceContainer _container; IProfferService _proffer; /// <summary> /// Default parameterless constructor for standalone containers. /// </summary> public ServiceContainer() {} /// <summary> /// Initializes the container with a parent service provider. /// </summary> public ServiceContainer(IServiceProvider provider) { _provider = provider; // Try to retrieve a parent container. _container = (IServiceContainer) provider.GetService(typeof (IServiceContainer)); // Try to retrieve the proffer service. _proffer = (IProfferService) provider.GetService(typeof (IProfferService)); } #endregion Fields & Ctors #region IServiceContainer Members /// <summary> /// Removes the specified service type from the service container, and optionally promotes the service to parent service containers. /// </summary> /// <param name="serviceType">The type of service to remove.</param> /// <param name="promote"><c>true</c> to promote this request to any parent service containers; otherwise, <c>false</c>.</param> public void RemoveService(Type serviceType, bool promote) { RemoveService(serviceType); if (promote) RemovePromotedService(serviceType); } /// <summary> /// Removes the specified service type from the service container. /// </summary> /// <param name="serviceType">The type of service to remove.</param> public void RemoveService(Type serviceType) { _services.Remove(serviceType); } /// <summary> /// Adds the specified service to the service container, and optionally promotes the service to parent service containers. /// </summary> /// <param name="serviceType">The type of service to add.</param> /// <param name="callback">A callback object that is used to create the service. This allows a service to be declared as available, but delays the creation of the object until the service is requested.</param> /// <param name="promote"><c>true</c> to promote this request to any parent service containers; otherwise, <c>false</c>.</param> public void AddService(Type serviceType, ServiceCreatorCallback callback, bool promote) { AddService(serviceType, callback); if (promote) AddPromotedService(serviceType, callback); } /// <summary> /// Adds the specified service to the service container. /// </summary> /// <param name="serviceType">The type of service to add.</param> /// <param name="callback">A callback object that is used to create the service. This allows a service to be declared as available, but delays the creation of the object until the service is requested.</param> public void AddService(Type serviceType, ServiceCreatorCallback callback) { if (serviceType == null) throw new ArgumentNullException("serviceType"); if (callback == null) throw new ArgumentNullException("callback"); if (_services.Contains(serviceType)) throw new ArgumentException("Service already exists.", "serviceType"); _services[serviceType] = callback; } /// <summary> /// Adds the specified service to the service container, and optionally promotes the service to any parent service containers. /// </summary> /// <param name="serviceType">The type of service to add.</param> /// <param name="serviceInstance">An instance of the service type to add. This object must implement or inherit from the type indicated by the serviceType parameter. </param> /// <param name="promote"><c>true</c> to promote this request to any parent service containers; otherwise, <c>false</c>.</param> public void AddService(Type serviceType, object serviceInstance, bool promote) { AddService(serviceType, serviceInstance); if (promote) AddPromotedService(serviceType, serviceInstance); } /// <summary> /// Adds the specified service to the service container. /// </summary> /// <param name="serviceType">The type of service to add.</param> /// <param name="serviceInstance">An instance of the service type to add. This object must implement or inherit from the type indicated by the serviceType parameter. </param> public void AddService(Type serviceType, object serviceInstance) { if (serviceType == null) throw new ArgumentNullException("serviceType"); if (serviceInstance == null) throw new ArgumentNullException("serviceInstance"); // __ComObjects are assignable anyway. We can't check that. // This is what System.ComponentModel.Design.ServiceContainer does. if (((serviceInstance as ServiceCreatorCallback) == null) && ((!serviceInstance.GetType().IsCOMObject && !serviceType.IsAssignableFrom(serviceInstance.GetType())))) throw new ArgumentException("Invalid service instance.", "serviceInstance"); if (_services.Contains(serviceType)) throw new ArgumentException("Service already exists.", "serviceType"); _services[serviceType] = serviceInstance; } #endregion #region IServiceProvider Members /// <summary> /// Provides access to services in this container. /// </summary> /// <param name="serviceType">The service type to retrieve.</param> /// <returns>The service instance or null if it's not available.</returns> public virtual object GetService(Type serviceType) { object serviceInstance = _services[serviceType]; if ((serviceInstance as ServiceCreatorCallback) != null) { ServiceCreatorCallback cbk = (ServiceCreatorCallback) serviceInstance; // Create the instance through the callback. serviceInstance = cbk(this, serviceType); // __ComObjects are assignable anyway. We can't check that. // This is what System.ComponentModel.Design.ServiceContainer does. if ((serviceInstance != null) && (!serviceInstance.GetType().IsCOMObject && !serviceType.IsAssignableFrom(serviceInstance.GetType()))) { _services.Remove(serviceType); serviceInstance = null; } else { _services[serviceType] = serviceInstance; } } // Propagate request to parents. if (serviceInstance == null && _provider != null) return _provider.GetService(serviceType); return serviceInstance; } IDictionary _services = new System.Collections.Specialized.HybridDictionary(); #endregion #region IOleServiceProvider Members /// <summary> /// Provides the ole implementation of the service retrieval routine. /// </summary> int IOleServiceProvider.QueryService(ref Guid guidService, ref Guid riid, out System.IntPtr ppvObject) { foreach (DictionaryEntry entry in _services) { if (((Type)entry.Key).GUID == guidService) { object service = GetService((Type) entry.Key); IntPtr pUnk = System.Runtime.InteropServices.Marshal.GetIUnknownForObject(service); int hr = System.Runtime.InteropServices.Marshal.QueryInterface(pUnk, ref riid, out ppvObject); System.Runtime.InteropServices.Marshal.Release(pUnk); return hr; } } ppvObject = (IntPtr) 0; return 0; } #endregion #region IDisposable Members /// <summary> /// Clears the container state. /// </summary> public virtual void Dispose() { // Remove all services promoted to VS. foreach (Type svc in _profferedservices.Keys) { RemovePromotedService(svc); } } #endregion #region Service promotion /// <summary> /// Keeps services that were promoted directly to VS. /// </summary> IDictionary _profferedservices = new System.Collections.Specialized.HybridDictionary(); private void AddPromotedService(Type serviceType, object serviceInstanceOrCallback) { if (_container == null && _proffer == null) return; // Regular service promotion. if (_container != null) { _container.AddService(serviceType, serviceInstanceOrCallback, true); return; } // Proffered services promotion. if (_proffer != null) { ProfferedService svc = new ProfferedService(); svc.Instance = serviceInstanceOrCallback; uint cookie; Guid sg = serviceType.GUID; int hr = _proffer.ProfferService(ref sg, this, out cookie); svc.Cookie= cookie; // If there're failures, throw? if (hr < 0) { throw new System.Runtime.InteropServices.COMException( String.Format("Failed to proffer service {0}", serviceType.FullName), hr); } _profferedservices[serviceType] = svc; } } private void RemovePromotedService(Type serviceType) { if (_container == null && _proffer == null) return; // Regular service demotion. if (_container != null) { _container.RemoveService(serviceType, true); return; } // We have a proffered service at hand. ProfferedService svc = (ProfferedService) _profferedservices[serviceType]; if (svc != null) { if (svc.Cookie != 0) { _proffer.RevokeService(svc.Cookie); // Dispose if appropriate, but don't dispose ourselves again. if (svc.Instance is IDisposable && svc.Instance != this) { ((IDisposable)svc.Instance).Dispose(); } } } } #region ProfferedService class /// <summary> /// This class contains a service that is being promoted to VS. /// </summary> private sealed class ProfferedService { public object Instance; public uint Cookie; } #endregion ProfferedService class #endregion Service proffering } } --- NEW FILE: IProfferService.cs --- using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; namespace Mvp.Xml.Design.VisualStudio { /// <remarks/> [ComImport] [ComVisible(true)] [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] [Guid("CB728B20-F786-11CE-92AD-00AA00A74CD0")] public interface IProfferService { // Methods /// <remarks/> int ProfferService( [In] ref Guid rguidService, [In, MarshalAs(UnmanagedType.Interface)] IOleServiceProvider psp, [Out, MarshalAs(UnmanagedType.U4)] out uint pdwCookie); /// <remarks/> void RevokeService( [In, MarshalAs(UnmanagedType.U4)] uint dwCookie); } } --- NEW FILE: Readme.txt --- Update GotDotNet folder from: http://www.gotdotnet.com/Community/UserSamples/Details.aspx?SampleGuid=4AA14341-24D5-45AB-AB18-B72351D0371C Released by Microsoft. |
From: Daniel C. \(kzu\) <dca...@us...> - 2005-10-31 09:31:37
|
Update of /cvsroot/mvp-xml/Design/v2/src/VisualStudio/GotDotNet In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29101/v2/src/VisualStudio/GotDotNet Added Files: BaseCodeGenerator.cs BaseCodeGeneratorWithSite.cs IObjectWithSite.cs IOleServiceProvider.cs IVsGeneratorProgress.cs IVsSingleFileGenerator.cs ServiceProvider.cs Log Message: Finished port to v2 of XGen and XsdGen. Removed XmlValidate as the new XML editor has built-in support for validation. --- NEW FILE: ServiceProvider.cs --- namespace Mvp.Xml.Design.VisualStudio { using System; using System.Diagnostics; using System.Runtime.InteropServices; /// <summary> /// This wraps the IOleServiceProvider interface and provides an easy COM+ way to get at /// services. /// </summary> public class ServiceProvider : IServiceProvider, IObjectWithSite { private static Guid IID_IUnknown = new Guid("{00000000-0000-0000-C000-000000000046}"); private IOleServiceProvider serviceProvider; /// <summary> /// Creates a new ServiceProvider object and uses the given interface to resolve /// services. /// </summary> /// <param name='sp'> /// The IOleServiceProvider interface to use. /// </param> public ServiceProvider(IOleServiceProvider sp) { serviceProvider = sp; } /// <summary> /// gives this class a chance to free its references. /// </summary> public virtual void Dispose() { if (serviceProvider != null) { serviceProvider = null; } } /// <summary> /// returns true if the given HRESULT is a failure HRESULT /// </summary> /// <param name="hr">HRESULT to test</param> /// <returns>true if the HRESULT is a failure, false if not.</returns> public static bool Failed(int hr) { return(hr < 0); } /// <summary> /// Retrieves the requested service. /// </summary> /// <param name='serviceClass'> /// The class of the service to retrieve. /// </param> /// <returns> /// an instance of serviceClass or null if no /// such service exists. /// </returns> public virtual object GetService(Type serviceClass) { if (serviceClass == null) { return null; } return GetService(serviceClass.GUID, serviceClass); } /// <summary> /// Retrieves the requested service. /// </summary> /// <param name='guid'> /// The GUID of the service to retrieve. /// </param> /// <returns> /// an instance of the service or null if no /// such service exists. /// </returns> public virtual object GetService(Guid guid) { return GetService(guid, null); } /// <summary> /// Retrieves the requested service. The guid must be specified; the class is only /// used when debugging and it may be null. /// </summary> private object GetService(Guid guid, Type serviceClass) { // Valid, but wierd for caller to init us with a NULL sp // if (serviceProvider == null) { return null; } object service = null; // No valid guid on the passed in class, so there is no service for it. // if (guid.Equals(Guid.Empty)) { return null; } // We provide a couple of services of our own. // if (guid.Equals(typeof(IOleServiceProvider).GUID)) { return serviceProvider; } if (guid.Equals(typeof(IObjectWithSite).GUID)) { return (IObjectWithSite)this; } IntPtr pUnk; int hr = serviceProvider.QueryService(ref guid, ref IID_IUnknown, out pUnk); if (Succeeded(hr) && (pUnk != IntPtr.Zero)) { service = Marshal.GetObjectForIUnknown(pUnk); Marshal.Release(pUnk); } return service; } /// <summary> /// Retrieves the current site object we're using to /// resolve services. /// </summary> /// <param name='riid'> /// Must be IServiceProvider.class.GUID /// </param> /// <param name='ppvSite'> /// Outparam that will contain the site object. /// </param> /// <seealso cref='IObjectWithSite'/> void IObjectWithSite.GetSite(ref Guid riid, object[] ppvSite) { ppvSite[0] = GetService(riid); } /// <summary> /// Sets the site object we will be using to resolve services. /// </summary> /// <param name='pUnkSite'> /// The site we will use. This site will only be /// used if it also implements IOleServiceProvider. /// </param> /// <seealso cref='IObjectWithSite'/> void IObjectWithSite.SetSite(object pUnkSite) { if (pUnkSite is IOleServiceProvider) { serviceProvider = (IOleServiceProvider)pUnkSite; } } /// <summary> /// returns true if the given HRESULT is a success HRESULT /// </summary> /// <param name="hr">HRESULT to test</param> /// <returns>true if the HRESULT is a success, false if not.</returns> public static bool Succeeded(int hr) { return(hr >= 0); } } } --- NEW FILE: BaseCodeGenerator.cs --- namespace Mvp.Xml.Design.VisualStudio { using System; using System.Diagnostics; using System.IO; using System.Runtime.InteropServices; /// <summary> /// A managed wrapper for VS's concept of an IVsSingleFileGenerator which is /// a custom tool invoked during the build which can take any file as an input /// and provide a compilable code file as output. /// </summary> public abstract class BaseCodeGenerator : IVsSingleFileGenerator { private IVsGeneratorProgress codeGeneratorProgress; private string codeFileNameSpace = String.Empty; private string codeFilePath = String.Empty; /// <summary> /// namespace for the file. /// </summary> protected string FileNameSpace { get { return codeFileNameSpace; } } /// <summary> /// file-path for the input file. /// </summary> protected string InputFilePath { get { return codeFilePath; } } /// <summary> /// interface to the VS shell object we use to tell our /// progress while we are generating. /// </summary> internal IVsGeneratorProgress CodeGeneratorProgress { get { return codeGeneratorProgress; } } /// <summary> /// gets the default extension for this generator /// </summary> /// <returns>string with the default extension for this generator</returns> public abstract string GetDefaultExtension(); /// <summary> /// the method that does the actual work of generating code given the input /// file. /// </summary> /// <param name="inputFileName">input file name</param> /// <param name="inputFileContent">file contents as a string</param> /// <returns>the generated code file as a byte-array</returns> protected abstract byte[] GenerateCode(string inputFileName, string inputFileContent); /// <summary> /// method that will communicate an error via the shell callback mechanism. /// </summary> /// <param name="warning">true if this is a warning</param> /// <param name="level">level or severity</param> /// <param name="message">text displayed to the user</param> /// <param name="line">line number of error/warning</param> /// <param name="column">column number of error/warning</param> protected virtual void GeneratorErrorCallback(bool warning, int level, string message, int line, int column) { IVsGeneratorProgress progress = CodeGeneratorProgress; if (progress != null) { progress.GeneratorError(warning, level, message, line, column); } } /// <summary> /// main method that the VS shell calls to do the generation /// </summary> /// <param name="wszInputFilePath">path to the input file</param> /// <param name="bstrInputFileContents">contents of the input file as a string (shell handles UTF-8 to Unicode and those types of conversions)</param> /// <param name="wszDefaultNamespace">default namespace for the generated code file</param> /// <param name="rgbOutputFileContents">byte-array of output file contents</param> /// <param name="pcbOutput">count of bytes in the output byte-array</param> /// <param name="pGenerateProgress">interface to send progress updates to the shell</param> public void Generate(string wszInputFilePath, string bstrInputFileContents, string wszDefaultNamespace, out IntPtr rgbOutputFileContents, out int pcbOutput, IVsGeneratorProgress pGenerateProgress) { if (bstrInputFileContents == null) { throw new ArgumentNullException(bstrInputFileContents); } codeFilePath = wszInputFilePath; codeFileNameSpace = wszDefaultNamespace; codeGeneratorProgress = pGenerateProgress; byte[] bytes = GenerateCode(wszInputFilePath, bstrInputFileContents); if (bytes == null) { rgbOutputFileContents = IntPtr.Zero; pcbOutput = 0; } else { pcbOutput = bytes.Length; rgbOutputFileContents = Marshal.AllocCoTaskMem(pcbOutput); Marshal.Copy(bytes, 0, rgbOutputFileContents, pcbOutput); } } /// <summary> /// method to return a byte-array given a Stream /// </summary> /// <param name="stream">stream to convert to a byte-array</param> /// <returns>the stream's contents as a byte-array</returns> protected byte[] StreamToBytes(Stream stream) { if (stream.Length == 0) { return new byte[] { }; } long position = stream.Position; stream.Position = 0; byte[] bytes = new byte[(int)stream.Length]; stream.Read(bytes, 0, bytes.Length); stream.Position = position; return bytes; } } } --- NEW FILE: IVsSingleFileGenerator.cs --- namespace Mvp.Xml.Design.VisualStudio { using System; using System.Runtime.InteropServices; /// <remarks/> [ ComImport, Guid("3634494C-492F-4F91-8009-4541234E4E99"), InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown) ] public interface IVsSingleFileGenerator { // // Retrieve default properties for the generator // [propget] HRESULT DefaultExtension([out,retval] BSTR* pbstrDefaultExtension); // /// <remarks/> [return: MarshalAs(UnmanagedType.BStr)] string GetDefaultExtension(); // // Generate the file // HRESULT Generate([in] LPCOLESTR wszInputFilePath, // [in] BSTR bstrInputFileContents, // [in] LPCOLESTR wszDefaultNamespace, // [out] BYTE** rgbOutputFileContents, // [out] ULONG* pcbOutput, // [in] IVsGeneratorProgress* pGenerateProgress); // /// <remarks/> void Generate( [MarshalAs(UnmanagedType.LPWStr)] string wszInputFilePath, [MarshalAs(UnmanagedType.BStr)] string bstrInputFileContents, [MarshalAs(UnmanagedType.LPWStr)] string wszDefaultNamespace, out IntPtr rgbOutputFileContents, [MarshalAs(UnmanagedType.U4)] out int pcbOutput, IVsGeneratorProgress pGenerateProgress); } } --- NEW FILE: IOleServiceProvider.cs --- namespace Mvp.Xml.Design.VisualStudio { using System; using System.Runtime.InteropServices; /// <remarks/> [ ComImport, Guid("6D5140C1-7436-11CE-8034-00AA006009FA"), InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown) ] public interface IOleServiceProvider { /// <remarks/> [PreserveSig] int QueryService([In]ref Guid guidService, [In]ref Guid riid, out IntPtr ppvObject); } } --- NEW FILE: IVsGeneratorProgress.cs --- namespace Mvp.Xml.Design.VisualStudio { using System; using System.Runtime.InteropServices; /// <remarks/> [ ComImport, Guid("BED89B98-6EC9-43CB-B0A8-41D6E2D6669D"), InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown) ] public interface IVsGeneratorProgress { // // Communicate errors // HRESULT GeneratorError([in] BOOL fWarning, // [in] DWORD dwLevel, // [in] BSTR bstrError, // [in] DWORD dwLine, // [in] DWORD dwColumn); // /// <remarks/> void GeneratorError( bool fWarning, [MarshalAs(UnmanagedType.U4)] int dwLevel, [MarshalAs(UnmanagedType.BStr)] string bstrError, [MarshalAs(UnmanagedType.U4)] int dwLine, [MarshalAs(UnmanagedType.U4)] int dwColumn); // // Report progress to the caller. // HRESULT Progress([in] ULONG nComplete, // Current position // [in] ULONG nTotal); // Max value // /// <remarks/> void Progress( [MarshalAs(UnmanagedType.U4)] int nComplete, [MarshalAs(UnmanagedType.U4)] int nTotal); } } --- NEW FILE: IObjectWithSite.cs --- namespace Mvp.Xml.Design.VisualStudio { using System; using System.Runtime.InteropServices; [ ComImport, Guid("FC4801A3-2BA9-11CF-A229-00AA003D7352"), InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown) ] internal interface IObjectWithSite { // // HRESULT SetSite( // [in] IUnknown * pUnkSite); // void SetSite( [MarshalAs(UnmanagedType.Interface)] object pUnkSite); // // HRESULT GetSite( // [in] REFIID riid, // [out, iid_is(riid)] void ** ppvSite); // void GetSite( [In] ref Guid riid, [Out, MarshalAs(UnmanagedType.LPArray)] object[] ppvSite); } } --- NEW FILE: BaseCodeGeneratorWithSite.cs --- namespace Mvp.Xml.Design.VisualStudio { using System; using System.CodeDom; using System.CodeDom.Compiler; using System.Diagnostics; using System.Runtime.InteropServices; using EnvDTE; using VSLangProj; using Microsoft.VisualStudio.Designer.Interfaces; /// <summary> /// This class exists to be cocreated a in a preprocessor build step. /// </summary> public abstract class BaseCodeGeneratorWithSite : BaseCodeGenerator, IObjectWithSite { private const int E_FAIL = unchecked((int)0x80004005); private const int E_NOINTERFACE = unchecked((int)0x80004002); private object site = null; private CodeDomProvider codeDomProvider = null; private static Guid CodeDomInterfaceGuid = new Guid("{73E59688-C7C4-4a85-AF64-A538754784C5}"); private static Guid CodeDomServiceGuid = CodeDomInterfaceGuid; private ServiceProvider serviceProvider = null; /// <summary> /// demand-creates a CodeDomProvider /// </summary> protected virtual CodeDomProvider CodeProvider { get { if (codeDomProvider == null) { IVSMDCodeDomProvider vsmdCodeDomProvider = (IVSMDCodeDomProvider) GetService(CodeDomServiceGuid); if (vsmdCodeDomProvider != null) { codeDomProvider = (CodeDomProvider) vsmdCodeDomProvider.CodeDomProvider; } Debug.Assert(codeDomProvider != null, "Get CodeDomProvider Interface failed. GetService(QueryService(CodeDomProvider) returned Null."); } return codeDomProvider; } set { if (value == null) { throw new ArgumentNullException(); } codeDomProvider = value; } } /// <summary> /// demand-creates a ServiceProvider given an IOleServiceProvider /// </summary> private ServiceProvider SiteServiceProvider { get { if (serviceProvider == null) { IOleServiceProvider oleServiceProvider = site as IOleServiceProvider; Debug.Assert(oleServiceProvider != null, "Unable to get IOleServiceProvider from site object."); serviceProvider = new ServiceProvider(oleServiceProvider); } return serviceProvider; } } /// <summary> /// method to get a service by its GUID /// </summary> /// <param name="serviceGuid">GUID of service to retrieve</param> /// <returns>an object that implements the requested service</returns> protected object GetService(Guid serviceGuid) { return SiteServiceProvider.GetService(serviceGuid); } /// <summary> /// method to get a service by its Type /// </summary> /// <param name="serviceType">Type of service to retrieve</param> /// <returns>an object that implements the requested service</returns> protected virtual object GetService(Type serviceType) { return SiteServiceProvider.GetService(serviceType); } /// <summary> /// gets the default extension of the output file by asking the CodeDomProvider /// what its default extension is. /// </summary> /// <returns></returns> public override string GetDefaultExtension() { CodeDomProvider codeDom = CodeProvider; Debug.Assert(codeDom != null, "CodeDomProvider is NULL."); string extension = codeDom.FileExtension; if (extension != null && extension.Length > 0) { if (extension[0] != '.') { extension = "." + extension; } } return extension; } /// <summary> /// Method to get an ICodeGenerator with which this class can create code. /// </summary> /// <returns></returns> protected virtual ICodeGenerator GetCodeWriter() { CodeDomProvider codeDom = CodeProvider; if (codeDom != null) { return codeDom.CreateGenerator(); } return null; } /// <summary> /// SetSite method of IOleObjectWithSite /// </summary> /// <param name="pUnkSite">site for this object to use</param> public virtual void SetSite(object pUnkSite) { site = pUnkSite; codeDomProvider = null; serviceProvider = null; } /// <summary> /// GetSite method of IOleObjectWithSite /// </summary> /// <param name="riid">interface to get</param> /// <param name="ppvSite">array in which to stuff return value</param> public virtual void GetSite(ref Guid riid, object[] ppvSite) { if (ppvSite == null) { throw new ArgumentNullException("ppvSite"); } if (ppvSite.Length < 1) { throw new ArgumentException("ppvSite array must have at least 1 member", "ppvSite"); } if (site == null) { throw new COMException("object is not sited", E_FAIL); } IntPtr pUnknownPointer = Marshal.GetIUnknownForObject(site); IntPtr intPointer = IntPtr.Zero; Marshal.QueryInterface(pUnknownPointer, ref riid, out intPointer); if (intPointer == IntPtr.Zero) { throw new COMException("site does not support requested interface", E_NOINTERFACE); } ppvSite[0] = Marshal.GetObjectForIUnknown(intPointer); } /// <summary> /// gets a string containing the DLL names to add. /// </summary> /// <param name="DLLToAdd"></param> /// <returns></returns> private string GetDLLNames(string[] DLLToAdd) { if (DLLToAdd == null || DLLToAdd.Length == 0) { return string.Empty; } string dllNames = DLLToAdd[0]; for (int i = 1; i < DLLToAdd.Length; i++) { dllNames = dllNames + ", " + DLLToAdd[i]; } return dllNames; } /// <summary> /// adds a reference to the project for each required DLL /// </summary> /// <param name="referenceDLL"></param> protected void AddReferenceDLLToProject(string[] referenceDLL) { if (referenceDLL.Length == 0) { return; } object serviceObject = GetService(typeof(ProjectItem)); Debug.Assert(serviceObject != null, "Unable to get Project Item."); if (serviceObject == null) { string errorMessage = String.Format("Unable to add DLL to project references: {0}. Please Add them manually.", GetDLLNames(referenceDLL)); GeneratorErrorCallback(false, 1, errorMessage, 0, 0); return; } Project containingProject = ((ProjectItem) serviceObject).ContainingProject; Debug.Assert(containingProject != null, "GetService(typeof(Project)) return null."); if (containingProject == null) { string errorMessage = String.Format("Unable to add DLL to project references: {0}. Please Add them manually.", GetDLLNames(referenceDLL)); GeneratorErrorCallback(false, 1, errorMessage, 0, 0); return; } VSProject vsProj = containingProject.Object as VSProject; Debug.Assert(vsProj != null, "Unable to ADD DLL to current project. Project.Object does not implement VSProject."); if (vsProj == null) { string errorMessage = String.Format("Unable to add DLL to project references: {0}. Please Add them manually.", GetDLLNames(referenceDLL)); GeneratorErrorCallback(false, 1, errorMessage, 0, 0); return; } try { for (int i = 0; i < referenceDLL.Length; i++) { vsProj.References.Add(referenceDLL[i]); } } catch (Exception e) { Debug.Fail("**** ERROR: vsProj.References.Add() throws exception: " + e.ToString()); string errorMessage = String.Format("Unable to add DLL to project references: {0}. Please Add them manually.", GetDLLNames(referenceDLL)); GeneratorErrorCallback(false, 1, errorMessage, 0, 0); return; } } /// <summary> /// method to create an exception message given an exception /// </summary> /// <param name="e">exception caught</param> /// <returns>message to display to the user</returns> protected virtual string CreateExceptionMessage(Exception e) { string message = (e.Message != null ? e.Message : string.Empty); Exception innerException = e.InnerException; while (innerException != null) { string innerMessage = innerException.Message; if (innerMessage != null && innerMessage.Length > 0) { message = message + " " + innerMessage; } innerException = innerException.InnerException; } return message; } /// <summary> /// method to create a version comment /// </summary> /// <param name="codeNamespace"></param> protected virtual void GenerateVersionComment(System.CodeDom.CodeNamespace codeNamespace) { codeNamespace.Comments.Add(new CodeCommentStatement(string.Empty)); codeNamespace.Comments.Add(new CodeCommentStatement(String.Format("This source code was auto-generated by {0}, Version {1}.", System.Reflection.Assembly.GetExecutingAssembly().GetName().Name, System.Environment.Version.ToString()))); codeNamespace.Comments.Add(new CodeCommentStatement(string.Empty)); } } } |
From: Daniel C. \(kzu\) <dca...@us...> - 2005-10-31 09:31:36
|
Update of /cvsroot/mvp-xml/Design/v2/src/Properties In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29101/v2/src/Properties Added Files: Resources.Designer.cs Resources.resx Log Message: Finished port to v2 of XGen and XsdGen. Removed XmlValidate as the new XML editor has built-in support for validation. --- NEW FILE: Resources.resx --- (This appears to be a binary file; contents omitted.) --- NEW FILE: Resources.Designer.cs --- (This appears to be a binary file; contents omitted.) |
From: Daniel C. \(kzu\) <dca...@us...> - 2005-10-31 09:31:36
|
Update of /cvsroot/mvp-xml/Design/v2/src/CustomTools/XsdToClasses In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29101/v2/src/CustomTools/XsdToClasses Added Files: XsdCodeGenerator.cs Log Message: Finished port to v2 of XGen and XsdGen. Removed XmlValidate as the new XML editor has built-in support for validation. --- NEW FILE: XsdCodeGenerator.cs --- #region Usage /* Usage: * Add an .xsd file to the project and set: * Build Action: Content * Custom Tool: XsdCodeGen * * Author: Daniel Cazzulino - kz...@gm... */ #endregion Usage using System; using System.IO; using System.CodeDom; using System.CodeDom.Compiler; using System.Runtime.InteropServices; using System.Xml.Schema; using System.Xml.Serialization; namespace Mvp.Xml.Design.CustomTools { /// <summary> /// Uses the XsdGeneratorLibrary to process XSD files and generate the corresponding /// classes. /// </summary> [Guid("F19A34B8-2CAF-459d-8080-FC85157A1165")] [ComVisible(true)] [CustomTool("Mvp.Xml.XsdGen", "Mvp.Xml XSD to Classes Generator", true)] [VersionSupport("8.0")] [CategorySupport(CategorySupportAttribute.CSharpCategory)] [CategorySupport(CategorySupportAttribute.VBCategory)] public class XsdCodeGenerator : CustomTool { /// <summary> /// Generates the output. /// </summary> protected override string OnGenerateCode(string inputFileName, string inputFileContent) { CodeNamespace ns = ExportCode(); return GenerateSource(ns); } private string GenerateSource(CodeNamespace ns) { CodeGeneratorOptions opt = new CodeGeneratorOptions(); opt.BracingStyle = "C"; StringWriter sw = new StringWriter(); GetCodeWriter().GenerateCodeFromNamespace(ns, sw, opt); sw.Flush(); return sw.ToString(); } private CodeNamespace ExportCode() { XmlSchema xsd; XmlSchemas schemas; LoadSchemas(out xsd, out schemas); CodeNamespace ns = new CodeNamespace(base.FileNameSpace); XmlSchemaImporter importer = new XmlSchemaImporter(schemas); XmlCodeExporter exporter = new XmlCodeExporter(ns); GenerateForElements(xsd, importer, exporter); GenerateForComplexTypes(xsd, importer, exporter); return ns; } private static void GenerateForComplexTypes(XmlSchema xsd, XmlSchemaImporter importer, XmlCodeExporter exporter) { foreach (XmlSchemaObject type in xsd.SchemaTypes.Values) { XmlSchemaComplexType ct = type as XmlSchemaComplexType; if (ct != null) { XmlTypeMapping mapping = importer.ImportSchemaType(ct.QualifiedName); exporter.ExportTypeMapping(mapping); } } } private static void GenerateForElements(XmlSchema xsd, XmlSchemaImporter importer, XmlCodeExporter exporter) { foreach (XmlSchemaElement element in xsd.Elements.Values) { XmlTypeMapping mapping = importer.ImportTypeMapping(element.QualifiedName); exporter.ExportTypeMapping(mapping); } } private void LoadSchemas(out XmlSchema xsd, out XmlSchemas schemas) { using (FileStream fs = new FileStream(base.InputFilePath, FileMode.Open)) { xsd = XmlSchema.Read(fs, null); xsd.Compile(null); } schemas = new XmlSchemas(); schemas.Add(xsd); } #region Registration and Installation /// <summary> /// Registers the generator. /// </summary> [ComRegisterFunction] public static void RegisterClass(Type type) { CustomTool.Register(typeof(XsdCodeGenerator)); } /// <summary> /// Unregisters the generator. /// </summary> [ComUnregisterFunction] public static void UnregisterClass(Type t) { CustomTool.UnRegister(typeof(XsdCodeGenerator)); } #endregion Registration and Installation } } |
From: Daniel C. \(kzu\) <dca...@us...> - 2005-10-31 09:31:36
|
Update of /cvsroot/mvp-xml/Design/v2/src/CustomTools In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29101/v2/src/CustomTools Added Files: CategorySupportAttribute.cs CustomTool.cs CustomToolAttribute.cs VersionSupportAttribute.cs Log Message: Finished port to v2 of XGen and XsdGen. Removed XmlValidate as the new XML editor has built-in support for validation. --- NEW FILE: CustomTool.cs --- using System; using System.CodeDom; using System.CodeDom.Compiler; using System.Collections; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.InteropServices; using System.Text; using System.Xml; using System.Xml.Schema; using System.Xml.Serialization; using Microsoft.Win32; using EnvDTE; using VSLangProj; using System.Globalization; namespace Mvp.Xml.Design.CustomTools { /// <summary> /// Base class for all custom tools. /// </summary> /// <remarks> /// Inheriting classes must provide a <see cref="GuidAttribute"/>, static /// methods with <see cref="ComRegisterFunctionAttribute"/> and <see cref="ComUnregisterFunctionAttribute"/>, /// which should call this class <see cref="Register"/> and <see cref="UnRegister"/> /// methods, passing the required parameters. /// </remarks> public abstract class CustomTool : VisualStudio.BaseCodeGeneratorWithSite { #region Constants /// <summary> /// {0}=VsVersion.Mayor, {1}=VsVersion.Minor, {2}=CategoryGuid, {3}=CustomTool /// </summary> const string RegistryKey = @"SOFTWARE\Microsoft\VisualStudio\{0}.{1}\Generators\{2}\{3}"; /// <summary> /// {0}=Custom Tool Name /// {1}=Tool version /// {2}=.NET Runtime version /// </summary> const string TemplateAutogenerated = @"//------------------------------------------------------------------------------ // <autogenerated> // This code was generated by the {0} tool. // Tool Version: {1} // Runtime Version: {2} // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // </autogenerated> //------------------------------------------------------------------------------ "; #endregion Constants protected override sealed byte[] GenerateCode(string inputFileName, string inputFileContent) { try { string code = OnGenerateCode(inputFileContent, inputFileContent); return ConvertStringToBytes(code); } catch (Exception ex) { if (ex is TargetInvocationException) { ex = ex.InnerException; } return ConvertStringToBytes(String.Format( CultureInfo.CurrentCulture, Properties.Resources.CustomTool_GeneralError, ex)); } } private byte[] ConvertStringToBytes(string code) { return System.Text.Encoding.UTF8.GetBytes(code); } protected abstract string OnGenerateCode(string inputFileName, string inputFileContent); public static string GetToolGeneratedCodeWarning(Type customToolType) { CustomToolAttribute attribute = (CustomToolAttribute)Attribute.GetCustomAttribute( customToolType, typeof(CustomToolAttribute), true); if (attribute == null) { throw new ArgumentException(String.Format( CultureInfo.CurrentCulture, Properties.Resources.CustomTool_ToolRequiredAttributeMissing, customToolType, typeof(CustomToolAttribute))); } return String.Format(TemplateAutogenerated, attribute.Name, ThisAssembly.Version, Environment.Version); } private static object CustomToolAttribute(CustomToolAttribute customToolAttribute) { throw new Exception("The method or operation is not implemented."); } #region Properties /// <summary> /// Provides access to the current project item selected. /// </summary> protected ProjectItem CurrentItem { get { return base.GetService(typeof(ProjectItem)) as ProjectItem; } } /// <summary> /// Provides access to the current project item selected. /// </summary> protected VSProject CurrentProject { get { if (CurrentItem != null) return CurrentItem.ContainingProject.Object as VSProject; return null; } } #endregion Properties #region Service access /// <summary> /// Provides access to services. /// </summary> /// <param name="serviceType">Service to retrieve.</param> /// <returns>The service object or null.</returns> protected override object GetService(Type serviceType) { object svc = base.GetService(serviceType); // Try the root environment. if (svc == null && CurrentItem == null) return null; VisualStudio.IOleServiceProvider ole = CurrentItem.DTE as VisualStudio.IOleServiceProvider; if (ole != null) return new VisualStudio.ServiceProvider(ole).GetService(serviceType); return null; } #endregion Service access #region Registration and Installation /// <summary> /// Registers the custom tool. /// </summary> public static void Register(Type type) { Guid generator; CustomToolAttribute tool; VersionSupportAttribute[] versions; CategorySupportAttribute[] categories; GetAttributes(type, out generator, out tool, out versions, out categories); foreach (VersionSupportAttribute version in versions) { foreach (CategorySupportAttribute category in categories) { RegisterCustomTool(generator, category.Guid, version.Version, tool.Description, tool.Name, tool.GeneratesDesignTimeCode); } } } /// <summary> /// Unregisters the custom tool. /// </summary> public static void UnRegister(Type type) { Guid generator; CustomToolAttribute tool; VersionSupportAttribute[] versions; CategorySupportAttribute[] categories; GetAttributes(type, out generator, out tool, out versions, out categories); foreach (VersionSupportAttribute version in versions) { foreach (CategorySupportAttribute category in categories) { UnRegisterCustomTool(category.Guid, version.Version, tool.Name); } } } #endregion Registration and Installation #region Helper methods /// <summary> /// Registers the custom tool. /// </summary> private static void RegisterCustomTool(Guid generator, Guid category, Version vsVersion, string description, string toolName, bool generatesDesignTimeCode) { /* * [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\[vsVersion]\Generators\[category]\[toolName]] * @="[description]" * "CLSID"="[category]" * "GeneratesDesignTimeSource"=[generatesDesignTimeCode] */ string keypath = String.Format(RegistryKey, vsVersion.Major, vsVersion.Minor, category.ToString("B"), toolName); using(RegistryKey key = Registry.LocalMachine.CreateSubKey(keypath)) { key.SetValue("", description); key.SetValue("CLSID", generator.ToString("B")); key.SetValue("GeneratesDesignTimeSource", generatesDesignTimeCode ? 1 : 0); } } /// <summary> /// Unregisters the custom tool. /// </summary> private static void UnRegisterCustomTool(Guid category, Version vsVersion, string toolName) { string key = String.Format(RegistryKey, vsVersion.Major, vsVersion.Minor, category.ToString("B"), toolName); Registry.LocalMachine.DeleteSubKey(key, false); } private static void GetAttributes(Type type, out Guid generator, out CustomToolAttribute tool, out VersionSupportAttribute[] versions, out CategorySupportAttribute[] categories) { object[] attrs; // Retrieve the GUID associated with the generator class. attrs = type.GetCustomAttributes(typeof(GuidAttribute), false); if (attrs.Length == 0) throw new ArgumentException(String.Format( CultureInfo.CurrentCulture, Properties.Resources.Tool_AttributeMissing, type, typeof(GuidAttribute))); generator = new Guid(((GuidAttribute)attrs[0]).Value); // Retrieve the custom tool information. attrs = type.GetCustomAttributes(typeof(CustomToolAttribute), false); if (attrs.Length == 0) throw new ArgumentException(String.Format( CultureInfo.CurrentCulture, Properties.Resources.Tool_AttributeMissing, type, typeof(CustomToolAttribute))); tool = (CustomToolAttribute) attrs[0]; // Retrieve the VS.NET versions supported. Can be inherited. attrs = type.GetCustomAttributes(typeof(VersionSupportAttribute), true); if (attrs.Length == 0) throw new ArgumentException(String.Format( CultureInfo.CurrentCulture, Properties.Resources.Tool_AttributeMissing, type, typeof(VersionSupportAttribute))); versions = (VersionSupportAttribute[]) attrs; // Retrieve the VS.NET generator categories supported. Can be inherited. attrs = type.GetCustomAttributes(typeof(CategorySupportAttribute), true); if (attrs.Length == 0) throw new ArgumentException(String.Format( CultureInfo.CurrentCulture, Properties.Resources.Tool_AttributeMissing, type, typeof(CategorySupportAttribute))); categories = (CategorySupportAttribute[]) attrs; } #endregion Helper methods } } --- NEW FILE: VersionSupportAttribute.cs --- using System; namespace Mvp.Xml.Design.CustomTools { /// <summary> /// Determines which versions of VS.NET are supported by the custom tool. /// </summary> [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)] public class VersionSupportAttribute : Attribute { Version _version; /// <summary> /// Initializes the attribute. /// </summary> /// <param name="version">Version supported by the tool.</param> public VersionSupportAttribute(string version) { _version = new Version(version); } /// <summary> /// Version supported by the tool. /// </summary> public Version Version { get { return _version; } } } } --- NEW FILE: CustomToolAttribute.cs --- using System; namespace Mvp.Xml.Design.CustomTools { /// <summary> /// Specifies custom tool registration information. /// </summary> [AttributeUsage(AttributeTargets.Class)] public class CustomToolAttribute : Attribute { string _name; string _description; bool _code; /// <summary> /// Assigns custom tool information to the class. /// </summary> /// <param name="name">Name of the custom tool.</param> /// <param name="description">A description of the tool.</param> /// <param name="generatesDesignTimeCode"> /// If <see langword="true" />, the IDE will try to compile on the fly the /// dependent the file associated with this tool, and make it available /// through intellisense to the rest of the project. /// </param> public CustomToolAttribute(string name, string description, bool generatesDesignTimeCode) { _name = name; _description = description; _code = generatesDesignTimeCode; } /// <summary> /// Name of the custom tool. /// </summary> public string Name { get { return _name; } } /// <summary> /// Friendly description of the tool. /// </summary> public string Description { get { return _description; } } /// <summary> /// Specifies whether the tool generates design time code to compile on the fly. /// </summary> public bool GeneratesDesignTimeCode { get { return _code; } } } } --- NEW FILE: CategorySupportAttribute.cs --- using System; namespace Mvp.Xml.Design.CustomTools { /// <summary> /// Determines which VS.NET generator categories are supported by the custom tool. /// This class also contains constants for C# and VB.NET category guids. /// </summary> [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)] public class CategorySupportAttribute : Attribute { Guid _category; /// <summary> /// VS Generator Category for C# Language. /// </summary> public const string CSharpCategory = "{FAE04EC1-301F-11D3-BF4B-00C04F79EFBC}"; /// <summary> /// VS Generator Category for VB Language. /// </summary> public const string VBCategory = "{164B10B9-B200-11D0-8C61-00A0C91E29D5}"; /// <summary> /// Initializes the attribute. /// </summary> /// <param name="categoryGuid"> /// Either <see cref="CSharpCategory"/> or <see cref="VBCategory"/>. /// </param> public CategorySupportAttribute(string categoryGuid) { _category = new Guid(categoryGuid); } /// <summary> /// The identifier of the supported category. /// </summary> public Guid Guid { get { return _category; } } } } |