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
- FilterQueryOptionExpression.cs
- QilCloneVisitor.cs
- ArgumentNullException.cs
- APCustomTypeDescriptor.cs
- SHA512.cs
- Root.cs
- SymbolType.cs
- GroupDescription.cs
- dbdatarecord.cs
- TableParagraph.cs
- HwndSourceKeyboardInputSite.cs
- DecoderExceptionFallback.cs
- QuestionEventArgs.cs
- CqlBlock.cs
- OleDbCommandBuilder.cs
- HttpModuleCollection.cs
- WebPartManager.cs
- CellParaClient.cs
- X509CertificateClaimSet.cs
- IdentitySection.cs
- DecoderBestFitFallback.cs
- CommandHelpers.cs
- MouseEvent.cs
- ContentPresenter.cs
- DeflateInput.cs
- SessionStateItemCollection.cs
- TextEndOfParagraph.cs
- ObjectViewListener.cs
- MultiAsyncResult.cs
- SafeHandle.cs
- SrgsElementFactoryCompiler.cs
- QueryCacheManager.cs
- WebReferencesBuildProvider.cs
- FixedSOMLineRanges.cs
- WebPartDeleteVerb.cs
- EntityCommandCompilationException.cs
- HttpListenerRequest.cs
- TrackingMemoryStreamFactory.cs
- HttpCookieCollection.cs
- XPathMultyIterator.cs
- ProxyWebPartConnectionCollection.cs
- FieldAccessException.cs
- TimeSpanStorage.cs
- TypeContext.cs
- Context.cs
- ToolboxComponentsCreatedEventArgs.cs
- ActivityBuilderHelper.cs
- FigureParaClient.cs
- XmlComplianceUtil.cs
- WebRequestModuleElement.cs
- CustomErrorsSectionWrapper.cs
- AnimationClockResource.cs
- HandoffBehavior.cs
- WizardDesigner.cs
- DesignerSerializationManager.cs
- ToolboxCategory.cs
- QilBinary.cs
- EventLogReader.cs
- TemplateControlBuildProvider.cs
- XsdBuildProvider.cs
- ListControl.cs
- InvalidWMPVersionException.cs
- DataGridViewCellContextMenuStripNeededEventArgs.cs
- PathTooLongException.cs
- CachedPathData.cs
- EncryptedType.cs
- SchemaInfo.cs
- EDesignUtil.cs
- InstancePersistence.cs
- AssociativeAggregationOperator.cs
- DetailsViewInsertedEventArgs.cs
- StringUtil.cs
- Image.cs
- Win32SafeHandles.cs
- PropertyItemInternal.cs
- SelectionChangedEventArgs.cs
- NextPreviousPagerField.cs
- RequestTimeoutManager.cs
- DataGridViewElement.cs
- BufferBuilder.cs
- BuildProvider.cs
- DataControlCommands.cs
- LocalizableResourceBuilder.cs
- ContentTypeSettingClientMessageFormatter.cs
- CollectionViewGroup.cs
- DataGridViewRow.cs
- DisplayNameAttribute.cs
- mediaeventargs.cs
- OleDbInfoMessageEvent.cs
- TabletDeviceInfo.cs
- SqlDependency.cs
- NetTcpSectionData.cs
- HitTestWithPointDrawingContextWalker.cs
- DependencyPropertyValueSerializer.cs
- Encoder.cs
- FrameworkContentElement.cs
- WebPartConnection.cs
- RoleServiceManager.cs
- IApplicationTrustManager.cs
- GenericTransactionFlowAttribute.cs