Fridathon: unstructured learning or hacking you can opt-in to do on any random Friday.
  • RelaxNG Compact Syntax vs XML Schemas: impressive!

    I’ve reading about blogging formats, undergoing specs, and the like, and I eventually ended in Tim Bray weblog, and his multi-version schema for PIE/ECHO/ATOM/Whatever (PEAW). You can look at the RelaxNG Compact Syntax version as well as the XML Schema version. Boy, 2Kb vs 6kb!! And the RelaxNG version is actually FAR more readable! And it uses the built-in XSD Types! Please, you NEED to have a look at both. [Read More]
  • XmlSerializer and XSD Type Inheritance: does it work?

    One of the most powerful XML Schema features is its hability to validate documents based on element types, instead of element names. That is no matter which element name is used in an instance document, say Customer, ` customer and CRMCustomer, as far as our XSD Schema makes them all inherit from say CustomerDef, the document will be valid. This is very important in interoperability scenarios, of course. That said, one of the most versatile and performat ways to handle XML in .NET (forget about XmlDocument) is using the XmlSerializer` class. Coupled with XSD.EXE or the technique I exposed in... [Read More]
  • Optimal string manipulation in XmlTextWriter?

    Lately I’ve been digging inside the XmlTextWriter class. I’m working on an alternate implementation to the traditional state machine based on arrays, one based on a mix of hierarchical state machines and DOM-like events propagation, for an XmlWriter-inherited class. During this investigation, I found several places where string manipulation is not optimal in aforementioned class. Specifically, even if it uses the StringBuilder class, it mixes calls to it with String.Concat, which is completely useless. Look at the following example taken from the StartDocument method (called by WriteStartDocument): [Read More]
  • Avoid the default designer for your IComponent-based classes: how to get the code view always!

    How many times you create a [WebService](http://msdn.microsoft.com/library/en-us/cpref/html/frlrfsystemwebserviceswebserviceclasstopic.asp), an [Installer](http://msdn.microsoft.com/library/en-us/cpref/html/frlrfsystemconfigurationinstallinstallerclasstopic.asp), or more generally, any class that directly or indirectly implements [IComponent](http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemComponentModelIComponentClassTopic.asp), and wish it doesn’t open the default [ComponentDesigner](http://msdn.microsoft.com/library/en-us/cpref/html/frlrfsystemcomponentmodeldesigncomponentdesignerclasstopic.asp)? The simple way to achieve it is adding the following attribute to your class declaration: [Read More]
  • Visitor Design Pattern: revisited for .NET

    The somewhat forgot Visitor Design Pattern exposed by Gamma et all (the legendary GoF book), is explored under the light of .NET and C#, and a new way of implementing it in an extensible yet easy way is discussed in my article. [Read More]
  • How to serve binary resources from a database (images and others) in ASP.NET?

    This is such a frequent question, that I thought I’d better spend some time outlining a customizable and versatile solution so that it can be reused in future scenarios. Often, binary resources such as employee pictures, office documents in a document management system, and others, are stored in a database. Now the issue is how to pull that information out of it and show it using ASP.NET. One way to solve this problem is creating a dummy ASP.NET page that simply uses Response.BinaryWrite() to output the binary field brought by the DB query, as is explained in an ASP Alliance... [Read More]
  • XSD.EXE is still useful (or how to get properties instead of fields)

    Getting code form XSD files is a great help when you have to create many entities reflecting your business logic. It also allows for easy extensibility because you only have to change the schema and generate the entities again. Using xsd.exe /c, you can get the XmlSerializer-friendly classes in a snap. What’s more, a very usefull tool by Chris Sells even makes the process automatic inside the IDE, with a custom tool. However, the problem with XSD is that it generates classes with public fields instead of property get/sets, which is far from ideal. [Read More]