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
- DetailsViewPageEventArgs.cs
- WhitespaceRuleReader.cs
- DataIdProcessor.cs
- KnownTypeDataContractResolver.cs
- ListViewSortEventArgs.cs
- AsyncWaitHandle.cs
- ToolStripItemEventArgs.cs
- Serialization.cs
- InvokePattern.cs
- StreamMarshaler.cs
- ReverseInheritProperty.cs
- TreeNodeSelectionProcessor.cs
- PathData.cs
- FtpWebResponse.cs
- CacheVirtualItemsEvent.cs
- M3DUtil.cs
- SqlDataSourceWizardForm.cs
- SrgsGrammar.cs
- _TLSstream.cs
- VSDExceptions.cs
- ReadWriteObjectLock.cs
- IWorkflowDebuggerService.cs
- ProviderCommandInfoUtils.cs
- ArrayWithOffset.cs
- SqlSelectClauseBuilder.cs
- HttpWebResponse.cs
- FullTextLine.cs
- XmlQualifiedNameTest.cs
- InkCanvasSelection.cs
- Expander.cs
- PartialList.cs
- DropShadowBitmapEffect.cs
- XsltContext.cs
- GifBitmapDecoder.cs
- ScalarConstant.cs
- storepermissionattribute.cs
- BorderGapMaskConverter.cs
- RegistrySecurity.cs
- SizeChangedInfo.cs
- XPathCompileException.cs
- PageContent.cs
- FileVersion.cs
- SystemIPGlobalStatistics.cs
- TableCell.cs
- XhtmlBasicValidatorAdapter.cs
- BindingObserver.cs
- Group.cs
- SuppressIldasmAttribute.cs
- CommonProperties.cs
- SecurityTokenResolver.cs
- _LazyAsyncResult.cs
- ObjectStateEntryOriginalDbUpdatableDataRecord.cs
- InputLanguage.cs
- EncoderBestFitFallback.cs
- PageCodeDomTreeGenerator.cs
- ControlBuilderAttribute.cs
- SafeSecurityHelper.cs
- XmlAutoDetectWriter.cs
- Matrix.cs
- SelectorAutomationPeer.cs
- ACL.cs
- PageAsyncTask.cs
- LinkTarget.cs
- TableColumn.cs
- ThemeableAttribute.cs
- UserInitiatedNavigationPermission.cs
- QueryInterceptorAttribute.cs
- AssemblyCacheEntry.cs
- CacheManager.cs
- CryptoApi.cs
- XmlSerializerVersionAttribute.cs
- RawStylusInputReport.cs
- X509RecipientCertificateClientElement.cs
- SiteMapPath.cs
- CachedPathData.cs
- ComponentManagerBroker.cs
- SerializationInfo.cs
- ContextMenu.cs
- CompilationUnit.cs
- ControlCachePolicy.cs
- XmlSchemaExporter.cs
- DescendantQuery.cs
- Iis7Helper.cs
- CapabilitiesSection.cs
- TypedElement.cs
- DbConnectionPoolIdentity.cs
- Propagator.JoinPropagator.cs
- ButtonColumn.cs
- MetabaseServerConfig.cs
- PipelineModuleStepContainer.cs
- AffineTransform3D.cs
- UnSafeCharBuffer.cs
- ControlValuePropertyAttribute.cs
- ClonableStack.cs
- OutputCacheSettingsSection.cs
- ProxyAssemblyNotLoadedException.cs
- OpenTypeLayout.cs
- DefinitionBase.cs
- ServiceModelTimeSpanValidator.cs
- DataBindingList.cs