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

Template-Based Code Generation with SmartCode

Rate me:
Please Sign up or sign in to vote.
4.82/5 (35 votes)
25 Dec 20067 min read 101.1K   3.5K   121  
SmartCode is a template based code generator.This tutorial describes the process of building a templates to SmartCode
<?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>
  <metadata name="uiDBImages.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
    <value>17, 17</value>
  </metadata>
  <data name="uiDBImages.ImageStream" mimetype="application/x-microsoft.net.object.binary.base64">
    <value>
        AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj0yLjAuMC4w
        LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
        ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAACK
        DQAAAk1TRnQBSQFMAgEBBwEAAQkBAAEEAQABEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
        AwABQAMAASADAAEBAQABCAYAAQgYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA
        AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5
        AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA
        AWYDAAGZAwABzAIAATMDAAIzAgABMwFmAgABMwGZAgABMwHMAgABMwH/AgABZgMAAWYBMwIAAmYCAAFm
        AZkCAAFmAcwCAAFmAf8CAAGZAwABmQEzAgABmQFmAgACmQIAAZkBzAIAAZkB/wIAAcwDAAHMATMCAAHM
        AWYCAAHMAZkCAALMAgABzAH/AgAB/wFmAgAB/wGZAgAB/wHMAQABMwH/AgAB/wEAATMBAAEzAQABZgEA
        ATMBAAGZAQABMwEAAcwBAAEzAQAB/wEAAf8BMwIAAzMBAAIzAWYBAAIzAZkBAAIzAcwBAAIzAf8BAAEz
        AWYCAAEzAWYBMwEAATMCZgEAATMBZgGZAQABMwFmAcwBAAEzAWYB/wEAATMBmQIAATMBmQEzAQABMwGZ
        AWYBAAEzApkBAAEzAZkBzAEAATMBmQH/AQABMwHMAgABMwHMATMBAAEzAcwBZgEAATMBzAGZAQABMwLM
        AQABMwHMAf8BAAEzAf8BMwEAATMB/wFmAQABMwH/AZkBAAEzAf8BzAEAATMC/wEAAWYDAAFmAQABMwEA
        AWYBAAFmAQABZgEAAZkBAAFmAQABzAEAAWYBAAH/AQABZgEzAgABZgIzAQABZgEzAWYBAAFmATMBmQEA
        AWYBMwHMAQABZgEzAf8BAAJmAgACZgEzAQADZgEAAmYBmQEAAmYBzAEAAWYBmQIAAWYBmQEzAQABZgGZ
        AWYBAAFmApkBAAFmAZkBzAEAAWYBmQH/AQABZgHMAgABZgHMATMBAAFmAcwBmQEAAWYCzAEAAWYBzAH/
        AQABZgH/AgABZgH/ATMBAAFmAf8BmQEAAWYB/wHMAQABzAEAAf8BAAH/AQABzAEAApkCAAGZATMBmQEA
        AZkBAAGZAQABmQEAAcwBAAGZAwABmQIzAQABmQEAAWYBAAGZATMBzAEAAZkBAAH/AQABmQFmAgABmQFm
        ATMBAAGZATMBZgEAAZkBZgGZAQABmQFmAcwBAAGZATMB/wEAApkBMwEAApkBZgEAA5kBAAKZAcwBAAKZ
        Af8BAAGZAcwCAAGZAcwBMwEAAWYBzAFmAQABmQHMAZkBAAGZAswBAAGZAcwB/wEAAZkB/wIAAZkB/wEz
        AQABmQHMAWYBAAGZAf8BmQEAAZkB/wHMAQABmQL/AQABzAMAAZkBAAEzAQABzAEAAWYBAAHMAQABmQEA
        AcwBAAHMAQABmQEzAgABzAIzAQABzAEzAWYBAAHMATMBmQEAAcwBMwHMAQABzAEzAf8BAAHMAWYCAAHM
        AWYBMwEAAZkCZgEAAcwBZgGZAQABzAFmAcwBAAGZAWYB/wEAAcwBmQIAAcwBmQEzAQABzAGZAWYBAAHM
        ApkBAAHMAZkBzAEAAcwBmQH/AQACzAIAAswBMwEAAswBZgEAAswBmQEAA8wBAALMAf8BAAHMAf8CAAHM
        Af8BMwEAAZkB/wFmAQABzAH/AZkBAAHMAf8BzAEAAcwC/wEAAcwBAAEzAQAB/wEAAWYBAAH/AQABmQEA
        AcwBMwIAAf8CMwEAAf8BMwFmAQAB/wEzAZkBAAH/ATMBzAEAAf8BMwH/AQAB/wFmAgAB/wFmATMBAAHM
        AmYBAAH/AWYBmQEAAf8BZgHMAQABzAFmAf8BAAH/AZkCAAH/AZkBMwEAAf8BmQFmAQAB/wKZAQAB/wGZ
        AcwBAAH/AZkB/wEAAf8BzAIAAf8BzAEzAQAB/wHMAWYBAAH/AcwBmQEAAf8CzAEAAf8BzAH/AQAC/wEz
        AQABzAH/AWYBAAL/AZkBAAL/AcwBAAJmAf8BAAFmAf8BZgEAAWYC/wEAAf8CZgEAAf8BZgH/AQAC/wFm
        AQABIQEAAaUBAANfAQADdwEAA4YBAAOWAQADywEAA7IBAAPXAQAD3QEAA+MBAAPqAQAD8QEAA/gBAAHw
        AfsB/wEAAaQCoAEAA4ADAAH/AgAB/wMAAv8BAAH/AwAB/wEAAf8BAAL/AgAD/xEAIP8ZAAG1BWYBABP/
        AfcLZgH/GQABtQH/AfQCGQFmAQAT/wH3Af8C8gHxAt0ECQFmAf8ZAAG7Af8BvAHvAfQBZgEAE/8B9wP/
        BOwB8wEZAQkBZgH/FwABoQHHAbsE/wFmAQAJ/wHxAZECrgHwBf8B9wX/A/QB8wEJAWYB/xAAAbUFZgHH
        Ac8BiwLWAdUCtAGtAQAB8QH3Ae0B8AT/AfEC7wG8AQcBrgHwBP8B9wP/BOwC9AHdAWYB/xAAAbUB/wH0
        AhkBZgGLAacBAAHWAQkB3AHWAdUBrQEAArwB7wHtAbUBkQGuAWwCtQHxAf8B8QEHAa4E/wG1CP8B9AHd
        AWYB/xAAAbsB/wG8Ae8B9AFmAaECAALWAdUCtAGtAQAB8AH0AbwC9wGRAa4BbAEHAfcD/wG8Aa4E/wHv
        A/8E7AL/AfEBZgH/EAABuwT/AWYBxwkAAfMB8AG8AfEE/wEHAZEB8QH/AfEBtQGRBP8BtQn/AfIBZgH/
        EAAC1gHVArQBrQG0AYYBxwEAAbUFZgj/AfQBvAGRAfcCtQHxBP8BuwP/BOwC/wHyAWYB/xAAAdYBCQHc
        AdYB1QGtAaEBpwHPAYsBtQH/AfQCGQFmCf8B9AEHAbwB7wHxBf8Buwr/AWYB/xAAAtYB1QK0Aa0CAAGh
        AacBuwH/AbwB7wH0AWYT/wPWAbUEtAHPA60B/xoAAbsE/wFmE/8B1gIJAtwB1gXVAa0B/xoAAtYB1QK0
        Aa0T/wPWAbUEtAHPA60B/xoAAdYBCQHcAdYB1QGtIP8aAALWAdUCtAGtIP8RAA0qAgAl/wH3CWYBbAEq
        AVkBKgGaCFkBUgGaASoBABL/AfcMZgb/AbUB/wHyAfEBiwH0AbwDCQFsASoBWQEqAZoIegFSAZoBKgEA
        Av8BtQtmBP8B9wEZAgkBiwEZAgkBiwEJArUBZgb/Ae8C/wHxAYsB/wH0AhkBuwFsASoBegEqAZoIegFS
        AaABKgEAAv8B9wH0AfEC8AO8AQcCuwFmBP8B9wIZAQkBrgIZAQkBrgHdAQkBtQFmBv8BuwH/AbQB8gGu
        Af8BtQG0Ac8BuwFsASoBegEqAaAIegFSAaABKgEAAv8B7wL/BPQDGQG7AWYE/wH3AvQBCQGuAfQBGQEJ
        Aa4BGQEJAbUBZgP/AVECSwG7Av8B8gGuAv8C9AG7AWwBKgF6ASoBoAh6AVIBoAEqAQAC/wHvAf8BvAEH
        AfQCuwH0AgABCQFmBP8B9wL0AQkBrgL0AQkBrgEZAd0BtQFmAv8BSwIxAVkBuwH/AfcB8gG0Af8CtQG0
        AQcBbAEqAXoBKgH/CMMBmQHDASoBAAL/AbsE/wX0AbwBZgT/AfcC9AEJAa4C9AEJAa4B9AEZAQABZgL/
        AUsBMQEyAVkBuwP/AbQF/wFsASoB5Q0qAQAC/wG7Af8CvAH/AbsBBwH0ArsB8AFmBP8B9wH/AfQB8AGu
        Af8B9AHwAa4B/wH0AQkBZgL/AUsBMQEyAVkBtQEAAdYB1QK0Ba0BKgugASoDAAL/AbsH/wL0AfABZgT/
        AfcC/wHwAa4C/wHwAa4C/wEJAWYC/wFLATEBMgFZAbQCCQLcAtYD1QGtASoB/wqgASoDAAL/AbsB/wK8
        Af8CvAH/AgcB8gFmBP8BtQL/AfABtAL/AfABtAL/AfABZgL/AUsBMQEyAVkJtAKtAQABKgH/A6AGKgQA
        Av8Buwn/AfQBZgT/AbUD/wG0A/8BtAP/AWYC/wFLATEBMgFZAXoBoAGaAVkBdAb/AgAEKgoAAv8D1gLV
        ArQFrQT/AbUCtAGuA7QBrgO0Aa4BZgL/AUsBMQEyAVkBegGgAZoBWQF0Bv8QAAL/AdYBCQTcAdYE1QGt
        BP8BtQHwAQcB7wG0AfABBwHvAbQB8AEHAe8BZgL/AUsBMQEyAVkBegGgAZoBWQF0Bv8QAAL/BdYB1QO0
        A60E/wG1AfEBvAEHAbUB8QG8AQcBtQHxAbwBBwFmAv8BSwFZAXoBmgOgAXoBdAb/EAAS/we1BvcC/wFz
        AZoFwwGaARwG/xAAIv8BHAF0AnMBHAF0AZkH/wFCAU0BPgcAAT4DAAEoAwABQAMAASADAAEBAQABAQYA
        AQEWAAP/AQAC/wYAAf8BgQYAAf8BgQYAAf8BgQYAAf4BAQcAAQEHAAGBBgABAQGBBgABAQH/BwABQA4A
        AQMHAAH/AcAGAAH/AcAGAAH/AcAGAAH/AcAGAAGAAQMHAAEBBwABAQcAAQEHAAEBBwABAQEAATAFAAEB
        AwABBAMAAQEEAAECAgABBwcAAQcGAAGAAQ8GAAHDAf8GAAL/BgAC/wYAAv8GAAL/BgAL
</value>
  </data>
</root>

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
Web Developer
United States United States
Danilo is the creator of SmartRules, a Business Rules Engine. He is an industry consultant working primarily with companies interested in implementing dynamic rules programming concepts to add flexibility to their architectures on web, CE, and desktop platforms. He operates his own website, Kontac, where you will find more information.

To contact Danilo, email him at danilo.mendez@gmail.com.

Comments and Discussions