Xamarin表单依赖服务don';你不能使用泛型吗?

Xamarin表单依赖服务don';你不能使用泛型吗?,xamarin,dependency-injection,xamarin.forms,Xamarin,Dependency Injection,Xamarin.forms,我试图在Xamarin.Forms中获取泛型类的实例。如果我使用以下代码,一切正常: 接口 namespace PrismNinjectApp1.Application.Interfaces { public interface IUserService { } } namespace PrismNinjectApp1.test { public interface IMyInterface<T> where T : class { } } 混凝土等级 [asse

我试图在Xamarin.Forms中获取泛型类的实例。如果我使用以下代码,一切正常:

接口

namespace PrismNinjectApp1.Application.Interfaces
{
    public interface IUserService { }
}
namespace PrismNinjectApp1.test
{
    public interface IMyInterface<T> where T : class { }
}
混凝土等级

[assembly: Dependency(typeof(PrismNinjectApp1.Application.DomainServices.UserService))]
namespace PrismNinjectApp1.Application.DomainServices
{
    public class UserService : IUserService
    {
        public UserService() { }
    }
}
[assembly: Dependency(typeof(PrismNinjectApp1.test.MyInterface<>))]
namespace PrismNinjectApp1.test
{
    public class MyInterface<T> : IMyInterface<T> where T : class { }
}
查看模型

namespace PrismNinjectApp1.ViewModels
{
    public class MainPageViewModel : BindableBase, INavigationAware
    {
        private readonly IUserService _userService;

        public MainPageViewModel()
        {
            _userService = DependencyService.Get<IUserService>();
        }
        //Implementation of INavigationAware interface (I'm using Prism)
    }
}
namespace PrismNinjectApp1.ViewModels
{
    public class MainPageViewModel : BindableBase, INavigationAware
    {
        private readonly IMyInterface<Users> _myInterface;

        public MainPageViewModel()
        {
            _myInterface = DependencyService.Get<IMyInterface<Users>>(); //Gets NULL value
        }
        //Implementation of INavigationAware interface (I'm using Prism)
    }
}
你知道我怎样才能得到这个对象实例吗

我之所以尝试这样做,是因为我想使用泛型服务和具有基本CRUD的存储库,以及具有这种结构的搜索方法

  • 应用程序(project droid和ios)
  • 共享(可移植项目)
  • 应用程序(用于外部服务-便携式项目)
  • 域-(可移植项目)
  • 数据-(便携式项目)

  • Xamarin表单版本:2.3.4.247

    您找到解决方案了吗?非常感谢你能与我分享。
    public class Users
        {
            [PrimaryKey, AutoIncrement]
            public int Id { get; set; }
            [MaxLength(100)]
            public string Name { get; set; }
        }