Updating stores to use TypeDescriptor for type conversion
This commit is contained in:
parent
de69da85fe
commit
afff831d62
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
|
@ -160,7 +161,7 @@ namespace Microsoft.AspNet.Identity.EntityFramework
|
||||||
{
|
{
|
||||||
return default(TKey);
|
return default(TKey);
|
||||||
}
|
}
|
||||||
return (TKey)Convert.ChangeType(id, typeof(TKey));
|
return (TKey)TypeDescriptor.GetConverter(typeof(TKey)).ConvertFromInvariantString(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual string ConvertIdToString(TKey id)
|
public virtual string ConvertIdToString(TKey id)
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
|
|
@ -212,7 +213,7 @@ namespace Microsoft.AspNet.Identity.EntityFramework
|
||||||
{
|
{
|
||||||
return default(TKey);
|
return default(TKey);
|
||||||
}
|
}
|
||||||
return (TKey)Convert.ChangeType(id, typeof(TKey));
|
return (TKey)TypeDescriptor.GetConverter(typeof(TKey)).ConvertFromInvariantString(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual string ConvertIdToString(TKey id)
|
public virtual string ConvertIdToString(TKey id)
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"System.Collections": "4.0.10-beta-*",
|
"System.Collections": "4.0.10-beta-*",
|
||||||
"System.ComponentModel": "4.0.0-beta-*",
|
"System.ComponentModel": "4.0.0-beta-*",
|
||||||
|
"System.ComponentModel.TypeConverter": "4.0.0-beta-*",
|
||||||
"System.Diagnostics.Debug": "4.0.10-beta-*",
|
"System.Diagnostics.Debug": "4.0.10-beta-*",
|
||||||
"System.Diagnostics.Tools": "4.0.0-beta-*",
|
"System.Diagnostics.Tools": "4.0.0-beta-*",
|
||||||
"System.Globalization": "4.0.10-beta-*",
|
"System.Globalization": "4.0.10-beta-*",
|
||||||
|
|
|
||||||
|
|
@ -43,21 +43,11 @@ namespace Microsoft.AspNet.Identity.EntityFramework.Test
|
||||||
public class ApplicationUserStore : UserStore<GuidUser, GuidRole, TestDbContext, Guid>
|
public class ApplicationUserStore : UserStore<GuidUser, GuidRole, TestDbContext, Guid>
|
||||||
{
|
{
|
||||||
public ApplicationUserStore(TestDbContext context) : base(context) { }
|
public ApplicationUserStore(TestDbContext context) : base(context) { }
|
||||||
|
|
||||||
public override Guid ConvertIdFromString(string userId)
|
|
||||||
{
|
|
||||||
return new Guid(userId);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ApplicationRoleStore : RoleStore<GuidRole, TestDbContext, Guid>
|
public class ApplicationRoleStore : RoleStore<GuidRole, TestDbContext, Guid>
|
||||||
{
|
{
|
||||||
public ApplicationRoleStore(TestDbContext context) : base(context) { }
|
public ApplicationRoleStore(TestDbContext context) : base(context) { }
|
||||||
|
|
||||||
public override Guid ConvertIdFromString(string id)
|
|
||||||
{
|
|
||||||
return new Guid(id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void AddUserStore(IServiceCollection services, object context = null)
|
protected override void AddUserStore(IServiceCollection services, object context = null)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue