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
- SEHException.cs
- Quaternion.cs
- PlacementWorkspace.cs
- SystemWebExtensionsSectionGroup.cs
- SBCSCodePageEncoding.cs
- Enumerable.cs
- TextDocumentView.cs
- MiniParameterInfo.cs
- ChineseLunisolarCalendar.cs
- ItemCheckEvent.cs
- BitmapFrame.cs
- DataServiceException.cs
- XmlSchemaInfo.cs
- DataGridDesigner.cs
- LowerCaseStringConverter.cs
- NetStream.cs
- mda.cs
- WindowsImpersonationContext.cs
- StrokeNodeData.cs
- MemberNameValidator.cs
- InfiniteTimeSpanConverter.cs
- ProcessStartInfo.cs
- PassportAuthenticationModule.cs
- TypeUtil.cs
- SecurityPolicySection.cs
- ConsoleCancelEventArgs.cs
- ModelPerspective.cs
- SiteMapNode.cs
- PlatformCulture.cs
- shaper.cs
- WebRequest.cs
- OleDbCommandBuilder.cs
- Context.cs
- ExpressionBindingCollection.cs
- TrustSection.cs
- WriterOutput.cs
- FullTextBreakpoint.cs
- PersonalizationEntry.cs
- SiteMapDesignerDataSourceView.cs
- SqlBulkCopyColumnMappingCollection.cs
- LicenseContext.cs
- StrokeRenderer.cs
- FillRuleValidation.cs
- Function.cs
- XmlTypeMapping.cs
- FlowDocumentReader.cs
- AddInController.cs
- StrokeIntersection.cs
- WebPartCatalogAddVerb.cs
- PasswordRecovery.cs
- ProviderException.cs
- BypassElement.cs
- ByteArrayHelperWithString.cs
- HtmlTextViewAdapter.cs
- CodeGen.cs
- AssociationSetEnd.cs
- InputDevice.cs
- ChangeInterceptorAttribute.cs
- SiteMapProvider.cs
- PreProcessor.cs
- TraceSection.cs
- RepeaterItemEventArgs.cs
- ContextMenuStripActionList.cs
- ParameterToken.cs
- CodeTypeDelegate.cs
- CodeComment.cs
- TiffBitmapEncoder.cs
- UnknownBitmapDecoder.cs
- EncodingStreamWrapper.cs
- WmfPlaceableFileHeader.cs
- XPathBinder.cs
- ServiceOperation.cs
- ObjectConverter.cs
- SerTrace.cs
- SqlFormatter.cs
- IList.cs
- PageTheme.cs
- RuntimeHandles.cs
- CompositeFontFamily.cs
- LineGeometry.cs
- WinFormsSpinner.cs
- Stroke2.cs
- HwndTarget.cs
- DateRangeEvent.cs
- TableColumn.cs
- SoapIgnoreAttribute.cs
- EditingCoordinator.cs
- ForeignKeyFactory.cs
- DynamicPropertyHolder.cs
- DispatcherOperation.cs
- SHA1Managed.cs
- DefaultAutoFieldGenerator.cs
- WebBrowserDocumentCompletedEventHandler.cs
- CodeDomDesignerLoader.cs
- TCPListener.cs
- ProfileProvider.cs
- BackStopAuthenticationModule.cs
- ProfileGroupSettingsCollection.cs
- EDesignUtil.cs
- LoginView.cs