当前位置: 首页>>代码示例>>C#>>正文


C# UserStore.Dispose方法代码示例

本文整理汇总了C#中UserStore.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# UserStore.Dispose方法的具体用法?C# UserStore.Dispose怎么用?C# UserStore.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UserStore的用法示例。


在下文中一共展示了UserStore.Dispose方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: UserStoreMethodsThrowWhenDisposedTest

 public void UserStoreMethodsThrowWhenDisposedTest()
 {
     var db = UnitTestHelper.CreateDefaultDb();
     var store = new UserStore<IdentityUser>(db);
     store.Dispose();
     Assert.Throws<ObjectDisposedException>(() => AsyncHelper.RunSync(() => store.AddClaimAsync(null, null)));
     Assert.Throws<ObjectDisposedException>(() => AsyncHelper.RunSync(() => store.AddLoginAsync(null, null)));
     Assert.Throws<ObjectDisposedException>(() => AsyncHelper.RunSync(() => store.AddToRoleAsync(null, null)));
     Assert.Throws<ObjectDisposedException>(() => AsyncHelper.RunSync(() => store.GetClaimsAsync(null)));
     Assert.Throws<ObjectDisposedException>(() => AsyncHelper.RunSync(() => store.GetLoginsAsync(null)));
     Assert.Throws<ObjectDisposedException>(() => AsyncHelper.RunSync(() => store.GetRolesAsync(null)));
     Assert.Throws<ObjectDisposedException>(() => AsyncHelper.RunSync(() => store.IsInRoleAsync(null, null)));
     Assert.Throws<ObjectDisposedException>(() => AsyncHelper.RunSync(() => store.RemoveClaimAsync(null, null)));
     Assert.Throws<ObjectDisposedException>(() => AsyncHelper.RunSync(() => store.RemoveLoginAsync(null, null)));
     Assert.Throws<ObjectDisposedException>(
         () => AsyncHelper.RunSync(() => store.RemoveFromRoleAsync(null, null)));
     Assert.Throws<ObjectDisposedException>(() => AsyncHelper.RunSync(() => store.RemoveClaimAsync(null, null)));
     Assert.Throws<ObjectDisposedException>(() => AsyncHelper.RunSync(() => store.FindAsync(null)));
     Assert.Throws<ObjectDisposedException>(() => AsyncHelper.RunSync(() => store.FindByIdAsync(null)));
     Assert.Throws<ObjectDisposedException>(() => AsyncHelper.RunSync(() => store.FindByNameAsync(null)));
     Assert.Throws<ObjectDisposedException>(() => AsyncHelper.RunSync(() => store.UpdateAsync(null)));
     Assert.Throws<ObjectDisposedException>(() => AsyncHelper.RunSync(() => store.DeleteAsync(null)));
     Assert.Throws<ObjectDisposedException>(
         () => AsyncHelper.RunSync(() => store.SetEmailConfirmedAsync(null, true)));
     Assert.Throws<ObjectDisposedException>(() => AsyncHelper.RunSync(() => store.GetEmailConfirmedAsync(null)));
     Assert.Throws<ObjectDisposedException>(
         () => AsyncHelper.RunSync(() => store.SetPhoneNumberConfirmedAsync(null, true)));
     Assert.Throws<ObjectDisposedException>(
         () => AsyncHelper.RunSync(() => store.GetPhoneNumberConfirmedAsync(null)));
 }
开发者ID:tomi85,项目名称:aspnetidentity,代码行数:30,代码来源:UserStoreTest.cs

示例2: Should_throw_ObjectDisposedException_if_disposed

 public void Should_throw_ObjectDisposedException_if_disposed()
 {
     var target = new UserStore<IdentityUser>();
     target.Dispose();
     Assert.Throws<ObjectDisposedException>(() => target.SetLockoutEnabledAsync(new IdentityUser(), true));
 }
开发者ID:rioka,项目名称:Simple.Data.AspNet.Identity,代码行数:6,代码来源:When_setting_lockout_enabled.cs

示例3: Should_throw_ObjectDisposedException_if_disposed

 public void Should_throw_ObjectDisposedException_if_disposed()
 {
     var target = new UserStore<IdentityUser>();
     target.Dispose();
     Assert.Throws<ObjectDisposedException>(() => target.GetRolesAsync(new IdentityUser()));
 }
开发者ID:rioka,项目名称:Simple.Data.AspNet.Identity,代码行数:6,代码来源:When_getting_user_roles.cs

示例4: ReturnCurrentUserAsync

 public async Task<ApplicationUser> ReturnCurrentUserAsync()
 {
     var store = new UserStore<ApplicationUser>(new ApplicationDbContext());
     var userManager = new UserManager<ApplicationUser>(store);
     ApplicationUser user = await userManager.FindByNameAsync(User.Identity.Name);
     store.Dispose();
     userManager.Dispose();
     return user;
 }
开发者ID:russell-cook,项目名称:nvapps_template,代码行数:9,代码来源:BaseController.cs

示例5: GetUsersInRole

        public List<ApplicationUser> GetUsersInRole(string roleName)
        {
            var roleManager = new RoleManager<IdentityRole>(new RoleStore<IdentityRole>(new ApplicationDbContext()));
            var role = roleManager.FindByName(roleName).Users.First();
            roleManager.Dispose();

            var store = new UserStore<ApplicationUser>(new ApplicationDbContext());
            var userManager = new UserManager<ApplicationUser>(store);
            var usersInRole = userManager.Users.Where(u => u.Roles.Select(r => r.RoleId).Contains(role.RoleId)).ToList();
            store.Dispose();
            store.Dispose();

            return usersInRole;
        }
开发者ID:russell-cook,项目名称:nvapps_template,代码行数:14,代码来源:BaseController.cs

示例6: Should_throw_ObjectDisposedException_calling_FindByBName_and_disposed

 public void Should_throw_ObjectDisposedException_calling_FindByBName_and_disposed()
 {
     var target = new UserStore<IdentityUser>();
     target.Dispose();
     Assert.Throws<ObjectDisposedException>(() => target.GetPhoneNumberConfirmedAsync(new IdentityUser()));
 }
开发者ID:rioka,项目名称:Simple.Data.AspNet.Identity,代码行数:6,代码来源:When_getting_phone_number.cs

示例7: Should_throw_ObjectDisposedException_calling_FindByBName_and_disposed

 public void Should_throw_ObjectDisposedException_calling_FindByBName_and_disposed()
 {
     var target = new UserStore<IdentityUser>();
     target.Dispose();
     Assert.Throws<ObjectDisposedException>(() => target.SetEmailAsync(new IdentityUser(), ""));
 }
开发者ID:rioka,项目名称:Simple.Data.AspNet.Identity,代码行数:6,代码来源:When_setting_email.cs


注:本文中的UserStore.Dispose方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。