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
- LinqDataSourceDeleteEventArgs.cs
- SerializationInfoEnumerator.cs
- AssemblyLoader.cs
- RequestResizeEvent.cs
- XmlReflectionMember.cs
- X509Utils.cs
- DataGridViewRowPrePaintEventArgs.cs
- EncodingTable.cs
- SecurityTokenReferenceStyle.cs
- MetadataHelper.cs
- TypeExtension.cs
- ControlAdapter.cs
- LabelAutomationPeer.cs
- WebPartActionVerb.cs
- TempEnvironment.cs
- WpfXamlType.cs
- SectionInput.cs
- GuidelineCollection.cs
- Wizard.cs
- TrustLevelCollection.cs
- webclient.cs
- WebUtil.cs
- TextComposition.cs
- SoapHttpTransportImporter.cs
- TokenBasedSet.cs
- BindingMemberInfo.cs
- SHA1Managed.cs
- AnonymousIdentificationSection.cs
- TransformProviderWrapper.cs
- ViewStateModeByIdAttribute.cs
- DataGridViewDataConnection.cs
- DomNameTable.cs
- TemplatePropertyEntry.cs
- GeneralTransform3D.cs
- RuntimeConfigLKG.cs
- Span.cs
- ImageAttributes.cs
- CodeDomSerializationProvider.cs
- TablePatternIdentifiers.cs
- FrameworkElement.cs
- Rectangle.cs
- ProcessModule.cs
- CoordinationService.cs
- PointHitTestParameters.cs
- MaterialCollection.cs
- PageTheme.cs
- ApplicationSettingsBase.cs
- SQLResource.cs
- CngUIPolicy.cs
- TemplateXamlTreeBuilder.cs
- AppDomain.cs
- RegistryKey.cs
- QuadraticBezierSegment.cs
- EUCJPEncoding.cs
- Rfc4050KeyFormatter.cs
- SecurityUniqueId.cs
- GenericUriParser.cs
- PersonalizationState.cs
- CharacterString.cs
- TextRangeEdit.cs
- HttpConfigurationContext.cs
- VirtualDirectoryMappingCollection.cs
- SchemeSettingElement.cs
- SparseMemoryStream.cs
- StrongNameUtility.cs
- AnnotationResourceCollection.cs
- Point3D.cs
- GeneratedCodeAttribute.cs
- cache.cs
- SQLRoleProvider.cs
- NativeMethods.cs
- FlowDocumentView.cs
- XmlDocumentFragment.cs
- XmlCustomFormatter.cs
- ListViewItem.cs
- wmiprovider.cs
- SystemPens.cs
- HttpResponseHeader.cs
- ConfigurationManagerHelper.cs
- WebBaseEventKeyComparer.cs
- PermissionAttributes.cs
- SpecialFolderEnumConverter.cs
- Model3DGroup.cs
- Scene3D.cs
- RouteItem.cs
- DataBoundControlAdapter.cs
- DataAdapter.cs
- unsafenativemethodstextservices.cs
- EditorPartCollection.cs
- CounterSampleCalculator.cs
- ExpressionEvaluator.cs
- GrammarBuilderWildcard.cs
- SynthesizerStateChangedEventArgs.cs
- documentsequencetextpointer.cs
- JsonGlobals.cs
- RuntimeArgumentHandle.cs
- InfoCardPolicy.cs
- ConsumerConnectionPoint.cs
- ByteFacetDescriptionElement.cs
- ProxyWebPartManager.cs