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
- XmlMapping.cs
- returneventsaver.cs
- SwitchElementsCollection.cs
- PasswordBox.cs
- ScrollBarRenderer.cs
- IHttpResponseInternal.cs
- HandledMouseEvent.cs
- TableRowGroup.cs
- TableCell.cs
- QueryOptionExpression.cs
- RotateTransform3D.cs
- DirectoryNotFoundException.cs
- WebPageTraceListener.cs
- SourceFileInfo.cs
- WebPartCollection.cs
- DBSchemaTable.cs
- MatrixStack.cs
- UnsafeNativeMethods.cs
- DataServiceCollectionOfT.cs
- XDRSchema.cs
- ArithmeticLiteral.cs
- CodeLinePragma.cs
- FileClassifier.cs
- UnsafeNativeMethods.cs
- ProviderConnectionPoint.cs
- Token.cs
- PropertyMappingExceptionEventArgs.cs
- TabPanel.cs
- WsatTransactionFormatter.cs
- ModelFactory.cs
- DbProviderFactory.cs
- FormsAuthenticationTicket.cs
- TreeNodeCollectionEditorDialog.cs
- TcpConnectionPoolSettingsElement.cs
- XmlEventCache.cs
- RunClient.cs
- DataSpaceManager.cs
- ErrorRuntimeConfig.cs
- AutomationFocusChangedEventArgs.cs
- DurableInstanceContextProvider.cs
- Content.cs
- DbLambda.cs
- DictionarySectionHandler.cs
- ObjectTypeMapping.cs
- DecimalStorage.cs
- EmbeddedMailObjectsCollection.cs
- VScrollBar.cs
- FileReader.cs
- TextSpanModifier.cs
- DataServiceProviderMethods.cs
- HttpListenerException.cs
- ReplyChannelAcceptor.cs
- MetadataLocation.cs
- ConnectionPoint.cs
- ObjectViewListener.cs
- UserNameSecurityTokenAuthenticator.cs
- ClientViaElement.cs
- DoubleConverter.cs
- SynchronizedRandom.cs
- OleDbError.cs
- SqlBulkCopy.cs
- BooleanAnimationBase.cs
- ZipIOZip64EndOfCentralDirectoryLocatorBlock.cs
- WebPartMovingEventArgs.cs
- TransportSecurityBindingElement.cs
- Int32Rect.cs
- DataServiceConfiguration.cs
- XmlEncoding.cs
- PageBuildProvider.cs
- UrlMappingCollection.cs
- DataSourceControl.cs
- Utils.cs
- ClientBase.cs
- DynamicMetaObject.cs
- Size3DConverter.cs
- DbMetaDataFactory.cs
- ProgressBarRenderer.cs
- QuaternionAnimationBase.cs
- PrintDialogException.cs
- MarkupObject.cs
- ExpressionParser.cs
- WebControlAdapter.cs
- JsonSerializer.cs
- DetailsViewInsertedEventArgs.cs
- CompilerCollection.cs
- ToolboxComponentsCreatedEventArgs.cs
- XsltException.cs
- FtpWebResponse.cs
- ScriptingJsonSerializationSection.cs
- UrlAuthFailedErrorFormatter.cs
- OpenTypeCommon.cs
- ViewStateException.cs
- ChannelBinding.cs
- EncodingTable.cs
- EncoderExceptionFallback.cs
- SerializationInfo.cs
- DependencyPropertyConverter.cs
- ObjectView.cs
- SpellerInterop.cs
- CaseInsensitiveComparer.cs