Code:
/ DotNET / DotNET / 8.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
- HandleCollector.cs
- ComEventsInfo.cs
- HorizontalAlignConverter.cs
- WebServiceClientProxyGenerator.cs
- UpWmlPageAdapter.cs
- XPathNodeList.cs
- RectangleGeometry.cs
- DesignParameter.cs
- RelationshipWrapper.cs
- WorkflowWebService.cs
- CodeRegionDirective.cs
- BasicBrowserDialog.designer.cs
- CachedCompositeFamily.cs
- CapiSafeHandles.cs
- GridViewActionList.cs
- MarshalByRefObject.cs
- TextBoxLine.cs
- DecimalStorage.cs
- ErrorWrapper.cs
- ManagedFilter.cs
- ThaiBuddhistCalendar.cs
- CultureMapper.cs
- Token.cs
- QueryPageSettingsEventArgs.cs
- EqualityComparer.cs
- TypeExtensionSerializer.cs
- AliasedExpr.cs
- MediaTimeline.cs
- StaticContext.cs
- KnownBoxes.cs
- XComponentModel.cs
- KeyGestureConverter.cs
- ByteAnimation.cs
- XmlKeywords.cs
- StylusPoint.cs
- RegisteredHiddenField.cs
- LayoutInformation.cs
- ValidationResult.cs
- TdsParserStaticMethods.cs
- OdbcFactory.cs
- DataGridViewCellConverter.cs
- XhtmlBasicPageAdapter.cs
- DataControlFieldCell.cs
- Lease.cs
- Types.cs
- AutoResizedEvent.cs
- TypeForwardedToAttribute.cs
- DerivedKeySecurityToken.cs
- SslStream.cs
- StateMachineSubscriptionManager.cs
- DayRenderEvent.cs
- TransactionFlowElement.cs
- RadioButton.cs
- MailDefinition.cs
- TypedTableBaseExtensions.cs
- ChangePassword.cs
- BindingMAnagerBase.cs
- TemplateBuilder.cs
- TypeConverterHelper.cs
- DllNotFoundException.cs
- Attributes.cs
- IdentifierService.cs
- CalendarDataBindingHandler.cs
- DictionaryEntry.cs
- XslException.cs
- FontNamesConverter.cs
- Memoizer.cs
- WebBrowserProgressChangedEventHandler.cs
- XmlSchemaRedefine.cs
- DiagnosticTraceSource.cs
- SafeArrayRankMismatchException.cs
- fixedPageContentExtractor.cs
- CheckBoxStandardAdapter.cs
- XmlSchemaCompilationSettings.cs
- HttpResponseInternalWrapper.cs
- MouseGestureValueSerializer.cs
- BatchStream.cs
- BindingExpressionUncommonField.cs
- LinqDataSourceValidationException.cs
- SQLString.cs
- BuildResult.cs
- FileSecurity.cs
- TimeoutException.cs
- SafeEventLogWriteHandle.cs
- TextStore.cs
- SmtpSection.cs
- StructuralComparisons.cs
- DocumentGridPage.cs
- StringConverter.cs
- UnsafeNativeMethodsMilCoreApi.cs
- CngProperty.cs
- ConsoleKeyInfo.cs
- BitmapImage.cs
- IncrementalHitTester.cs
- DefaultAsyncDataDispatcher.cs
- RecordConverter.cs
- DisposableCollectionWrapper.cs
- ThreadExceptionDialog.cs
- Vector3DAnimationBase.cs
- CodeDirectoryCompiler.cs