Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / wpf / src / Shared / MS / Internal / Permissions / InternalPermissions.cs / 1 / InternalPermissions.cs
//---------------------------------------------------------------------------- // //// Copyright (C) Microsoft Corporation. All rights reserved. // // // // Description: Internal Permissions. // These are classes for permissions that will be asserted/demanded internally. // But will be granted in full-trust. // Only internal avalon code will assert these permissions. // // Using them allows the following: // We can have very specific targeted asserts. So for example instead of // a blanket assert for Unmanaged code instead we can have very granular permissiosn. // // They are still available by default in full-trust. // // Currently the only way to detect User-Initiated actions is for commands. // So by associating a custom permisison with a command we can very tightly scope // the set of operations allowed. // // History: // 02/28/05 : marka - Created //--------------------------------------------------------------------------- using System; using System.Text; using System.Security; using System.Security.Permissions; using System.Windows; #if WINDOWS_BASE using MS.Internal.WindowsBase; #endif namespace MS.Internal.Permissions { // // derive all InternalPermissions from this. // Provides default implementations of several abstract methods on CodeAccessPermission // [FriendAccessAllowed] internal abstract class InternalPermissionBase : CodeAccessPermission, IUnrestrictedPermission { //----------------------------------------------------- // // Constructors // //----------------------------------------------------- #region Constructor public InternalPermissionBase( ) { } #endregion Constructor //------------------------------------------------------ // // Interface Methods // //----------------------------------------------------- #region Interface Methods public bool IsUnrestricted() { return true; } #endregion Interface Methods //------------------------------------------------------ // // Public Methods // //------------------------------------------------------ #region Public Methods public override SecurityElement ToXml() { SecurityElement element = new SecurityElement("IPermission"); Type type = this.GetType(); StringBuilder AssemblyName = new StringBuilder(type.Assembly.ToString()); AssemblyName.Replace('\"', '\''); element.AddAttribute("class", type.FullName + ", " + AssemblyName); element.AddAttribute("version", "1"); return element; } public override void FromXml( SecurityElement elem) { // from XML is easy - there is no state. } public override IPermission Intersect(IPermission target) { if(null == target) { return null; } if ( target.GetType() != this.GetType() ) { throw new ArgumentException( SR.Get(SRID.InvalidPermissionType), this.GetType().FullName); } // there is no state. The intersection of 2 permissions of the same type is the same permission. return this.Copy(); } public override bool IsSubsetOf(IPermission target) { if(null == target) { return false; } if ( target.GetType() != this.GetType() ) { throw new ArgumentException( SR.Get(SRID.InvalidPermissionType), this.GetType().FullName); } // there is no state. If you are the same type as me - you are a subset of me. return true; } #endregion Public Methods } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. //---------------------------------------------------------------------------- // //// Copyright (C) Microsoft Corporation. All rights reserved. // // // // Description: Internal Permissions. // These are classes for permissions that will be asserted/demanded internally. // But will be granted in full-trust. // Only internal avalon code will assert these permissions. // // Using them allows the following: // We can have very specific targeted asserts. So for example instead of // a blanket assert for Unmanaged code instead we can have very granular permissiosn. // // They are still available by default in full-trust. // // Currently the only way to detect User-Initiated actions is for commands. // So by associating a custom permisison with a command we can very tightly scope // the set of operations allowed. // // History: // 02/28/05 : marka - Created //--------------------------------------------------------------------------- using System; using System.Text; using System.Security; using System.Security.Permissions; using System.Windows; #if WINDOWS_BASE using MS.Internal.WindowsBase; #endif namespace MS.Internal.Permissions { // // derive all InternalPermissions from this. // Provides default implementations of several abstract methods on CodeAccessPermission // [FriendAccessAllowed] internal abstract class InternalPermissionBase : CodeAccessPermission, IUnrestrictedPermission { //----------------------------------------------------- // // Constructors // //----------------------------------------------------- #region Constructor public InternalPermissionBase( ) { } #endregion Constructor //------------------------------------------------------ // // Interface Methods // //----------------------------------------------------- #region Interface Methods public bool IsUnrestricted() { return true; } #endregion Interface Methods //------------------------------------------------------ // // Public Methods // //------------------------------------------------------ #region Public Methods public override SecurityElement ToXml() { SecurityElement element = new SecurityElement("IPermission"); Type type = this.GetType(); StringBuilder AssemblyName = new StringBuilder(type.Assembly.ToString()); AssemblyName.Replace('\"', '\''); element.AddAttribute("class", type.FullName + ", " + AssemblyName); element.AddAttribute("version", "1"); return element; } public override void FromXml( SecurityElement elem) { // from XML is easy - there is no state. } public override IPermission Intersect(IPermission target) { if(null == target) { return null; } if ( target.GetType() != this.GetType() ) { throw new ArgumentException( SR.Get(SRID.InvalidPermissionType), this.GetType().FullName); } // there is no state. The intersection of 2 permissions of the same type is the same permission. return this.Copy(); } public override bool IsSubsetOf(IPermission target) { if(null == target) { return false; } if ( target.GetType() != this.GetType() ) { throw new ArgumentException( SR.Get(SRID.InvalidPermissionType), this.GetType().FullName); } // there is no state. If you are the same type as me - you are a subset of me. return true; } #endregion Public Methods } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- QilInvokeEarlyBound.cs
- TableCell.cs
- RenderTargetBitmap.cs
- UdpDiscoveryEndpointElement.cs
- DependsOnAttribute.cs
- ActiveXHelper.cs
- IgnoreDeviceFilterElement.cs
- DbProviderServices.cs
- AuthorizationRuleCollection.cs
- PrimitiveXmlSerializers.cs
- InputMethod.cs
- TempFiles.cs
- CodePageEncoding.cs
- FunctionCommandText.cs
- XmlComment.cs
- Normalization.cs
- BooleanConverter.cs
- RequestStatusBarUpdateEventArgs.cs
- SystemTcpConnection.cs
- WindowsGraphicsCacheManager.cs
- MinimizableAttributeTypeConverter.cs
- SettingsSection.cs
- DbParameterCollectionHelper.cs
- MaxSessionCountExceededException.cs
- ObjectCloneHelper.cs
- Model3DGroup.cs
- IDReferencePropertyAttribute.cs
- HttpRequest.cs
- Control.cs
- EdmConstants.cs
- CategoryList.cs
- ComponentResourceManager.cs
- IisTraceWebEventProvider.cs
- SinglePhaseEnlistment.cs
- DataGridViewCellCollection.cs
- OutputCache.cs
- ComEventsHelper.cs
- GenericQueueSurrogate.cs
- ZeroOpNode.cs
- ReadOnlyCollectionBase.cs
- MergeExecutor.cs
- SafeIUnknown.cs
- _SafeNetHandles.cs
- Content.cs
- LabelTarget.cs
- XmlSchemaImport.cs
- PagePropertiesChangingEventArgs.cs
- isolationinterop.cs
- OverflowException.cs
- ValidationHelper.cs
- SmtpException.cs
- IsolatedStorageFileStream.cs
- HostProtectionPermission.cs
- __ConsoleStream.cs
- MemberCollection.cs
- TableParagraph.cs
- Table.cs
- StylusPointCollection.cs
- DataStreams.cs
- ParserHooks.cs
- StylusPointPropertyId.cs
- _Events.cs
- TreeViewBindingsEditor.cs
- AbsoluteQuery.cs
- UmAlQuraCalendar.cs
- DynamicArgumentDesigner.xaml.cs
- CodeSnippetCompileUnit.cs
- PropertyTab.cs
- FilterElement.cs
- MediaTimeline.cs
- ExportException.cs
- ProcessThread.cs
- FontEditor.cs
- ServiceModelStringsVersion1.cs
- SimpleRecyclingCache.cs
- DependencyPropertyConverter.cs
- ConfigXmlCDataSection.cs
- RemoteDebugger.cs
- FormViewInsertedEventArgs.cs
- PlaceHolder.cs
- System.Data.OracleClient_BID.cs
- ProfilePropertySettings.cs
- ResourceCategoryAttribute.cs
- KernelTypeValidation.cs
- DispatcherHooks.cs
- FontStyles.cs
- InstallerTypeAttribute.cs
- ProbeRequestResponseAsyncResult.cs
- SEHException.cs
- sitestring.cs
- ConfigXmlComment.cs
- GlobalProxySelection.cs
- Debugger.cs
- WSFederationHttpSecurityMode.cs
- SiteMapPath.cs
- PreviewPageInfo.cs
- LogicalExpr.cs
- IResourceProvider.cs
- EncoderBestFitFallback.cs
- XmlReaderDelegator.cs