Click here to Skip to main content
15,886,110 members
Articles / Web Development / ASP.NET

XsdTidy beautifies the Xsd.exe output *with full DocBook .NET Wrapper*

Rate me:
Please Sign up or sign in to vote.
4.89/5 (32 votes)
1 Mar 20048 min read 185.6K   2.4K   72  
Refactors the Xsd.exe classes. Shipped with a full .NET wrapper of DocBook.
using System;
using System.Xml.Serialization;
using System.Xml;
using System.IO;
using System.Reflection;

namespace NDocBook.Cons
{
	using XsdTidy;

	/// <summary>
	/// Summary description for Class1.
	/// </summary>
	class Class1
	{
		/// <summary>
		/// The main entry point for the application.
		/// </summary>
		[STAThread]
		static void Main(string[] args)
		{

			try
			{
				Console.WriteLine("Xsd Beautifier,");
				Console.WriteLine("Jonathan de Halleux, 2004");
				Console.WriteLine("-------------------------");

				if (args.Length < 4)
					throw new ArgumentException("arguments must be: .dll namespacein namespaceout version");
				Console.WriteLine("Assembly containing types: <{0}>", args[0]);
				Console.WriteLine("Source namespace: <{0}>", args[1]);
				Console.WriteLine("Target namespace/assembly: <{0}>", args[2]);
				Console.WriteLine("Version: <{0}>", args[3]);
				Console.WriteLine("Current directory: {0}",Directory.GetCurrentDirectory());

				Console.WriteLine("Processing {0}", args[0]);
				if(!File.Exists(args[0]+".dll"))
					throw new ArgumentException("Could not find " + args[0] + ".dll");

				Assembly a = Assembly.Load(args[0].Trim());

				XsdWrapperGenerator gen = new XsdWrapperGenerator(
					args[2],					
					new Version(args[3])
					);

				gen.ConstructorBuild +=new StringEventHandler(gen_ConstructorBuild);
				gen.ConstructorBuildPass +=new EventHandler(gen_ConstructorBuildPass);
				gen.ConstructorDefine +=new StringEventHandler(gen_ConstructorDefine);
				gen.ConstructorDefinePass +=new EventHandler(gen_ConstructorDefinePass);
				gen.FieldBuild +=new StringEventHandler(gen_FieldBuild);
				gen.PropertyBuild +=new StringEventHandler(gen_PropertyBuild);
				gen.PropertyPass +=new EventHandler(gen_PropertyPass);
				gen.TypeBuild +=new StringEventHandler(gen_TypeBuild);
				gen.TypePass +=new EventHandler(gen_TypePass);

				foreach(Type t in a.GetExportedTypes())
				{
					if (t.Namespace == args[1])
						gen.AddClass(t);
				}
				gen.WrapClasses();
				gen.Save();
			}
			catch(Exception ex)
			{
				Console.WriteLine("Error.");
				Console.WriteLine(ex.Message);
				Console.WriteLine(ex.ToString());
			}
		}

		private static void gen_ConstructorBuild(object sender, StringEventArgs e)
		{

		}

		private static void gen_ConstructorBuildPass(object sender, EventArgs e)
		{

		}

		private static void gen_ConstructorDefine(object sender, StringEventArgs e)
		{

		}

		private static void gen_ConstructorDefinePass(object sender, EventArgs e)
		{

		}

		private static void gen_FieldBuild(object sender, StringEventArgs e)
		{

		}

		private static void gen_PropertyBuild(object sender, StringEventArgs e)
		{

		}

		private static void gen_PropertyPass(object sender, EventArgs e)
		{

		}

		private static void gen_TypeBuild(object sender, StringEventArgs e)
		{

		}

		private static void gen_TypePass(object sender, EventArgs e)
		{

		}
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Engineer
United States United States
Jonathan de Halleux is Civil Engineer in Applied Mathematics. He finished his PhD in 2004 in the rainy country of Belgium. After 2 years in the Common Language Runtime (i.e. .net), he is now working at Microsoft Research on Pex (http://research.microsoft.com/pex).

Comments and Discussions