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
- DirectionalLight.cs
- VoiceSynthesis.cs
- HttpCacheVary.cs
- DataGridViewCellErrorTextNeededEventArgs.cs
- SqlSelectStatement.cs
- SafeFileMappingHandle.cs
- OperandQuery.cs
- Encoder.cs
- NumberAction.cs
- MenuAdapter.cs
- AggregationMinMaxHelpers.cs
- QilInvokeLateBound.cs
- FunctionQuery.cs
- FormClosedEvent.cs
- SystemIcmpV4Statistics.cs
- ImageConverter.cs
- Matrix.cs
- WindowsFormsDesignerOptionService.cs
- WebPartDisplayMode.cs
- FormatterServices.cs
- Visual3DCollection.cs
- HttpSessionStateBase.cs
- Base64Stream.cs
- BackgroundWorker.cs
- MailWriter.cs
- HtmlInputReset.cs
- MailHeaderInfo.cs
- OraclePermissionAttribute.cs
- DataSourceCacheDurationConverter.cs
- SwitchLevelAttribute.cs
- ADRoleFactoryConfiguration.cs
- FormViewRow.cs
- Thumb.cs
- TreeSet.cs
- DataBinding.cs
- UrlPath.cs
- MatrixUtil.cs
- Component.cs
- UnsafeNativeMethods.cs
- SequenceNumber.cs
- CompilerGlobalScopeAttribute.cs
- TreeSet.cs
- DeclarationUpdate.cs
- ProcessManager.cs
- ExtensionSurface.cs
- EntityDataSourceColumn.cs
- ClientFormsIdentity.cs
- ConditionalAttribute.cs
- Function.cs
- Int16KeyFrameCollection.cs
- SendOperation.cs
- Control.cs
- QilFactory.cs
- ReadOnlyObservableCollection.cs
- SRGSCompiler.cs
- XmlCDATASection.cs
- ExpandoClass.cs
- SpellerHighlightLayer.cs
- OleDbCommandBuilder.cs
- DSASignatureFormatter.cs
- QueryCacheKey.cs
- SourceFileBuildProvider.cs
- DecimalAverageAggregationOperator.cs
- SafeTokenHandle.cs
- StringExpressionSet.cs
- XmlSchemaImporter.cs
- KnownTypes.cs
- ThumbAutomationPeer.cs
- SwitchExpression.cs
- SchemaImporter.cs
- ListViewDeleteEventArgs.cs
- PrimitiveSchema.cs
- TableCell.cs
- ToolStripSplitButton.cs
- NegationPusher.cs
- SubMenuStyle.cs
- DataControlFieldCell.cs
- SrgsDocument.cs
- XPathNavigator.cs
- DataGridViewRowCancelEventArgs.cs
- TextBoxAutoCompleteSourceConverter.cs
- DisplayMemberTemplateSelector.cs
- CacheOutputQuery.cs
- RoleManagerSection.cs
- ValueOfAction.cs
- CellRelation.cs
- AnimationClockResource.cs
- PoisonMessageException.cs
- ComPlusThreadInitializer.cs
- ServiceInfo.cs
- DbSetClause.cs
- StorageComplexTypeMapping.cs
- RotateTransform3D.cs
- DataGridCommandEventArgs.cs
- OutputWindow.cs
- SelectorAutomationPeer.cs
- FormViewCommandEventArgs.cs
- MediaScriptCommandRoutedEventArgs.cs
- ListenerAdapterBase.cs
- PolicyDesigner.cs