XML transforms, SlowCheetah

I had been working with web applications with the web.config transform. Which is a great feature for the builds automation and deployments.

But it is lack of the support for other config files, such as app.config for windows service projects or console applications. Or maybe an xml configuration file in your project.

After I read the Hanslmen’s blog, I found this little plugin in for Visual Studio called “SlowCheetah”. It enables you to create transforms for any configuration files. How great is that!

Download the plugin and restart your VS.

You will see the “Add Transform” option once you right click the configuration file.

http://visualstudiogallery.msdn.microsoft.com/69023d00-a4f9-4a34-a6cd-7e854ba318b5

To read this Microsoft dude’s blog,

http://sedodream.com/2011/08/17/AppconfigTransformVisualStudioAddIn.aspx

Enjoy the little time saver plugin.

Mr. Data Converter, converting csv to other formatted strings

This is a pretty cool JS plugin to convert csv formatted string to other formats.

It supports XML – Properties, XML – Nodes, JSON – Properties, JSON – Column arrays, JSON – Row arrays, Html tables, and others.

I found it very helpful for xml, JSON and html formats.

for example, a csv string as below,

ProviderName, ProviderID, OrganizationName
"Microsoft","jamcracker","Telstra"

The converted JSON – properties looks like,

[{"ProviderName":"Microsoft"," ProviderID":"jamcracker"," OrganizationName":"Telstra"}]

The converted JSON – Column array looks like,

{
  "ProviderName":["Microsoft"],
  " ProviderID":["jamcracker"],
  " OrganizationName":["Telstra"]
}

The converted JSON – Row array looks like,

[
  ["Microsoft","jamcracker","Telstra"]
]

The converted XML – Properties look like,

<?xml version="1.0" encoding="UTF-8"?>
<rows>
  <row ProviderName="Microsoft"  ProviderID="jamcracker"  OrganizationName="Telstra" ></row>
</rows>

The converted XML – Nodes look like,

<?xml version="1.0" encoding="UTF-8"?>
<rows>
  <row>
    <ProviderName>Microsoft</ProviderName>
    < ProviderID>jamcracker</ ProviderID>
    < OrganizationName>Telstra</ OrganizationName>
  </row>
</rows>

The converted Html tables look like,

<table>
  <thead>
    <tr>
      <th class="ProviderName-cell">ProviderName</th>
      <th class=" ProviderID-cell"> ProviderID</th>
      <th class=" OrganizationName-cell"> OrganizationName</th>
    </tr>
  </thead>
  <tbody>
    <tr class="lastRow">
      <td class="ProviderName-cell">Microsoft</td>
      <td class=" ProviderID-cell">jamcracker</td>
      <td class=" OrganizationName-cell">Telstra</td>
    </tr>
  </tbody>
</table>

So cool, isn’t it. Save tons of time for my development.

It is from the website, http://www.shancarter.com/data_converter/index.html

And to download from Github, https://github.com/shancarter/Mr-Data-Converter

Make use of XmlSerializer

I have a list of “Order” objects. And output a xml, here is what I did by using a XmlSerializer.

using (var memoryStream = new MemoryStream())
            {
                using (TextWriter streamWriter = new StreamWriter(memoryStream))
                {
                    System.Xml.Serialization.XmlSerializer x = new System.Xml.Serialization.XmlSerializer(orders.GetType());
                    x.Serialize(streamWriter, orders);
                    return File(memoryStream.ToArray(),"xml/text");
                }
            }