mirror of
https://github.com/BepInEx/mono.git
synced 2026-11-19 01:31:17 -10:00
Adding reference source for System.Data System.Data.DataSetExtensions System.Data.Entity System.Data.Entity.Design System.Data.Linq System.Data.SqlXml System.ServiceModel System.ServiceModel.Activation System.ServiceModel.Activities System.ServiceModel.Channels System.ServiceModel.Discovery System.ServiceModel.Internals System.ServiceModel.Routing System.ServiceModel.WasHosting System.ServiceModel.Web System.Web System.Web.ApplicationServices System.Web.DynamicData System.Web.Entity System.Web.Entity.Design System.Web.Extensions System.Web.Mobile System.Web.Routing System.Web.Services System.Xml System.Xml.Linq
97 lines
2.7 KiB
C#
97 lines
2.7 KiB
C#
//------------------------------------------------------------------------------
|
|
// <copyright file="RoleGroup.cs" company="Microsoft">
|
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
// </copyright>
|
|
//------------------------------------------------------------------------------
|
|
|
|
namespace System.Web.UI.WebControls {
|
|
|
|
using System.ComponentModel;
|
|
using System.Security.Principal;
|
|
using System.Web.Security;
|
|
|
|
|
|
/// <devdoc>
|
|
/// Associates a collection of roles with a template.
|
|
/// </devdoc>
|
|
public sealed class RoleGroup {
|
|
private ITemplate _contentTemplate;
|
|
private string[] _roles;
|
|
|
|
|
|
/// <devdoc>
|
|
/// The template associated with the roles.
|
|
/// </devdoc>
|
|
[
|
|
Browsable(false),
|
|
DefaultValue(null),
|
|
PersistenceMode(PersistenceMode.InnerProperty),
|
|
TemplateContainer(typeof(LoginView)),
|
|
]
|
|
public ITemplate ContentTemplate {
|
|
get {
|
|
return _contentTemplate;
|
|
}
|
|
set {
|
|
_contentTemplate = value;
|
|
}
|
|
}
|
|
|
|
|
|
/// <devdoc>
|
|
/// The roles associated with the template.
|
|
/// </devdoc>
|
|
[
|
|
TypeConverterAttribute(typeof(StringArrayConverter)),
|
|
]
|
|
public string[] Roles {
|
|
get {
|
|
if (_roles == null) {
|
|
return new string[0];
|
|
}
|
|
else {
|
|
// Must clone to preserve encapsulation
|
|
return (string[]) _roles.Clone();
|
|
}
|
|
}
|
|
set {
|
|
if (value == null) {
|
|
_roles = value;
|
|
}
|
|
else {
|
|
// Must clone to preserve encapsulation
|
|
_roles = (string[]) value.Clone();
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/// <devdoc>
|
|
/// Whether the user is in any of the roles.
|
|
/// </devdoc>
|
|
public bool ContainsUser(IPrincipal user) {
|
|
if (user == null) {
|
|
throw new ArgumentNullException("user");
|
|
}
|
|
if (_roles == null) {
|
|
return false;
|
|
}
|
|
foreach (string role in _roles) {
|
|
if (user.IsInRole(role)) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
|
|
/// <devdoc>
|
|
/// For appearance in designer collection editor.
|
|
/// </devdoc>
|
|
public override string ToString() {
|
|
StringArrayConverter converter = new StringArrayConverter();
|
|
return converter.ConvertToString(Roles);
|
|
}
|
|
}
|
|
}
|