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
- OrderedHashRepartitionEnumerator.cs
- FramingChannels.cs
- ServiceProviders.cs
- ProcessHostServerConfig.cs
- BrushConverter.cs
- BaseAddressPrefixFilterElement.cs
- MonitoringDescriptionAttribute.cs
- EventLogTraceListener.cs
- FontWeightConverter.cs
- HashJoinQueryOperatorEnumerator.cs
- DataGridSortingEventArgs.cs
- DataBindingCollection.cs
- dsa.cs
- Rijndael.cs
- MetadataSerializer.cs
- GroupBox.cs
- ComboBoxItem.cs
- TileBrush.cs
- UniqueTransportManagerRegistration.cs
- UdpTransportSettingsElement.cs
- SqlComparer.cs
- MonitorWrapper.cs
- ScrollItemPattern.cs
- TemplatePartAttribute.cs
- SchemaTableOptionalColumn.cs
- DataKey.cs
- ExpressionParser.cs
- LayoutTableCell.cs
- DesignerAttribute.cs
- RuntimeTrackingProfile.cs
- QueryableFilterRepeater.cs
- ArrayTypeMismatchException.cs
- ToolStripRenderer.cs
- HtmlTable.cs
- HandlerBase.cs
- EpmSourceTree.cs
- SelectionPattern.cs
- DataServiceResponse.cs
- NextPreviousPagerField.cs
- SizeAnimationUsingKeyFrames.cs
- SeverityFilter.cs
- TypeNameConverter.cs
- AssociationSetEnd.cs
- InternalControlCollection.cs
- DbParameterCollectionHelper.cs
- QilExpression.cs
- _Events.cs
- Dictionary.cs
- PointAnimationBase.cs
- SignatureGenerator.cs
- Vector3DConverter.cs
- ScopelessEnumAttribute.cs
- EntityStoreSchemaGenerator.cs
- UnsafeNativeMethods.cs
- Ref.cs
- OleDbMetaDataFactory.cs
- XmlHierarchyData.cs
- COM2ComponentEditor.cs
- AnchoredBlock.cs
- MarkedHighlightComponent.cs
- Formatter.cs
- TextModifier.cs
- CheckBoxStandardAdapter.cs
- SqlErrorCollection.cs
- CompilerGeneratedAttribute.cs
- NumericExpr.cs
- WebServiceMethodData.cs
- RSAPKCS1SignatureFormatter.cs
- CompilerTypeWithParams.cs
- Camera.cs
- SpotLight.cs
- UserMapPath.cs
- CssTextWriter.cs
- OptimalTextSource.cs
- XmlArrayAttribute.cs
- SecureConversationDriver.cs
- NameTable.cs
- StyleReferenceConverter.cs
- DataGridViewRowEventArgs.cs
- SecurityTokenRequirement.cs
- PeerDuplexChannel.cs
- ArgIterator.cs
- FixedSOMImage.cs
- ToolboxComponentsCreatingEventArgs.cs
- ProcessThread.cs
- CmsUtils.cs
- MoveSizeWinEventHandler.cs
- NameValueCollection.cs
- Clipboard.cs
- ServiceModelEnumValidatorAttribute.cs
- ZipIOLocalFileHeader.cs
- FixedSchema.cs
- ClientBuildManager.cs
- InheritedPropertyDescriptor.cs
- XomlCompilerResults.cs
- TextControl.cs
- Geometry.cs
- StoryFragments.cs
- XXXInfos.cs
- UInt16Storage.cs