Code:
/ 4.0 / 4.0 / 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. //------------------------------------------------------------------------------ //// 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
- webeventbuffer.cs
- ContractNamespaceAttribute.cs
- ConfigurationStrings.cs
- StreamingContext.cs
- ProviderConnectionPoint.cs
- Label.cs
- CacheAxisQuery.cs
- WebControlToolBoxItem.cs
- LingerOption.cs
- PersistChildrenAttribute.cs
- X509RecipientCertificateServiceElement.cs
- WorkflowPrinting.cs
- LineVisual.cs
- CompilerErrorCollection.cs
- IPAddress.cs
- sqlmetadatafactory.cs
- LocalServiceSecuritySettingsElement.cs
- FixedTextView.cs
- IndexingContentUnit.cs
- ListParagraph.cs
- MarkupCompilePass2.cs
- SignedXml.cs
- HttpHandlerActionCollection.cs
- XmlSchemaProviderAttribute.cs
- ClientData.cs
- ColorTransformHelper.cs
- TableAdapterManagerNameHandler.cs
- SettingsBase.cs
- TypeToArgumentTypeConverter.cs
- HttpDebugHandler.cs
- TypeConverterHelper.cs
- ImmComposition.cs
- CollectionEditor.cs
- LocalizedNameDescriptionPair.cs
- DataContractJsonSerializerOperationFormatter.cs
- CodeGen.cs
- HtmlButton.cs
- SingleAnimationBase.cs
- AsyncResult.cs
- OleDbDataReader.cs
- ADMembershipProvider.cs
- Compiler.cs
- LogReservationCollection.cs
- ActiveDocumentEvent.cs
- DataServiceHostFactory.cs
- SmiTypedGetterSetter.cs
- CompareValidator.cs
- StylusSystemGestureEventArgs.cs
- Parsers.cs
- LinqDataView.cs
- ClockController.cs
- CaseInsensitiveHashCodeProvider.cs
- Table.cs
- WebPartManagerInternals.cs
- TableLayoutRowStyleCollection.cs
- TextDecorationLocationValidation.cs
- ObservableDictionary.cs
- DataGridColumnHeaderItemAutomationPeer.cs
- BackgroundWorker.cs
- StoreAnnotationsMap.cs
- EncodingDataItem.cs
- SeekStoryboard.cs
- Style.cs
- MethodImplAttribute.cs
- MemberAccessException.cs
- ZipIOModeEnforcingStream.cs
- FieldMetadata.cs
- ClientSettingsProvider.cs
- CodeDelegateInvokeExpression.cs
- SiteMap.cs
- DesignerAttribute.cs
- Transform3DCollection.cs
- FileDialog.cs
- StdRegProviderWrapper.cs
- CommonObjectSecurity.cs
- HierarchicalDataBoundControl.cs
- CalendarTable.cs
- NotCondition.cs
- RoutedPropertyChangedEventArgs.cs
- NotImplementedException.cs
- Transform3DGroup.cs
- MainMenu.cs
- CatalogPartCollection.cs
- CompilerGeneratedAttribute.cs
- ArcSegment.cs
- DataKey.cs
- AttachedPropertyDescriptor.cs
- XdrBuilder.cs
- GridViewColumn.cs
- HiddenField.cs
- Command.cs
- IListConverters.cs
- DataServiceEntityAttribute.cs
- ConfigXmlCDataSection.cs
- StagingAreaInputItem.cs
- StylusPointProperties.cs
- CacheDict.cs
- Size.cs
- AuthenticationManager.cs
- PropertyEntry.cs