Are you ready for HTML5

With HTML5 becoming more of the norm, well if it’s not it is about to be, and IE6 not supporting it (hang on IE9 does not currently support it either!), so it will just have to be dumped, at last  ðŸ™‚  As us developers will need to get up to speed on HTML5 there is a new resource available from Google, HTML5Rocks, lots of great resource and information available on this site

MEF not supporting open generic types

If you are trying to use MEF with open generic types like:

[Export(typeof(IRepository<>))]
public class itial; padding: 0px; margin: 0px; border: 0px initial initial;">Repository<T> : IRepository<al; background-color: transparent; color: black; background-position: initial initial; background-repeat: initial initial; padding: 0px; margin: 0px; border: 0px initial initial;">T>
   
where T : class
{

With an import of

[Import(typeof(IRepository<>))]
private IRepository<Contact> repository;

You’ll come stuck, as the current implementation MEF does not support Open Generic Types.

For more information take a look at Glenn Block article Why doesn’t MEF support open-generics for exports? Because MEF is not type based

Also there is Open-generic support in the MEF Contrib, which can be found on codeplex.

The reasoning is this, MEF parts relate on contracts which are strings, not types. To illustrate, see the code below.

namespace Orders {

  public interface IOrderRepository {}

  [Export(typeof(IOrderRespository))]

  public class OrderRepository : IOrderRepository {

  }

}

Although I have passed typeof(IOrderRepsitory) to the export, that is just a convenience that gets converted to a contract name of “Orders.IOrderRepository”. The same applies to the importer…

[Export]

public class OrderService(

  [Import]

  public IOrderRepository Repository {gets;set;} 

)

The import on IOrderRepository also gets converted to a contract name of “Orders.IOrderRepository”. This way the container is able to satisfy the import as the 2 contracts match. In the same way we support closed generics, so….

public interface IRepository<T> {}

namespace Orders {

  [Export(typeof(IRepository<Order>))]

  public class OrderRepository : IRepository<Order> {

  }

}

[Export]

public class OrderService(

  [Import]

  public IRepository<Order> Repository {gets;set;} 

)

Will work because the OrderRepository is exporting the contractname “Orders.IRepository<Order>” and the OrderService is importing the same contract.

However, this is what it looks like if we try the same with open generics.

public interface IRepository<T> {}

namespace Utils {

  [Export(typeof(IRepository<>))]

  public class Repository : IRepository<T> {

  }

}

[Export]

public class OrderService(

  [Import]

  public IRepository<Order> Repository {gets;set;} 

Now the contract names will be different. The exporter will have a contract of  “Utils.IRepository<>” and the importer will have a contract of “Utils.IRepository<Order>”.

It is a simple match up, that breaks down in the open-generics case. This is because fundamentally, MEF is not matching on type.

Original article form codeplex

How to generate LINQ to SQL Mapping

You may or may not have come across the ability within LINQ to SQL to have mapping to and from your own objects.

Microsoft has a mapping builder called sqlmetal, which is a code generation tool to generate the mapping automatically.

Here is a sample command line to generate the mapping file.

sqlmetal /server:. /database:mydb /map:mydbMappings.xml /code:code.dbml

Running Gallio tests within Visual Studio

While using Gallio for performing Unit Tests within Visual Studio, I have noticed that some times you can’t run Unit Tests, or it says that no tests available, with thanks to Lee, he pointed me to a simple fix

Visual Studio can be used to run your tests in process, with the debugger. In order for a project to be “testable”, you’ll need to make sure it has the following in the csproj:

</p>
<p>&lt;ProjectTypeGuids&gt;{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}&lt;/ProjectTypeGuids&gt;</p>
<p>

 

PRETEC i-DISK – how to rescue

I recently purchased a Pertec i-Disk Bullet 32Gb, and within a hour I had broken it, it had become write protected, not sure why.  After an e-mail to Pertec support they sent me a solution to solve the problem, here is what they said and how to get your i-Disk working again

Please use USB flash drive recovery tool as attach file. And repair unworkable i-Disk Bulletproof as following procedures;

If this utility still can’t help you to repair your failure Bulletproof USB, we suggest you can send back the USB to original purchased store/vendor,

They will provide you RMA service for further check and repair process.

URescue utility repairing procedures:

1.           Backup your personal data stored in i-Disk Bulletproof if available.

2.           Plug unworkable i-Disk Bulletproof into a safety virus-free desktop or notebook computer.

3.           Execute “URescue.exe”, click “Update” button to repair i-Disk Bulletproof.

4.           Please be remind, all data stored in i-Disk Bulletproof will be deleted. Click “OK” to continue.

 

5.           Repair successfully, click “OK” to exit URescue utility.

URescue.zip (5.31 mb)