The following code can be used to determine this:
public static class DesignModeSo essentially you can then code in your application:
{
private static byte _mode = 255;
public static bool IsTrue
{
get
{
if (_mode == 255)
_mode = AppDomain.CurrentDomain.FriendlyName.Contains("DefaultDomain")
? (byte)1 : (byte) 0;
return _mode == 1;
}
}
}
if (DesignMode.IsTrue)
{
//don't call coredll.dll
}
else
{
//call coredll.dll
}
4 comments:
Hy Simon,
I prefer using Model View Presenter pattern. This allows me to use on the view only controls which are also working in design time on the desktop. When I have special needs I sub class user controls and adapt their behaviors. The actual business logic is then put away in a presenter which is placed in another assembly.
Daniel
You can also check if the Environment.OSVersion.PlatformID is WinCE (run time) or not (design time)
@Daniel: I also prefer to use MVP pattern on devices and I don't see how this relates to this post?
You still need something in the view to determine what to do. I typically have a base view that contains code that pulls types off the container (IoC) but in the case of design time, I need to mock out the container. This bit of code allows you to detemine desktop/design time for that reason. Other reasons are things like custom user controls that on the desktop you need to call gdi32.dll whereas on the device you call coredll.dll.
Simon.
@Christian:
Thanks, that is probably a simpler way.
Simon.
Post a Comment