Skip to content

Instantly share code, notes, and snippets.

@Jalalx
Created April 29, 2015 21:18
Show Gist options
  • Save Jalalx/ec38b626cbdbd9d70a24 to your computer and use it in GitHub Desktop.
Save Jalalx/ec38b626cbdbd9d70a24 to your computer and use it in GitHub Desktop.
Unity extensions for WPF Prism apps
using System;
namespace Microsoft.Practices.Unity
{
public static class IUnityContainerExtensions
{
/// <summary>
/// Registers a ContentControl for navigation using the name parameter.
/// </summary>
/// <typeparam name="T">The type of ContentControl to register</typeparam>
/// <param name="name">The unique name to associate with the registered Page</param>
public static void RegisterTypeForNavigation<T>(this IUnityContainer container, string name)
{
container.RegisterType(typeof(object), typeof(T), name);
}
/// <summary>
/// Registers a ContentControl for navigation using a convention based approach, using the name of the type being passed in.
/// </summary>
/// <typeparam name="T">The type of ContentControl to register</typeparam>
public static void RegisterTypeForNavigation<T>(this IUnityContainer container)
{
Type type = typeof(T);
container.RegisterType(typeof(object), type, type.FullName);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment