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
- SchemaImporterExtensionElement.cs
- IdentitySection.cs
- DataContractSerializerOperationFormatter.cs
- BlobPersonalizationState.cs
- Int32EqualityComparer.cs
- TreeNodeCollection.cs
- NotCondition.cs
- ListenerTraceUtility.cs
- TextRangeProviderWrapper.cs
- XPathCompiler.cs
- EmptyReadOnlyDictionaryInternal.cs
- InvokeHandlers.cs
- DataGridHeaderBorder.cs
- FloaterBaseParaClient.cs
- PrinterUnitConvert.cs
- TemplateContainer.cs
- CompiledQueryCacheKey.cs
- AttributedMetaModel.cs
- DaylightTime.cs
- Positioning.cs
- DataGridViewSortCompareEventArgs.cs
- ColumnResult.cs
- SortedSet.cs
- BitVector32.cs
- AccessDataSourceView.cs
- CatalogPart.cs
- DateTime.cs
- RedBlackList.cs
- UpdateRecord.cs
- SubMenuStyle.cs
- ThrowHelper.cs
- TextBreakpoint.cs
- ClientTargetCollection.cs
- DragDrop.cs
- KeyBinding.cs
- autovalidator.cs
- SetMemberBinder.cs
- ToolStripMenuItem.cs
- XmlSchemaAttribute.cs
- DiagnosticsConfiguration.cs
- BooleanConverter.cs
- MtomMessageEncoder.cs
- FixedNode.cs
- MarginCollapsingState.cs
- SafeCoTaskMem.cs
- SrgsRule.cs
- Storyboard.cs
- ViewManager.cs
- DataSourceCache.cs
- GradientStopCollection.cs
- Maps.cs
- InspectionWorker.cs
- UnsafeMethods.cs
- InfoCardServiceInstallComponent.cs
- OdbcInfoMessageEvent.cs
- OleDbErrorCollection.cs
- TextBreakpoint.cs
- CompilerInfo.cs
- ServiceContractListItem.cs
- MatrixTransform.cs
- KeyInfo.cs
- UnsafeNativeMethods.cs
- _DomainName.cs
- RelatedView.cs
- NamespaceCollection.cs
- TextViewBase.cs
- WebPartConnectionsCancelEventArgs.cs
- XmlParserContext.cs
- CodeConditionStatement.cs
- SymDocumentType.cs
- DiscoveryOperationContext.cs
- UIElementHelper.cs
- MessageQueueEnumerator.cs
- BaseCodeDomTreeGenerator.cs
- HandleValueEditor.cs
- UriSection.cs
- ObjectListCommandEventArgs.cs
- CodeConstructor.cs
- ToolStripSeparatorRenderEventArgs.cs
- ISessionStateStore.cs
- TypedReference.cs
- ResXResourceReader.cs
- ResourceAttributes.cs
- QueueProcessor.cs
- UInt64Converter.cs
- CommandExpr.cs
- GlyphTypeface.cs
- Compiler.cs
- PkcsUtils.cs
- TypedReference.cs
- TimeSpanValidatorAttribute.cs
- WebPartManagerInternals.cs
- PropertiesTab.cs
- RemoteWebConfigurationHost.cs
- FilterQueryOptionExpression.cs
- AssemblyResolver.cs
- ContentOperations.cs
- AppSecurityManager.cs
- RoleGroup.cs
- NavigationPropertyAccessor.cs