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
![Network programming in C#, Network Programming in VB.NET, Network Programming in .NET](/images/book.jpg)
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- DeviceContext2.cs
- BitSet.cs
- BitmapEffectDrawingContextWalker.cs
- Pair.cs
- PreloadHost.cs
- __FastResourceComparer.cs
- CodeAttributeDeclaration.cs
- ColorContext.cs
- __TransparentProxy.cs
- Double.cs
- Convert.cs
- UTF8Encoding.cs
- ValidationEventArgs.cs
- SelectionListDesigner.cs
- ObjectListDataBindEventArgs.cs
- StringSorter.cs
- UserControlCodeDomTreeGenerator.cs
- BindingListCollectionView.cs
- PriorityBinding.cs
- WebPartsPersonalization.cs
- UidManager.cs
- PageRequestManager.cs
- XamlPoint3DCollectionSerializer.cs
- XmlSchemaParticle.cs
- DXD.cs
- RangeBase.cs
- BuildProviderCollection.cs
- DirectoryObjectSecurity.cs
- RuntimeEnvironment.cs
- unitconverter.cs
- System.Data.OracleClient_BID.cs
- ColorTransform.cs
- TextOutput.cs
- UnhandledExceptionEventArgs.cs
- XmlSchemaExternal.cs
- CodePageUtils.cs
- TextClipboardData.cs
- RowsCopiedEventArgs.cs
- MonthChangedEventArgs.cs
- XsltArgumentList.cs
- LoadedEvent.cs
- PopupControlService.cs
- SchemaImporter.cs
- ButtonField.cs
- EventArgs.cs
- ClientSettingsSection.cs
- CompilerLocalReference.cs
- HtmlElement.cs
- TextEditorSpelling.cs
- EventsTab.cs
- PeerSecurityHelpers.cs
- SymLanguageVendor.cs
- TypeLoadException.cs
- SmtpSpecifiedPickupDirectoryElement.cs
- CommandCollectionEditor.cs
- TextRunCacheImp.cs
- EntityContainerEmitter.cs
- newitemfactory.cs
- OdbcParameter.cs
- SqlDelegatedTransaction.cs
- DbDataAdapter.cs
- XmlSchemaSimpleTypeUnion.cs
- RegexTypeEditor.cs
- BaseTemplateParser.cs
- DynamicRenderer.cs
- _CookieModule.cs
- GridViewDeleteEventArgs.cs
- StorageAssociationTypeMapping.cs
- DeflateStreamAsyncResult.cs
- SqlDataSourceParameterParser.cs
- Rijndael.cs
- ArrangedElementCollection.cs
- PropertySegmentSerializer.cs
- CultureNotFoundException.cs
- BuilderInfo.cs
- FrameAutomationPeer.cs
- ViewStateException.cs
- WorkflowViewStateService.cs
- ItemType.cs
- DataGridViewLinkCell.cs
- ArrayItemValue.cs
- XamlPointCollectionSerializer.cs
- DocumentReferenceCollection.cs
- CatchDesigner.xaml.cs
- XmlSchemaImporter.cs
- ProcessHost.cs
- FieldTemplateUserControl.cs
- XsltFunctions.cs
- DetailsViewModeEventArgs.cs
- BitmapSource.cs
- HttpCacheVary.cs
- MimeMapping.cs
- XamlStream.cs
- TranslateTransform3D.cs
- Transform3DGroup.cs
- AggregatePushdown.cs
- WmiEventSink.cs
- X509Utils.cs
- TextRangeProviderWrapper.cs
- UserInitiatedRoutedEventPermissionAttribute.cs