/
IdentityRole.cs
86 lines (76 loc) · 2.71 KB
/
IdentityRole.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
namespace Microsoft.AspNetCore.Identity
{
/// <summary>
/// The default implementation of <see cref="IdentityRole{TKey}"/> which uses a string as the primary key.
/// </summary>
public class IdentityRole : IdentityRole<string>
{
/// <summary>
/// Initializes a new instance of <see cref="IdentityRole"/>.
/// </summary>
/// <remarks>
/// The Id property is initialized to form a new GUID string value.
/// </remarks>
public IdentityRole()
{
Id = Guid.NewGuid().ToString();
}
/// <summary>
/// Initializes a new instance of <see cref="IdentityRole"/>.
/// </summary>
/// <param name="roleName">The role name.</param>
/// <remarks>
/// The Id property is initialized to form a new GUID string value.
/// </remarks>
public IdentityRole(string roleName) : this()
{
Name = roleName;
}
}
/// <summary>
/// Represents a role in the identity system
/// </summary>
/// <typeparam name="TKey">The type used for the primary key for the role.</typeparam>
public class IdentityRole<TKey> where TKey : IEquatable<TKey>
{
/// <summary>
/// Initializes a new instance of <see cref="IdentityRole{TKey}"/>.
/// </summary>
public IdentityRole() { }
/// <summary>
/// Initializes a new instance of <see cref="IdentityRole{TKey}"/>.
/// </summary>
/// <param name="roleName">The role name.</param>
public IdentityRole(string roleName) : this()
{
Name = roleName;
}
/// <summary>
/// Gets or sets the primary key for this role.
/// </summary>
public virtual TKey Id { get; set; }
/// <summary>
/// Gets or sets the name for this role.
/// </summary>
public virtual string Name { get; set; }
/// <summary>
/// Gets or sets the normalized name for this role.
/// </summary>
public virtual string NormalizedName { get; set; }
/// <summary>
/// A random value that should change whenever a role is persisted to the store
/// </summary>
public virtual string ConcurrencyStamp { get; set; } = Guid.NewGuid().ToString();
/// <summary>
/// Returns the name of the role.
/// </summary>
/// <returns>The name of the role.</returns>
public override string ToString()
{
return Name;
}
}
}