Code:
/ FX-1434 / FX-1434 / 1.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
- NotificationContext.cs
- NamedPermissionSet.cs
- WebPartEditVerb.cs
- ConfigXmlElement.cs
- FunctionDefinition.cs
- ToolStripScrollButton.cs
- Renderer.cs
- ProjectionPathSegment.cs
- UTF32Encoding.cs
- ValidationRuleCollection.cs
- SqlTrackingWorkflowInstance.cs
- D3DImage.cs
- AutomationTextAttribute.cs
- FormatControl.cs
- Stack.cs
- ReachNamespaceInfo.cs
- DataGridViewSelectedCellCollection.cs
- SqlDataSourceConnectionPanel.cs
- FlowDocumentPageViewerAutomationPeer.cs
- AngleUtil.cs
- DataGridViewSelectedRowCollection.cs
- SpeakProgressEventArgs.cs
- CultureInfo.cs
- SqlParameterizer.cs
- TextFormatterHost.cs
- HtmlTernaryTree.cs
- Converter.cs
- ImageBrush.cs
- precedingsibling.cs
- MultiTargetingUtil.cs
- VisualStyleElement.cs
- BinaryObjectInfo.cs
- ExceptionValidationRule.cs
- RelatedView.cs
- StandardMenuStripVerb.cs
- SplashScreen.cs
- ApplicationInfo.cs
- FormViewCommandEventArgs.cs
- DataTableMappingCollection.cs
- ProcessRequestArgs.cs
- SingleTagSectionHandler.cs
- WsiProfilesElementCollection.cs
- RemotingAttributes.cs
- InvalidOleVariantTypeException.cs
- PageThemeParser.cs
- DuplicateDetector.cs
- cryptoapiTransform.cs
- PersianCalendar.cs
- DirtyTextRange.cs
- ItemsPanelTemplate.cs
- RC2CryptoServiceProvider.cs
- TracingConnection.cs
- MultipleViewPattern.cs
- Descriptor.cs
- StoreConnection.cs
- Vector3D.cs
- MetadataArtifactLoaderComposite.cs
- ScaleTransform3D.cs
- ViewValidator.cs
- SqlClientWrapperSmiStream.cs
- ShaderRenderModeValidation.cs
- StrokeCollectionDefaultValueFactory.cs
- DescendentsWalkerBase.cs
- GreenMethods.cs
- DataListGeneralPage.cs
- MasterPage.cs
- MethodCallConverter.cs
- UnsafeNativeMethods.cs
- XhtmlTextWriter.cs
- XmlNodeChangedEventArgs.cs
- BindingContext.cs
- WindowsComboBox.cs
- InterleavedZipPartStream.cs
- RegexTypeEditor.cs
- CodeGeneratorAttribute.cs
- ServiceDescription.cs
- SymmetricAlgorithm.cs
- SqlDataSource.cs
- DesignerExtenders.cs
- HttpPostedFile.cs
- Image.cs
- OptionUsage.cs
- FragmentQueryProcessor.cs
- DecoderExceptionFallback.cs
- DockPattern.cs
- _LoggingObject.cs
- Base64Decoder.cs
- SQLDateTime.cs
- MergablePropertyAttribute.cs
- ConfigXmlElement.cs
- ReferencedAssembly.cs
- LinqDataSourceHelper.cs
- UIElementAutomationPeer.cs
- ContentControl.cs
- PropertyInfoSet.cs
- __Error.cs
- TreeNodeStyle.cs
- ParentQuery.cs
- DrawingCollection.cs
- ExpressionPrinter.cs