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
- IntPtr.cs
- ObjectMaterializedEventArgs.cs
- ColumnCollection.cs
- PaperSource.cs
- MimeMultiPart.cs
- WsdlInspector.cs
- PeerNameResolver.cs
- RenderData.cs
- HierarchicalDataTemplate.cs
- OleDbDataAdapter.cs
- RowUpdatingEventArgs.cs
- RegularExpressionValidator.cs
- KnownTypeAttribute.cs
- _NetworkingPerfCounters.cs
- TextBounds.cs
- CreateUserWizardStep.cs
- ProcessModelInfo.cs
- GroupByQueryOperator.cs
- XamlTreeBuilderBamlRecordWriter.cs
- AdornerHitTestResult.cs
- StdValidatorsAndConverters.cs
- SafeUserTokenHandle.cs
- ExtentKey.cs
- StreamInfo.cs
- HttpDictionary.cs
- DictionaryCustomTypeDescriptor.cs
- BufferModeSettings.cs
- ArrayElementGridEntry.cs
- ObjectDataSourceStatusEventArgs.cs
- TableItemPattern.cs
- OracleNumber.cs
- URLAttribute.cs
- ConvertersCollection.cs
- XmlAttributeCollection.cs
- TableCellAutomationPeer.cs
- WebPartTransformer.cs
- KeyTimeConverter.cs
- ConstraintManager.cs
- NonVisualControlAttribute.cs
- Keywords.cs
- XmlSchemaProviderAttribute.cs
- WebPartChrome.cs
- IdentityReference.cs
- SwitchLevelAttribute.cs
- PermissionListSet.cs
- FlowPanelDesigner.cs
- autovalidator.cs
- BuilderElements.cs
- CustomAttributeFormatException.cs
- UseManagedPresentationElement.cs
- DateTimeHelper.cs
- SchemaImporterExtensionElementCollection.cs
- ThrowHelper.cs
- ImmutablePropertyDescriptorGridEntry.cs
- ComponentResourceKey.cs
- SharedPerformanceCounter.cs
- SamlAction.cs
- BooleanStorage.cs
- StateChangeEvent.cs
- ShapeTypeface.cs
- SingleKeyFrameCollection.cs
- X509Certificate.cs
- ActiveXSite.cs
- DataControlPagerLinkButton.cs
- LayoutUtils.cs
- CodeMemberEvent.cs
- Int64Animation.cs
- XmlSchemaProviderAttribute.cs
- BaseCodeDomTreeGenerator.cs
- MaterialGroup.cs
- ZipIOZip64EndOfCentralDirectoryBlock.cs
- Blend.cs
- MenuItemBinding.cs
- CornerRadius.cs
- TdsRecordBufferSetter.cs
- GregorianCalendar.cs
- CodeArrayCreateExpression.cs
- Version.cs
- AddInBase.cs
- ItemContainerPattern.cs
- HtmlTable.cs
- MediaElementAutomationPeer.cs
- CustomValidator.cs
- WebBrowserNavigatedEventHandler.cs
- DetectEofStream.cs
- XsltException.cs
- altserialization.cs
- LineMetrics.cs
- WorkflowEventArgs.cs
- SwitchExpression.cs
- MailDefinition.cs
- NoneExcludedImageIndexConverter.cs
- AttributeAction.cs
- Invariant.cs
- HttpProfileBase.cs
- BufferedReceiveElement.cs
- EmptyReadOnlyDictionaryInternal.cs
- XmlQualifiedName.cs
- TypeDefinition.cs
- TagElement.cs