Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / ndp / fx / src / xsp / System / Web / UI / WebControls / RoleGroup.cs / 1 / RoleGroup.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.UI.WebControls { using System.ComponentModel; using System.Security.Permissions; using System.Security.Principal; using System.Web.Security; ////// Associates a collection of roles with a template. /// [AspNetHostingPermission(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal)] 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); } } }
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- DefaultValueConverter.cs
- EntityDataSourceWrapper.cs
- MsmqIntegrationSecurityMode.cs
- PeerNearMe.cs
- XomlCompilerHelpers.cs
- DiagnosticStrings.cs
- FileDialog_Vista.cs
- ClusterSafeNativeMethods.cs
- StylusEditingBehavior.cs
- DocumentSequence.cs
- BulletChrome.cs
- OverflowException.cs
- TileBrush.cs
- MasterPageCodeDomTreeGenerator.cs
- EdmScalarPropertyAttribute.cs
- RootBuilder.cs
- EmptyStringExpandableObjectConverter.cs
- TrustManager.cs
- CodeCatchClause.cs
- SiteMapHierarchicalDataSourceView.cs
- FormsAuthenticationModule.cs
- AllMembershipCondition.cs
- HandlerFactoryWrapper.cs
- EditBehavior.cs
- CodeTypeDelegate.cs
- ByteConverter.cs
- KeyedHashAlgorithm.cs
- ObjectContextServiceProvider.cs
- XmlSchemaDocumentation.cs
- ReadOnlyCollection.cs
- DCSafeHandle.cs
- ComponentResourceKeyConverter.cs
- EncodingNLS.cs
- HtmlContainerControl.cs
- ConfigurationPropertyCollection.cs
- LowerCaseStringConverter.cs
- prefixendpointaddressmessagefilter.cs
- BookmarkEventArgs.cs
- DetailsViewPagerRow.cs
- ColorPalette.cs
- ObjectNotFoundException.cs
- _RequestCacheProtocol.cs
- ImageBrush.cs
- TrustLevelCollection.cs
- CrossContextChannel.cs
- CapacityStreamGeometryContext.cs
- HttpApplication.cs
- DataGridViewMethods.cs
- MetaModel.cs
- StoreItemCollection.cs
- FixedTextSelectionProcessor.cs
- UpDownBase.cs
- METAHEADER.cs
- XPathQueryGenerator.cs
- RawKeyboardInputReport.cs
- NavigationPropertyEmitter.cs
- TextBlockAutomationPeer.cs
- StreamGeometry.cs
- BindValidator.cs
- XmlImplementation.cs
- IProvider.cs
- LayoutTableCell.cs
- StorageEntityContainerMapping.cs
- LayoutEngine.cs
- XmlResolver.cs
- ApplicationDirectory.cs
- TraceContextRecord.cs
- KeyedCollection.cs
- DataProtection.cs
- GeometryModel3D.cs
- DebuggerAttributes.cs
- ListChunk.cs
- followingsibling.cs
- Convert.cs
- CommandDevice.cs
- ThemeDirectoryCompiler.cs
- querybuilder.cs
- SecurityUtils.cs
- EventLogPermission.cs
- ButtonPopupAdapter.cs
- XmlSchemaAttributeGroup.cs
- TypeResolvingOptionsAttribute.cs
- TypedRowGenerator.cs
- CodeDirectionExpression.cs
- Decoder.cs
- NativeMethods.cs
- ConstrainedDataObject.cs
- XmlElementElementCollection.cs
- HtmlWindowCollection.cs
- UnSafeCharBuffer.cs
- _NetworkingPerfCounters.cs
- Journaling.cs
- ExceptionUtil.cs
- BaseAddressPrefixFilterElement.cs
- TextDecorationCollection.cs
- DrawingContextWalker.cs
- TreeBuilder.cs
- MetabaseSettingsIis7.cs
- Vector3DAnimationUsingKeyFrames.cs
- RenderCapability.cs