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
- EventProviderClassic.cs
- XmlEventCache.cs
- Executor.cs
- QuotedPrintableStream.cs
- ObjectStorage.cs
- NonBatchDirectoryCompiler.cs
- DataSetFieldSchema.cs
- NonParentingControl.cs
- TemplateColumn.cs
- ProcessDesigner.cs
- ITextView.cs
- OperationAbortedException.cs
- Constant.cs
- BaseAppDomainProtocolHandler.cs
- List.cs
- ProcessProtocolHandler.cs
- ByteViewer.cs
- SHA256.cs
- DataGridCell.cs
- OleDbReferenceCollection.cs
- ApplicationContext.cs
- QueryProcessor.cs
- QueryableDataSource.cs
- CounterSample.cs
- IisTraceListener.cs
- MenuItemBindingCollection.cs
- CodeSnippetTypeMember.cs
- DesignerForm.cs
- ToolStripMenuItemCodeDomSerializer.cs
- DocumentOutline.cs
- BindingList.cs
- Comparer.cs
- TreeViewCancelEvent.cs
- SelectorItemAutomationPeer.cs
- InvokePatternIdentifiers.cs
- BitmapEffectRenderDataResource.cs
- SamlConstants.cs
- Int16Animation.cs
- QueryAccessibilityHelpEvent.cs
- ReversePositionQuery.cs
- BulletedListEventArgs.cs
- PEFileEvidenceFactory.cs
- FixedSchema.cs
- DesigntimeLicenseContext.cs
- ResponseBodyWriter.cs
- AsyncStreamReader.cs
- TextBox.cs
- LoginDesigner.cs
- AnchoredBlock.cs
- ConfigXmlDocument.cs
- ContourSegment.cs
- XmlObjectSerializerWriteContextComplexJson.cs
- NodeFunctions.cs
- MeasurementDCInfo.cs
- ScriptReference.cs
- ListenerSessionConnection.cs
- EntityWithChangeTrackerStrategy.cs
- CmsInterop.cs
- XmlUnspecifiedAttribute.cs
- XDRSchema.cs
- SQLGuid.cs
- ToolStripSystemRenderer.cs
- ViewStateException.cs
- PrintController.cs
- SimpleType.cs
- CssTextWriter.cs
- OutputScopeManager.cs
- Operator.cs
- EntityDataSourceContainerNameConverter.cs
- ChtmlImageAdapter.cs
- ExpressionEditorAttribute.cs
- control.ime.cs
- TagPrefixCollection.cs
- WindowsSlider.cs
- _SslStream.cs
- InputBindingCollection.cs
- CachedFontFace.cs
- TextRangeBase.cs
- ListViewCommandEventArgs.cs
- PhysicalAddress.cs
- Queue.cs
- BuildProviderAppliesToAttribute.cs
- InputScope.cs
- hresults.cs
- ExtendedPropertyDescriptor.cs
- Stack.cs
- ExceptionUtil.cs
- ReliableOutputSessionChannel.cs
- BindingMAnagerBase.cs
- DataObjectSettingDataEventArgs.cs
- SrgsNameValueTag.cs
- MediaSystem.cs
- ElementFactory.cs
- QueryResultOp.cs
- MouseEvent.cs
- GlobalizationSection.cs
- _NestedMultipleAsyncResult.cs
- HelpInfo.cs
- RankException.cs
- CollectionViewGroupRoot.cs