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
- MissingManifestResourceException.cs
- HitTestWithPointDrawingContextWalker.cs
- SpecularMaterial.cs
- WebBodyFormatMessageProperty.cs
- HideDisabledControlAdapter.cs
- StreamBodyWriter.cs
- EventlogProvider.cs
- Int16AnimationUsingKeyFrames.cs
- FontStyle.cs
- DataColumn.cs
- WhitespaceRuleLookup.cs
- HtmlTableCellCollection.cs
- WebPartMenu.cs
- AuthorizationSection.cs
- UserControlCodeDomTreeGenerator.cs
- DataKey.cs
- TimeIntervalCollection.cs
- WebPartDisplayModeCancelEventArgs.cs
- OutOfProcStateClientManager.cs
- NativeMethodsCLR.cs
- ContentValidator.cs
- EnumCodeDomSerializer.cs
- ListViewSelectEventArgs.cs
- WindowsListViewGroup.cs
- MetadataCache.cs
- DetailsViewPageEventArgs.cs
- PathSegment.cs
- TextElement.cs
- ActiveDocumentEvent.cs
- UnsafeNativeMethods.cs
- TransformerConfigurationWizardBase.cs
- SecurityElement.cs
- CodeSnippetExpression.cs
- XPathNodeList.cs
- MetaTable.cs
- MemoryStream.cs
- WindowsFormsSynchronizationContext.cs
- FileDialog_Vista.cs
- StoreUtilities.cs
- IRCollection.cs
- Trace.cs
- DataGridViewCellCancelEventArgs.cs
- LineServicesCallbacks.cs
- XmlAggregates.cs
- ObjectManager.cs
- SQLDecimalStorage.cs
- EditingMode.cs
- UiaCoreProviderApi.cs
- BooleanFacetDescriptionElement.cs
- HttpListenerRequest.cs
- SimpleLine.cs
- BufferModeSettings.cs
- ResourceReferenceExpressionConverter.cs
- UniqueID.cs
- Object.cs
- OpenTypeLayoutCache.cs
- TransactionChannelFaultConverter.cs
- ServiceOperationListItemList.cs
- InvalidDataException.cs
- WindowsAltTab.cs
- _SSPIWrapper.cs
- HtmlInputPassword.cs
- ToolStripDropDownButton.cs
- WindowsEditBox.cs
- QueryOptionExpression.cs
- ContextStack.cs
- InvokeMemberBinder.cs
- GeometryCollection.cs
- OneOfScalarConst.cs
- DataRelationCollection.cs
- JavaScriptObjectDeserializer.cs
- Highlights.cs
- IdentifierService.cs
- SpeakCompletedEventArgs.cs
- WaitForChangedResult.cs
- Run.cs
- DataObject.cs
- CustomWebEventKey.cs
- SourceFileBuildProvider.cs
- TimelineCollection.cs
- DefinitionUpdate.cs
- UIElement3D.cs
- ControlBuilderAttribute.cs
- HebrewNumber.cs
- Dispatcher.cs
- CompiledScopeCriteria.cs
- PageAdapter.cs
- TextDecoration.cs
- RangeValidator.cs
- NativeMethods.cs
- ItemCollection.cs
- WmlCalendarAdapter.cs
- ReadOnlyTernaryTree.cs
- CustomErrorCollection.cs
- OperationResponse.cs
- OracleConnection.cs
- GeometryHitTestResult.cs
- UIAgentAsyncParams.cs
- CategoryGridEntry.cs
- Merger.cs