Code:
/ DotNET / DotNET / 8.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
- InfoCardKeyedHashAlgorithm.cs
- TransformerInfoCollection.cs
- FixedElement.cs
- BamlMapTable.cs
- BypassElement.cs
- SoapIgnoreAttribute.cs
- Stackframe.cs
- AuthenticationManager.cs
- TextEditorSelection.cs
- BitmapMetadataBlob.cs
- NGCPageContentCollectionSerializerAsync.cs
- ButtonAutomationPeer.cs
- CombinedHttpChannel.cs
- HwndTarget.cs
- TextTreePropertyUndoUnit.cs
- ControlCollection.cs
- HMACRIPEMD160.cs
- FileChangesMonitor.cs
- assemblycache.cs
- DataPagerCommandEventArgs.cs
- HtmlInputRadioButton.cs
- WindowsMenu.cs
- WindowsStatic.cs
- OdbcConnectionStringbuilder.cs
- InheritanceUI.cs
- DataTableReaderListener.cs
- WebAdminConfigurationHelper.cs
- PackagePart.cs
- XmlKeywords.cs
- TransformationRules.cs
- XmlSchemaExternal.cs
- TypeConverterMarkupExtension.cs
- WindowHideOrCloseTracker.cs
- DtdParser.cs
- WindowsFormsSectionHandler.cs
- TableParaClient.cs
- WeakReferenceKey.cs
- DeferredBinaryDeserializerExtension.cs
- TraceContextRecord.cs
- OleDbErrorCollection.cs
- OnOperation.cs
- PolyBezierSegment.cs
- WindowsPen.cs
- SystemIcmpV4Statistics.cs
- HotCommands.cs
- Int32RectConverter.cs
- WebMessageEncodingElement.cs
- InvariantComparer.cs
- iisPickupDirectory.cs
- ImageMetadata.cs
- TypefaceMetricsCache.cs
- MenuItem.cs
- ThrowHelper.cs
- ProtectedConfiguration.cs
- PngBitmapEncoder.cs
- DataContractFormatAttribute.cs
- Graphics.cs
- WizardStepBase.cs
- ColumnBinding.cs
- DataRelation.cs
- NativeMethods.cs
- ImageFormat.cs
- DbParameterHelper.cs
- HashCodeCombiner.cs
- AutomationElementIdentifiers.cs
- InternalTransaction.cs
- HostingEnvironment.cs
- XmlCharType.cs
- FigureParagraph.cs
- TokenCreationException.cs
- HttpHandlerAction.cs
- UIElementCollection.cs
- InternalSafeNativeMethods.cs
- BindingCollection.cs
- HorizontalAlignConverter.cs
- EventDescriptor.cs
- LayoutInformation.cs
- Identifier.cs
- ViewgenGatekeeper.cs
- InvalidAsynchronousStateException.cs
- SQLBinaryStorage.cs
- TextTreeRootNode.cs
- ScrollEventArgs.cs
- DesignerForm.cs
- PropertyCondition.cs
- AmbientLight.cs
- IImplicitResourceProvider.cs
- MouseActionConverter.cs
- OleDbWrapper.cs
- HierarchicalDataSourceIDConverter.cs
- Point4D.cs
- ConnectionProviderAttribute.cs
- FlowLayoutPanelDesigner.cs
- WebPartCollection.cs
- CollectionBase.cs
- DbModificationCommandTree.cs
- HtmlEncodedRawTextWriter.cs
- SqlMethodTransformer.cs
- ContentFilePart.cs
- CalendarBlackoutDatesCollection.cs