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
- AttachedAnnotation.cs
- PropertyMetadata.cs
- DataGridItemCollection.cs
- ModelVisual3D.cs
- DSASignatureFormatter.cs
- DialogResultConverter.cs
- UIntPtr.cs
- CommunicationObjectAbortedException.cs
- X509Chain.cs
- ValueType.cs
- StateDesigner.LayoutSelectionGlyph.cs
- Point4D.cs
- PanelDesigner.cs
- HttpCachePolicyElement.cs
- LostFocusEventManager.cs
- EventDescriptor.cs
- StateItem.cs
- ParameterModifier.cs
- UnsafeNativeMethods.cs
- SqlCommandBuilder.cs
- MulticastNotSupportedException.cs
- HScrollProperties.cs
- Symbol.cs
- KeySpline.cs
- ClientScriptManager.cs
- PathFigureCollectionConverter.cs
- NamespaceList.cs
- PrivilegedConfigurationManager.cs
- HtmlToClrEventProxy.cs
- ServiceElement.cs
- UndoManager.cs
- DataGridViewIntLinkedList.cs
- Clause.cs
- TextParagraphCache.cs
- Property.cs
- RC2.cs
- CryptoConfig.cs
- EventLog.cs
- Configuration.cs
- JsonDeserializer.cs
- TypedTableBaseExtensions.cs
- RowBinding.cs
- ItemCollection.cs
- SqlOuterApplyReducer.cs
- MetabaseServerConfig.cs
- Selection.cs
- HttpListenerContext.cs
- ZipIOExtraFieldElement.cs
- PassportIdentity.cs
- BindingList.cs
- SqlBuilder.cs
- EndOfStreamException.cs
- columnmapkeybuilder.cs
- ObjectSecurity.cs
- QilPatternFactory.cs
- PolicyStatement.cs
- ColorTranslator.cs
- GridViewSortEventArgs.cs
- X509CertificateRecipientServiceCredential.cs
- ErrorTolerantObjectWriter.cs
- ComplexObject.cs
- DebuggerAttributes.cs
- ModelItemCollection.cs
- TriState.cs
- SEHException.cs
- LocationSectionRecord.cs
- SemanticResolver.cs
- Metadata.cs
- OleDbMetaDataFactory.cs
- FaultDesigner.cs
- BooleanStorage.cs
- TokenBasedSetEnumerator.cs
- SessionStateModule.cs
- DefinitionBase.cs
- ProcessHost.cs
- HtmlInputReset.cs
- DiscoveryDocumentLinksPattern.cs
- GridViewEditEventArgs.cs
- WorkflowInstanceContextProvider.cs
- TreeWalkHelper.cs
- AttachInfo.cs
- SoapMessage.cs
- WorkflowViewStateService.cs
- BufferedGraphicsContext.cs
- BindingExpressionBase.cs
- ValidatorCompatibilityHelper.cs
- Quad.cs
- RuleSettings.cs
- EdgeProfileValidation.cs
- DateTimeFormatInfo.cs
- SessionEndingCancelEventArgs.cs
- FontFamilyValueSerializer.cs
- DbConnectionPool.cs
- AddressingVersion.cs
- DataObjectSettingDataEventArgs.cs
- xmlfixedPageInfo.cs
- MenuItemCollection.cs
- StatusBar.cs
- ExtenderProvidedPropertyAttribute.cs
- SafeProcessHandle.cs