Sunday, April 20, 2008
How-to get the XML representacion of a DSL Model Element
Today I had to find out how to get the XML representacion of a DSL Model Element. Here you have an extension method for Model Elements (mels) that gets the concrete serializer using the Domain XML Serializer Directory and the Domain Class Id of the target Model Element (mel).
public static string GetXML(this ModelElement mel)
{
StringBuilder xml = new StringBuilder();
DomainXmlSerializerDirectory directory = new DomainXmlSerializerDirectory();
directory.AddBehavior(CoreDesignSurfaceSerializationBehavior.Instance);
directory.AddBehavior(<#Yours DSL Serialization Behavior goes here #>.Instance);
// Gets the serializer of the Mel
DomainClassXmlSerializer serializer = directory.GetSerializer(mel.GetDomainClass().Id);
if (serializer != null)
{
using (XmlWriter writer = XmlWriter.Create(new StringWriter(xml)))
{
serializer.Write(new SerializationContext(directory), mel, writer);
}
}
else
{
Trace.TraceWarning(Resources.UnableToGetSerializer, mel.GetType().Name);
}
return xml.ToString();
}
HTH,
Adrian
Thursday, October 18, 2007
Clarius T4 Editor is out!
The beta version is available at http://www.t4editor.net. You can go, download it and provide some feedback at the Clarius T4 Forum which will be very valuable for us (Clarius) to prioritize the most important features for the RTM version!
Here is you have the links:
Victor's official announcement
Clarius T4 Editor Site
Clarius T4 Editor Forums
Clarius T4 Editor Download
Thanks!
Wednesday, October 17, 2007
Clarius is Hiring!
As Pablo said in his post Clarius is looking for candidates to fill Senior Dev Positions. You can check the details in Pablo's post too and if you are interested you can ping Pablo, me (alo AT clariusconsulting DOT net or through the contact form of this blog) or send your resume directly to Clarius job alias (which you can find in www.clariusconsulting.net).
Thanks!
Clarius is Hiring!
As Pablo said in his post Clarius is looking for candidates to fill Senior Dev Positions. You can check the details in Pablo's post too and if you are interested you can ping Pablo, me (alo AT clariusconsulting DOT net or through the contact form of this blog) or send your resume directly to Clarius job alias (which you can find in www.clariusconsulting.net).
Thanks!
Thursday, September 27, 2007
runas cmd makes your life easier
This week I had to temporaly use a different user on my machine. So at first I thought I had to move all my settings (outlook profile, firefox bookmarks, vms, etc) from my primary user to this new one. This is not a nice task. Hopefully I remembered the runas command which allowed me to run the above programs (indeed I'm currently creating this post running WLW using runas) as my primary user from the new user session. IMO this is definitily a very good tip if you have the same scenario in the feature.
Wednesday, September 26, 2007
Read source code to be a better developer
I want to give it a try. My idea is to take a look at one or two projects every week and post some conclusions of what I could learn of them. Here you have for example the latest Scott Hanselman's post showing his weekly results. So if you have in mind a really cool source code stuff, please feel free to ping me (leaving a comment to this post or using the contact me link) and let me know where I can get it! Thanks!
Tuesday, September 11, 2007
Adding a custom VS Task List Token
You probably used the TODO task list token to add a comment about what it should be done. But what about if you want to use a custom token to add a different kind of comment; for example a Review(x) comment. VS allows you to add custom task list token via Tools->Options->Environment->Task List as it's shown in the following screenshot:
So then you will able to add the Review comments and these will be appearing in the Task List comments section:
Friday, September 07, 2007
My blog is also on asp.net weblogs!
A few days ago I got an account to start blogging at weblogs.asp.net. So I decided to move the latest posts using a cool tool jes did and for now my idea is to post the same content in both blogger and asp.net blogs. I'm also considering the alternative of using the Cross-Post plugin kzu did. So you can check the new blog on asp.net and leave a comment if want to as well!
adalon on asp.net weblogs: http://weblogs.asp.net/adalon
TCI - Toolbox Controls Installer
TCI is a VS Package that is provided by the VS SDK as a redist. TCI allows you to easily add your custom Control to the VS Toolbox. For a brief introduction to TCI you can check the VS SDK documentation. Here I will try to cover what is happening under cover:
When you want to add your custom control to the VS toolbox using the TCI VS Package all you need is to tell TCI where the assembly containing the control is and notify to TCI this event incrementing a registry key. Probably the easier way to achieve these requirements is using a WIX-based installer (as the SDK sample does).
In order to tell TCI where your control is you can use the the fully qualified type name if you are installing the control in the GAC as following:
<Registry Root="HKLM" Key="Software\Microsoft\VisualStudio\9.0\ToolboxControlsInstaller\GacControl, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1631b3e7a8fbcce5, processorArchitecture=MSIL" Value="Litware Controls" Type="string" />
Or provide a location where the assembly containing the control is using the CodeBase value:
<Registry Root="HKLM" Key="Software\Microsoft\VisualStudio\9.0\ToolboxControlsInstaller\NonGacControl, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1631b3e7a8fbcce5, processorArchitecture=MSIL" Value="Litware Controls" Type="string">
<Registry Name="Codebase" Value="[#AssemblyContainingTheFile.dll]" Type="string" />
</Registry>
Finally you have to include the MSM containing the custom actions which notify TCI that a new Control has been installed:
<Merge Id="TbxCtrlsInstDefaultItemsCA" Language="1033" SourceFile="..\..\..\Redistributables\TbxCtrlsInstDefaultItemsCA.msm" DiskId="1" />
The custom action will increment or decrement the "Default Items" value of the following registry entry:
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\9.0\Packages\{2c298b35-07da-45f1-96a3-be55d91c8d7a}\Toolbox]
"Default Items"=dword:00000001
Note that the {2c298b35-07da-45f1-96a3-be55d91c8d7a} is the GUID for the TCI VS Package.
It's important to check if the TCI Redist is already installed before installing your custom controls if you targeting VS 2500. It's not necessary for VS codename "Orcas" because TCI Package is already installed. You can find the TCI VS Package in the VS's Private Assemblies directory.