Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Services / Messaging / System / Messaging / MessageQueuePermissionAttribute.cs / 1305376 / MessageQueuePermissionAttribute.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Messaging { using System.ComponentModel; using System.Security; using System.Security.Permissions; ///[ AttributeUsage(AttributeTargets.Method | AttributeTargets.Constructor | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Assembly | AttributeTargets.Event, AllowMultiple = true, Inherited = false ), Serializable() ] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1813:AvoidUnsealedAttributes")] public class MessageQueuePermissionAttribute : CodeAccessSecurityAttribute { private string label; private string machineName; private string path; private string category; private MessageQueuePermissionAccess permissionAccess; /// public MessageQueuePermissionAttribute(SecurityAction action) : base(action) { } /// public string Category { get { return this.category; } set { string oldValue = this.category; this.category = value; Exception e = CheckProperties(); if (e != null) { this.category = oldValue; throw e; } } } /// public string Label { get { return this.label; } set { string oldValue = this.label; this.label = value; Exception e = CheckProperties(); if (e != null) { this.label = oldValue; throw e; } } } /// public string MachineName { get { return this.machineName; } set{ if (value != null && !SyntaxCheck.CheckMachineName(value)) throw new ArgumentException(Res.GetString(Res.InvalidProperty, "MachineName", value)); string oldValue = this.machineName; this.machineName = value; Exception e = CheckProperties(); if (e != null) { this.machineName = oldValue; throw e; } } } /// public string Path { get { return this.path; } set { if (value != null && value != MessageQueuePermission.Any && !MessageQueue.ValidatePath(value, false)) throw new ArgumentException(Res.GetString(Res.PathSyntax)); string oldValue = this.path; this.path = value; Exception e = CheckProperties(); if (e != null) { this.path = oldValue; throw e; } } } /// public MessageQueuePermissionAccess PermissionAccess { get { return this.permissionAccess; } set { this.permissionAccess = value; } } /// public override IPermission CreatePermission() { if (Unrestricted) return new MessageQueuePermission(PermissionState.Unrestricted); CheckProperties(); if (this.path != null) return new MessageQueuePermission(this.PermissionAccess, this.path); return new MessageQueuePermission(this.PermissionAccess, this.machineName, this.label, this.category); } private Exception CheckProperties() { if (this.path != null && (this.machineName != null || this.label != null || this.category != null)) return new InvalidOperationException(Res.GetString(Res.PermissionPathOrCriteria)); if (this.path == null && this.machineName == null && this.label == null && this.category == null) return new InvalidOperationException(Res.GetString(Res.PermissionAllNull)); return null; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ // // Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Messaging { using System.ComponentModel; using System.Security; using System.Security.Permissions; ///[ AttributeUsage(AttributeTargets.Method | AttributeTargets.Constructor | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Assembly | AttributeTargets.Event, AllowMultiple = true, Inherited = false ), Serializable() ] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1813:AvoidUnsealedAttributes")] public class MessageQueuePermissionAttribute : CodeAccessSecurityAttribute { private string label; private string machineName; private string path; private string category; private MessageQueuePermissionAccess permissionAccess; /// public MessageQueuePermissionAttribute(SecurityAction action) : base(action) { } /// public string Category { get { return this.category; } set { string oldValue = this.category; this.category = value; Exception e = CheckProperties(); if (e != null) { this.category = oldValue; throw e; } } } /// public string Label { get { return this.label; } set { string oldValue = this.label; this.label = value; Exception e = CheckProperties(); if (e != null) { this.label = oldValue; throw e; } } } /// public string MachineName { get { return this.machineName; } set{ if (value != null && !SyntaxCheck.CheckMachineName(value)) throw new ArgumentException(Res.GetString(Res.InvalidProperty, "MachineName", value)); string oldValue = this.machineName; this.machineName = value; Exception e = CheckProperties(); if (e != null) { this.machineName = oldValue; throw e; } } } /// public string Path { get { return this.path; } set { if (value != null && value != MessageQueuePermission.Any && !MessageQueue.ValidatePath(value, false)) throw new ArgumentException(Res.GetString(Res.PathSyntax)); string oldValue = this.path; this.path = value; Exception e = CheckProperties(); if (e != null) { this.path = oldValue; throw e; } } } /// public MessageQueuePermissionAccess PermissionAccess { get { return this.permissionAccess; } set { this.permissionAccess = value; } } /// public override IPermission CreatePermission() { if (Unrestricted) return new MessageQueuePermission(PermissionState.Unrestricted); CheckProperties(); if (this.path != null) return new MessageQueuePermission(this.PermissionAccess, this.path); return new MessageQueuePermission(this.PermissionAccess, this.machineName, this.label, this.category); } private Exception CheckProperties() { if (this.path != null && (this.machineName != null || this.label != null || this.category != null)) return new InvalidOperationException(Res.GetString(Res.PermissionPathOrCriteria)); if (this.path == null && this.machineName == null && this.label == null && this.category == null) return new InvalidOperationException(Res.GetString(Res.PermissionAllNull)); return null; } } } // 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
- AppDomainShutdownMonitor.cs
- ActivityContext.cs
- EpmTargetPathSegment.cs
- AssemblyInfo.cs
- _ContextAwareResult.cs
- MediaTimeline.cs
- InvalidOperationException.cs
- DateBoldEvent.cs
- SiteMapNodeItemEventArgs.cs
- TextCompositionEventArgs.cs
- XmlDigitalSignatureProcessor.cs
- ToolboxItemCollection.cs
- TextServicesLoader.cs
- TextEditorParagraphs.cs
- SortQueryOperator.cs
- ListItemViewControl.cs
- _ProxyChain.cs
- TableLayoutSettings.cs
- DataGridTableStyleMappingNameEditor.cs
- AccessDataSourceView.cs
- WebBrowserNavigatedEventHandler.cs
- SplineKeyFrames.cs
- StylusEditingBehavior.cs
- CodeMemberField.cs
- MailAddress.cs
- BamlTreeNode.cs
- Package.cs
- Calendar.cs
- StylusDownEventArgs.cs
- BinaryFormatter.cs
- WebContext.cs
- Lease.cs
- Application.cs
- ScriptControlDescriptor.cs
- AffineTransform3D.cs
- AutomationElementCollection.cs
- XsdDataContractExporter.cs
- ArgumentException.cs
- Expression.cs
- ToolStripDropDownItem.cs
- DateTimeOffset.cs
- TrustManager.cs
- DictionaryBase.cs
- WorkItem.cs
- UnsafeNativeMethodsTablet.cs
- SectionInformation.cs
- Expression.cs
- SystemIPInterfaceStatistics.cs
- FilteredAttributeCollection.cs
- ObjectFullSpanRewriter.cs
- BindingExpressionBase.cs
- DbDataRecord.cs
- RadioButton.cs
- PageThemeBuildProvider.cs
- DesignerTransactionCloseEvent.cs
- QuerySetOp.cs
- TextEffect.cs
- ITreeGenerator.cs
- SapiRecoInterop.cs
- UnsafeNativeMethods.cs
- UrlMappingCollection.cs
- StrongName.cs
- __Error.cs
- DataGridViewRowHeaderCell.cs
- ClientUrlResolverWrapper.cs
- UniqueConstraint.cs
- ThreadSafeList.cs
- Image.cs
- XmlLoader.cs
- InvokeProviderWrapper.cs
- FrameworkTemplate.cs
- AnimatedTypeHelpers.cs
- ClientSideProviderDescription.cs
- RenderingEventArgs.cs
- SoapTypeAttribute.cs
- JsonStringDataContract.cs
- FileFormatException.cs
- ConnectionManagementElementCollection.cs
- MenuItemStyleCollection.cs
- __Filters.cs
- ValidatorCompatibilityHelper.cs
- LogReserveAndAppendState.cs
- UriTemplateTrieLocation.cs
- DesignOnlyAttribute.cs
- RuleRefElement.cs
- MethodImplAttribute.cs
- DocumentPageView.cs
- BrowserDefinitionCollection.cs
- TreeNodeClickEventArgs.cs
- FormViewRow.cs
- mediapermission.cs
- PropertyManager.cs
- ListChangedEventArgs.cs
- TextDataBindingHandler.cs
- ProjectionCamera.cs
- PersonalizationStateInfo.cs
- BypassElementCollection.cs
- TCPListener.cs
- COM2EnumConverter.cs
- Win32NamedPipes.cs