The Caracas Nine

The Human Rights Foundation has a project to highlight human rights abuses in Venezuela.

They have chosen 9 representative cases from all walks of life.

The website is www.caracasnine.com .

The accompanying video:

Advertisements

Back to Certification

I’m starting the process of upgrading my MCAD certification.

After some initial confusion I have settled on the following Upgrade path:

  • 70-558: Upgrade: MCAD Skills to MCTS Windows Applications by Using the Microsoft .NET Framework
    • 70-536: TS: Microsoft .NET Framework – Application Development Foundation
    • 70-526: TS: Microsoft .NET Framework 2.0 – Windows-Based Client Development
  • 70-528: TS: Microsoft .NET Framework 2.0 – Web-based Client Development
  • 70-529: TS: Microsoft .NET Framework 2.0 – Distributed Application Development
  • 70-549: PRO: Designing and Developing Enterprise Applications by Using the Microsoft .NET Framework

70-558 is essentially a bundle of the two exams it covers.

I have a Safari Books Online subscription which is going to be very handy for this.  I’ve added the trainning kits for 70-536 and 70-526 to my bookshelf.  I don’t particulary like the Microsoft Press books but they should be a good starting point to prepare for the exam. Good thing is I won’t have hard copies to throw away.

Golf is a bourgeois sport indeed!

chavezgolf
Video: Golf is a bourgeois sport indeed – English subtitles

I know some golf-haters will agree with some of what Chavez says in the video. But this is not about Golf. This is about a Governor being scared to admit to his boss that he likes Golf.

The clip also shows the way the country is run. A Governor has to go on a talk show to ask for money to refurbish a Hotel. All sorts of decisions are made by Chavez on his Sunday show. His words become Law soon after.

Before someone points out that freedom of speech must exist in Venezuela for that journalist to speak the way she does, I’ll just remind you that Chavez has already closed down 1 TV station and 34 radio stations.

The media outlets left standing are constantly attacked for saying stuff like this, as shown in this other clip (Spanish): Globovision attacked by Chavez supporters

Satellite assemblies for custom cultures

Pre-defined Cultures

When dealing with pre-defined cultures Visual Studio does all the work for you. Add a resource file with the right culture name and build your project. A satellite assembly is created behind the scenes and placed in the output directory.

files

Notice how having the file Resources.es-VE.resx results in ResourceSpikeTest.resources.dll being created in the Debug folder, under the right sub-directory for the es-VE culture.

Also notice how the default resource file Resource.resx is not embedded in a separate assembly. This resource file (in a binary format) will be embedded in the project’s dll itself.

The project I’m working with here is a Test project since I want to write some unit tests around the satellite assembly. At this point the satellite assembly is correctly placed in the output directory, but the interesting thing about Test projects is that they don’t run from the target directory but from the TestResults folder instead.

We therefore have to deploy the satellite assembly so that it is available when the test runs.

[TestMethod]
[DeploymentItem( @"es-VE\ResourceSpikeTest.resources.dll", "es-VE")]
public void TestPredefinedCulture()
{
  Thread.CurrentThread.CurrentUICulture =
     new CultureInfo("es-VE");
  Assert.AreEqual("epale", Resource.msg);
}

The DeploymentItem attribute causes our satellite assembly to be copied from the target directory to an es-VE sub-folder inside TestResults (more specifically inside the ‘Out’ folder for each test run). With the satellite assembly correctly deployed the test will pass.

Custom Cultures

Custom cultures are a different beast. Visual Studio will not generate the satellite assembly for you. You have to do it by hand using resgen.exe an al.exe. There is plenty of information around on how to use these tools. Adding the following code to your project’s post-build events will do the trick:

mkdir "$(TargetDir)%cultureName%"

set path=%path%;"$(FrameworkSDKDir)"bin\
set baseName=Resource
set cultureName=x-en-ClientA
set namespace=ResourceSpikeTest

resgen $(ProjectDir)%baseName%.%cultureName%.resx  ^
$(ProjectDir)%namespace%.%baseName%.%cultureName%.resources

AL /t:lib ^
/out:"$(TargetDir)%cultureName%\%namespace%.resources.dll" ^
/c:%cultureName%  ^
/embed:"$(ProjectDir)%namespace%.%baseName%.%cultureName%.resources"

Now after building the project we have a satellite assembly for the x-en-ClientA culture in our target directory, just like we did for the pre-defined culture.

To be able to run a similar unit test as the previous one we must ensure that the custom culture has been properly registered in the machine where the test is running.

public UnitTest1()
{
  if (!CustomCultureIsNotRegistered("x-en-ClientA"))
  {
    var cib = new CultureAndRegionInfoBuilder("x-en-ClientA",
                    CultureAndRegionModifiers.None);

    var ci = new CultureInfo("en-AU");
    cib.LoadDataFromCultureInfo(ci);
    cib.Parent = ci;

    var ri = new RegionInfo("AU");
    cib.LoadDataFromRegionInfo(ri);
    cib.Register();
 }
}

private bool CustomCultureIsNotRegistered(string name)
{
  return CultureInfo.GetCultures(CultureTypes.UserCustomCulture)
     .ToList().Any(c => c.Name.Equals(name));
 }

And once again we need to deploy the satellite assembly using the DeploymentItem attribute in our test method.

[TestMethod]
[DeploymentItem(@"x-en-ClientA\ResourceSpikeTest.resources.dll", "x-en-ClientA")]
public void TestPredefinedCulture()
{
  Thread.CurrentThread.CurrentUICulture =
     new CultureInfo("x-en-ClientA");
  Assert.AreEqual("ClientA rocks!", Resource.msg);
}

It’s worth pointing out that when we want to reference a resource we use the strongly-typed default Resource file.  Any other resource file that we add to the project we can set to ‘No code generation’.  The strongly-typed resource file uses a ResourceManager to find the resource based on the current culture.