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
- ConfigurationElement.cs
- HtmlTextArea.cs
- PlanCompiler.cs
- ProcessProtocolHandler.cs
- XamlStackWriter.cs
- GeometryGroup.cs
- ObjectDataSourceView.cs
- Pair.cs
- Page.cs
- SimpleExpression.cs
- NumberFormatInfo.cs
- XmlReflectionImporter.cs
- DropDownButton.cs
- EdmProperty.cs
- XmlSigningNodeWriter.cs
- DoubleAnimation.cs
- WebPartTransformer.cs
- Random.cs
- CheckBoxRenderer.cs
- DrawingImage.cs
- WebPartMenu.cs
- VisualStyleInformation.cs
- PngBitmapEncoder.cs
- CellIdBoolean.cs
- ViewSimplifier.cs
- LicenseManager.cs
- WebBrowserEvent.cs
- SelectionUIService.cs
- StaticSiteMapProvider.cs
- MeasureItemEvent.cs
- SqlBinder.cs
- XmlEntityReference.cs
- MetafileHeaderWmf.cs
- CommandArguments.cs
- MarkupWriter.cs
- ELinqQueryState.cs
- ConfigurationManagerHelper.cs
- ConstrainedDataObject.cs
- XamlInt32CollectionSerializer.cs
- StatusCommandUI.cs
- BevelBitmapEffect.cs
- MessageDescriptionCollection.cs
- ApplicationSecurityInfo.cs
- DesignerView.xaml.cs
- Point4DValueSerializer.cs
- ListViewItemEventArgs.cs
- ChannelTerminatedException.cs
- SafeHandle.cs
- CopyAction.cs
- DbConnectionPoolGroupProviderInfo.cs
- RelationshipSet.cs
- SqlTriggerAttribute.cs
- JournalNavigationScope.cs
- VectorValueSerializer.cs
- SoapWriter.cs
- EntityDataSourceChangedEventArgs.cs
- datacache.cs
- __Error.cs
- ExtendedProperty.cs
- MyContact.cs
- RadialGradientBrush.cs
- ReferencedAssemblyResolver.cs
- ConsumerConnectionPoint.cs
- TrackingServices.cs
- CmsInterop.cs
- HtmlInputControl.cs
- TransformCollection.cs
- basenumberconverter.cs
- XmlWriterTraceListener.cs
- CodeGenerator.cs
- CodeSubDirectoriesCollection.cs
- HttpConfigurationContext.cs
- DocumentXmlWriter.cs
- LogWriteRestartAreaState.cs
- TextSelectionHighlightLayer.cs
- Parser.cs
- ScaleTransform.cs
- BStrWrapper.cs
- ButtonBase.cs
- ListSortDescription.cs
- Decimal.cs
- Button.cs
- Material.cs
- GeometryGroup.cs
- TextTreeFixupNode.cs
- ActivityCodeDomSerializationManager.cs
- XmlSchemaAll.cs
- DNS.cs
- SqlDelegatedTransaction.cs
- RewritingProcessor.cs
- Message.cs
- InstanceCompleteException.cs
- ImageMapEventArgs.cs
- JsonServiceDocumentSerializer.cs
- PropertySet.cs
- HScrollBar.cs
- Maps.cs
- DictionaryManager.cs
- ExpressionTextBox.xaml.cs
- TimeSpanSecondsConverter.cs