Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / xsp / System / Web / UI / WebControls / RoleGroup.cs / 1305376 / RoleGroup.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
namespace System.Web.UI.WebControls {
using System.ComponentModel;
using System.Security.Principal;
using System.Web.Security;
///
/// Associates a collection of roles with a template.
///
public sealed class RoleGroup {
private ITemplate _contentTemplate;
private string[] _roles;
///
/// The template associated with the roles.
///
[
Browsable(false),
DefaultValue(null),
PersistenceMode(PersistenceMode.InnerProperty),
TemplateContainer(typeof(LoginView)),
]
public ITemplate ContentTemplate {
get {
return _contentTemplate;
}
set {
_contentTemplate = value;
}
}
///
/// The roles associated with the template.
///
[
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();
}
}
}
///
/// Whether the user is in any of the roles.
///
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;
}
///
/// For appearance in designer collection editor.
///
public override string ToString() {
StringArrayConverter converter = new StringArrayConverter();
return converter.ConvertToString(Roles);
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- DocumentXPathNavigator.cs
- StaticSiteMapProvider.cs
- COM2PictureConverter.cs
- Update.cs
- DiscreteKeyFrames.cs
- OLEDB_Enum.cs
- QuotedPairReader.cs
- ZipIOLocalFileBlock.cs
- MethodImplAttribute.cs
- Selector.cs
- RecordManager.cs
- BinarySecretKeyIdentifierClause.cs
- SettingsAttributes.cs
- CfgParser.cs
- TextServicesManager.cs
- TransformerInfoCollection.cs
- Utils.cs
- SqlParameter.cs
- AdornerLayer.cs
- ObjectStateFormatter.cs
- DynamicUpdateCommand.cs
- WebResourceAttribute.cs
- TraceHwndHost.cs
- LineBreakRecord.cs
- SqlIdentifier.cs
- RadioButton.cs
- ErrorEventArgs.cs
- ServiceNameElement.cs
- PropertyBuilder.cs
- BitmapEffectGeneralTransform.cs
- SettingsBase.cs
- RankException.cs
- CreateUserErrorEventArgs.cs
- DataControlFieldCell.cs
- PreservationFileReader.cs
- webclient.cs
- ToolStrip.cs
- DbConnectionInternal.cs
- RoleManagerModule.cs
- IsolationInterop.cs
- GroupJoinQueryOperator.cs
- odbcmetadatafactory.cs
- AttachedPropertiesService.cs
- CodeMemberMethod.cs
- ObjectListTitleAttribute.cs
- WeakEventTable.cs
- OrderByBuilder.cs
- EventBuilder.cs
- ScrollEventArgs.cs
- Symbol.cs
- InputLanguageProfileNotifySink.cs
- Rect.cs
- FixedSOMTableRow.cs
- Win32.cs
- TextCharacters.cs
- RewritingProcessor.cs
- SystemColors.cs
- Rule.cs
- DateTimeFormatInfoScanner.cs
- PowerStatus.cs
- HtmlForm.cs
- ObjectManager.cs
- HtmlDocument.cs
- RegexEditorDialog.cs
- DataGridViewLinkCell.cs
- TypeUtil.cs
- CodeTypeReferenceExpression.cs
- HttpGetServerProtocol.cs
- AsyncCompletedEventArgs.cs
- Hashtable.cs
- ArrayExtension.cs
- LineMetrics.cs
- WebServiceHandlerFactory.cs
- SyndicationSerializer.cs
- XmlSchemaSubstitutionGroup.cs
- Canvas.cs
- OleDbDataReader.cs
- DataGridViewRowsAddedEventArgs.cs
- CommaDelimitedStringAttributeCollectionConverter.cs
- PointAnimationClockResource.cs
- CodeIdentifiers.cs
- DetailsViewInsertEventArgs.cs
- MouseGestureValueSerializer.cs
- TrackingProvider.cs
- BamlRecords.cs
- PartialToken.cs
- StorageMappingFragment.cs
- DefaultMemberAttribute.cs
- DataServiceOperationContext.cs
- PrimarySelectionGlyph.cs
- FullTextState.cs
- PartitionedDataSource.cs
- LocationChangedEventArgs.cs
- Array.cs
- MouseGestureValueSerializer.cs
- DataKey.cs
- DataQuery.cs
- FontDialog.cs
- RawMouseInputReport.cs
- MemoryStream.cs