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
- AuthenticateEventArgs.cs
- ServiceObjectContainer.cs
- TableCellCollection.cs
- LoginName.cs
- contentDescriptor.cs
- ObjectDataSourceFilteringEventArgs.cs
- followingquery.cs
- TextServicesHost.cs
- DictionaryBase.cs
- BulletChrome.cs
- PrintDocument.cs
- TextSimpleMarkerProperties.cs
- tooltip.cs
- LabelDesigner.cs
- DataGridRowEventArgs.cs
- XslUrlEditor.cs
- HwndAppCommandInputProvider.cs
- ToolStripPanelRow.cs
- SmiMetaDataProperty.cs
- PresentationSource.cs
- SpinLock.cs
- TypedTableBaseExtensions.cs
- ServiceReflector.cs
- DataGridGeneralPage.cs
- TextEditorTables.cs
- SelectionUIHandler.cs
- EventDescriptor.cs
- InlinedAggregationOperatorEnumerator.cs
- BasicBrowserDialog.cs
- BrowserCapabilitiesCompiler.cs
- PropertyChange.cs
- TransformedBitmap.cs
- ImageButton.cs
- PasswordRecoveryAutoFormat.cs
- SkipQueryOptionExpression.cs
- KeyTime.cs
- Hex.cs
- MouseDevice.cs
- StsCommunicationException.cs
- AnnotationComponentManager.cs
- PassportAuthenticationModule.cs
- ColumnCollection.cs
- CodeGotoStatement.cs
- TableRowCollection.cs
- ComplexLine.cs
- HttpModuleActionCollection.cs
- LiteralTextContainerControlBuilder.cs
- SegmentTree.cs
- ApplicationInfo.cs
- DesignerActionUIStateChangeEventArgs.cs
- WebPartConnectionsCancelVerb.cs
- BrushConverter.cs
- Window.cs
- EdmRelationshipRoleAttribute.cs
- StrokeNode.cs
- TextSelectionProcessor.cs
- CommandLibraryHelper.cs
- Update.cs
- CodeSnippetStatement.cs
- PublisherIdentityPermission.cs
- DbgCompiler.cs
- WebPartConnectionsEventArgs.cs
- RegexNode.cs
- ThemeDirectoryCompiler.cs
- ServiceProviders.cs
- CardSpaceSelector.cs
- SplitContainer.cs
- XsltContext.cs
- SqlParameter.cs
- Int32AnimationUsingKeyFrames.cs
- DataGridViewRowStateChangedEventArgs.cs
- TemplateParser.cs
- DataGridViewRowEventArgs.cs
- _NestedSingleAsyncResult.cs
- ServiceModelConfiguration.cs
- While.cs
- CriticalHandle.cs
- FlowDocumentFormatter.cs
- CommandSet.cs
- HttpProfileBase.cs
- GenericEnumerator.cs
- securestring.cs
- ConfigViewGenerator.cs
- HtmlControl.cs
- ExpressionBuilderCollection.cs
- localization.cs
- DataTrigger.cs
- Attribute.cs
- XPathConvert.cs
- SqlDataSourceView.cs
- XmlSchemaAll.cs
- RegexNode.cs
- ISAPIWorkerRequest.cs
- CompiledAction.cs
- COM2FontConverter.cs
- ScrollItemPattern.cs
- MonthChangedEventArgs.cs
- FormViewDeleteEventArgs.cs
- AdornerDecorator.cs
- NetworkInformationPermission.cs