Code:
/ FX-1434 / FX-1434 / 1.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
- SetStateDesigner.cs
- DataKeyCollection.cs
- Encoder.cs
- HyperLinkField.cs
- Calendar.cs
- ClientScriptManager.cs
- AttachedPropertyBrowsableForTypeAttribute.cs
- WindowsBrush.cs
- SqlRemoveConstantOrderBy.cs
- MediaContextNotificationWindow.cs
- FindCriteriaCD1.cs
- RecognizedWordUnit.cs
- SchemaImporterExtension.cs
- Input.cs
- DocumentStream.cs
- DropSource.cs
- DataGridViewRowHeightInfoNeededEventArgs.cs
- PolyLineSegment.cs
- ContextMenu.cs
- FontNamesConverter.cs
- MsmqHostedTransportManager.cs
- MobileUserControl.cs
- CompoundFileStorageReference.cs
- WebFormDesignerActionService.cs
- ClientRolePrincipal.cs
- InheritablePropertyChangeInfo.cs
- RegexRunner.cs
- Native.cs
- IPEndPoint.cs
- ParameterBuilder.cs
- ApplicationServicesHostFactory.cs
- CodeSubDirectory.cs
- RSAOAEPKeyExchangeDeformatter.cs
- AudioFormatConverter.cs
- TextRange.cs
- ChangeInterceptorAttribute.cs
- RTLAwareMessageBox.cs
- MatrixStack.cs
- EventProviderWriter.cs
- RegexBoyerMoore.cs
- Enum.cs
- _UncName.cs
- EmptyControlCollection.cs
- BeginEvent.cs
- OdbcDataAdapter.cs
- SafeCryptHandles.cs
- AdRotator.cs
- StopStoryboard.cs
- SystemResources.cs
- GroupStyle.cs
- InfoCardKeyedHashAlgorithm.cs
- TablePatternIdentifiers.cs
- PresentationSource.cs
- OverrideMode.cs
- oledbconnectionstring.cs
- ResourceWriter.cs
- RowType.cs
- DataControlPagerLinkButton.cs
- XPathAxisIterator.cs
- Transform3D.cs
- BamlResourceDeserializer.cs
- GridViewDesigner.cs
- TextBox.cs
- DataGridViewDataConnection.cs
- XMLSyntaxException.cs
- DataExchangeServiceBinder.cs
- URLAttribute.cs
- FormatException.cs
- DockPanel.cs
- ValidatingCollection.cs
- WebPartCatalogCloseVerb.cs
- Focus.cs
- HttpServerProtocol.cs
- TextPattern.cs
- Util.cs
- _UriSyntax.cs
- TextServicesPropertyRanges.cs
- Accessible.cs
- SessionStateModule.cs
- EditBehavior.cs
- ThrowOnMultipleAssignment.cs
- CodeCompileUnit.cs
- FixedHyperLink.cs
- Section.cs
- Freezable.cs
- TemplateKey.cs
- ByteStack.cs
- TrustLevel.cs
- ByteStack.cs
- ClientConfigurationHost.cs
- ComponentDispatcherThread.cs
- EmissiveMaterial.cs
- ToolStripContentPanel.cs
- SystemWebCachingSectionGroup.cs
- Propagator.cs
- ConfigXmlComment.cs
- EventMap.cs
- AttachedPropertyBrowsableAttribute.cs
- IisTraceWebEventProvider.cs
- ExceptionTrace.cs