Skip to content

Instantly share code, notes, and snippets.

@iamrommel
Created June 18, 2013 03:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save iamrommel/5802397 to your computer and use it in GitHub Desktop.
Save iamrommel/5802397 to your computer and use it in GitHub Desktop.
Using the Microsoft.LightSwitch.ExportProvider.dll to utilize the MEF in LightSwitch
using System;
using LightSwitchApplication.UserCode.Constants;
using Microsoft.VisualStudio.ExtensibilityHosting;
using System.Linq;
namespace LightSwitchApplication.UserCode.Premium
{
/// <summary>
/// To centralize the method selection use this factory
/// So in the future it will not be cluttered
/// </summary>
public class PremiumComponentFactory
{
public IPremiumComponent GetInstance(PremiumComponentType premiumComponentType)
{
var result = VsExportProviderService.GetExportedValues<IPremiumComponent>()
.FirstOrDefault(m => m.PremiumComponentType == premiumComponentType);
if (result == null)
throw new NotImplementedException(string.Format("The selected milk component type '{0}' does not exists from our list.", premiumComponentType.ToString()));
return result;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment