导航到包含丹麦字母的棱镜视图

时间:2015-06-23 16:13:43

标签: unity-container prism-5

我有ÆØÅ的名字。如果我尝试导航到其中一个,我得到system.object而不是我的视图。

unity.RegisterTypeForNavigation();

public static void RegisterTypeForNavigation<T>(this IUnityContainer container)
{
    container.RegisterType(typeof(object), typeof(T), typeof(T).FullName);
}

我应该逃避FullName吗?

1 个答案:

答案 0 :(得分:0)

是的,你应该url编码类型名称,fx。像这样

public static class UnityExtensions
{
    public static void RegisterTypeForNavigation<T>(this IUnityContainer container)
    {
        container.RegisterType(typeof(object), typeof(T),Replace(typeof(T).FullName));
    }

    public static string Replace(string url)
    {
        return WebUtility.UrlEncode(url);
    }
}

导航时还需要urlencode。

public void Navigate(object navigatePath, string region = RegionNames.ContentRegion,
                         NavigationParameters parameters = null,
                         Action<NavigationResult> navigationCallback = null)
    {
        if (navigatePath == null) return;

        var path = UnityExtensions.Replace(navigatePath.ToString());

        if (parameters == null)
            _regionManager.RequestNavigate(region, path);
        else
        {
            var uri = new Uri(path, UriKind.RelativeOrAbsolute);
            if (navigationCallback == null)
                _regionManager.RequestNavigate(region, uri, parameters);
            else
                _regionManager.RequestNavigate(region, uri, navigationCallback, parameters);
        }
    }

那是