Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Framework / System / Windows / DeferrableContent.cs / 1471291 / DeferrableContent.cs
using System; using System.Collections.Generic; using System.Text; using System.IO; using System.Security; using System.Xaml; using System.Xaml.Permissions; using System.Windows.Baml2006; using System.ComponentModel; namespace System.Windows { [TypeConverter(typeof(DeferrableContentConverter))] public class DeferrableContent { ////// Critical to write: We will assert this permission before realizing the deferred content. /// Critical to read: Can be mutated via FromXml method. /// internal XamlLoadPermission LoadPermission { [SecurityCritical] get; [SecurityCritical] private set; } ////// Critical to write: This describes the content that is allowed to be loaded with LoadPermission. /// If LoadPermission is null then this is non-critical. /// Safe to read: Carries no privilege in itself. /// internal Stream Stream { [SecurityCritical, SecurityTreatAsSafe] get; [SecurityCritical] private set; } internal Baml2006SchemaContext SchemaContext { get; private set; } internal IXamlObjectWriterFactory ObjectWriterFactory { get; private set; } internal XamlObjectWriterSettings ObjectWriterParentSettings { get; private set; } internal object RootObject { get; private set; } // internal IServiceProvider ServiceProvider { get; private set; } ////// Critical: Sets critical properties LoadPermission and Stream /// Safe: Demands LoadPermission before setting it /// [SecurityCritical, SecurityTreatAsSafe] internal DeferrableContent(Stream stream, Baml2006SchemaContext schemaContext, IXamlObjectWriterFactory objectWriterFactory, IServiceProvider serviceProvider, object rootObject) { ObjectWriterParentSettings = objectWriterFactory.GetParentSettings(); if (ObjectWriterParentSettings.AccessLevel != null) { XamlLoadPermission loadPermission = new XamlLoadPermission(ObjectWriterParentSettings.AccessLevel); loadPermission.Demand(); this.LoadPermission = loadPermission; } bool assemblyTargetsFramework2 = false; // The local assembly can be null if it is not specified in the XamlReaderSettings. if (schemaContext.LocalAssembly != null) { assemblyTargetsFramework2 = schemaContext.LocalAssembly.ImageRuntimeVersion.StartsWith("v2", StringComparison.Ordinal); } // There is an incompatibility between the framework versions 3 and 4 regarding MarkupExtension resources. // In version 3, MarkupExtension resources did not provide values when looked up. // In version 4, they do. if (assemblyTargetsFramework2) { ObjectWriterParentSettings.SkipProvideValueOnRoot = true; } this.Stream = stream; this.SchemaContext = schemaContext; this.ObjectWriterFactory = objectWriterFactory; this.ServiceProvider = serviceProvider; this.RootObject = rootObject; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. using System; using System.Collections.Generic; using System.Text; using System.IO; using System.Security; using System.Xaml; using System.Xaml.Permissions; using System.Windows.Baml2006; using System.ComponentModel; namespace System.Windows { [TypeConverter(typeof(DeferrableContentConverter))] public class DeferrableContent { ////// Critical to write: We will assert this permission before realizing the deferred content. /// Critical to read: Can be mutated via FromXml method. /// internal XamlLoadPermission LoadPermission { [SecurityCritical] get; [SecurityCritical] private set; } ////// Critical to write: This describes the content that is allowed to be loaded with LoadPermission. /// If LoadPermission is null then this is non-critical. /// Safe to read: Carries no privilege in itself. /// internal Stream Stream { [SecurityCritical, SecurityTreatAsSafe] get; [SecurityCritical] private set; } internal Baml2006SchemaContext SchemaContext { get; private set; } internal IXamlObjectWriterFactory ObjectWriterFactory { get; private set; } internal XamlObjectWriterSettings ObjectWriterParentSettings { get; private set; } internal object RootObject { get; private set; } // internal IServiceProvider ServiceProvider { get; private set; } ////// Critical: Sets critical properties LoadPermission and Stream /// Safe: Demands LoadPermission before setting it /// [SecurityCritical, SecurityTreatAsSafe] internal DeferrableContent(Stream stream, Baml2006SchemaContext schemaContext, IXamlObjectWriterFactory objectWriterFactory, IServiceProvider serviceProvider, object rootObject) { ObjectWriterParentSettings = objectWriterFactory.GetParentSettings(); if (ObjectWriterParentSettings.AccessLevel != null) { XamlLoadPermission loadPermission = new XamlLoadPermission(ObjectWriterParentSettings.AccessLevel); loadPermission.Demand(); this.LoadPermission = loadPermission; } bool assemblyTargetsFramework2 = false; // The local assembly can be null if it is not specified in the XamlReaderSettings. if (schemaContext.LocalAssembly != null) { assemblyTargetsFramework2 = schemaContext.LocalAssembly.ImageRuntimeVersion.StartsWith("v2", StringComparison.Ordinal); } // There is an incompatibility between the framework versions 3 and 4 regarding MarkupExtension resources. // In version 3, MarkupExtension resources did not provide values when looked up. // In version 4, they do. if (assemblyTargetsFramework2) { ObjectWriterParentSettings.SkipProvideValueOnRoot = true; } this.Stream = stream; this.SchemaContext = schemaContext; this.ObjectWriterFactory = objectWriterFactory; this.ServiceProvider = serviceProvider; this.RootObject = rootObject; } } } // 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
- BackEase.cs
- Operand.cs
- OrderedEnumerableRowCollection.cs
- DbParameterCollection.cs
- DateTime.cs
- WindowsPrincipal.cs
- MLangCodePageEncoding.cs
- TextureBrush.cs
- AsyncWaitHandle.cs
- PartialCachingAttribute.cs
- WpfWebRequestHelper.cs
- SqlCacheDependencyDatabaseCollection.cs
- ButtonRenderer.cs
- EventLogPermissionEntryCollection.cs
- SpecularMaterial.cs
- ListBoxItemAutomationPeer.cs
- WinEventHandler.cs
- StatusBarPanelClickEvent.cs
- Mutex.cs
- SiteMembershipCondition.cs
- StreamSecurityUpgradeInitiatorBase.cs
- SecurityState.cs
- IndicFontClient.cs
- GeneralTransform2DTo3D.cs
- AddInProcess.cs
- Int64Storage.cs
- SharedStream.cs
- SingleKeyFrameCollection.cs
- XmlNamespaceMappingCollection.cs
- CodeAccessSecurityEngine.cs
- IISMapPath.cs
- GrammarBuilder.cs
- CharEntityEncoderFallback.cs
- UriScheme.cs
- SHA1.cs
- ObjectDataSourceSelectingEventArgs.cs
- CollectionChangeEventArgs.cs
- XmlMtomWriter.cs
- GroupItem.cs
- DataRow.cs
- MSAAEventDispatcher.cs
- ZipIOExtraField.cs
- DataTableMapping.cs
- XmlReaderSettings.cs
- SinglePageViewer.cs
- HebrewNumber.cs
- HttpListenerRequest.cs
- Attributes.cs
- PublisherMembershipCondition.cs
- ExtensionSurface.cs
- CollectionBase.cs
- QueryMatcher.cs
- HttpModulesSection.cs
- BeginEvent.cs
- BuildProviderUtils.cs
- ColorComboBox.cs
- ImportCatalogPart.cs
- CustomServiceCredentials.cs
- basecomparevalidator.cs
- Behavior.cs
- FlowPosition.cs
- AvTraceFormat.cs
- Propagator.JoinPropagator.SubstitutingCloneVisitor.cs
- LocalValueEnumerator.cs
- GetIsBrowserClientRequest.cs
- ColumnHeader.cs
- ScriptControlManager.cs
- MailMessageEventArgs.cs
- validationstate.cs
- mediaeventargs.cs
- CompiledRegexRunnerFactory.cs
- Membership.cs
- EntityDataSourceWizardForm.cs
- GeometryModel3D.cs
- DataGridViewCellCollection.cs
- PauseStoryboard.cs
- WebPartsPersonalizationAuthorization.cs
- RoutingBehavior.cs
- ProxyFragment.cs
- XmlSchemaElement.cs
- LineProperties.cs
- TimeoutException.cs
- SelectingProviderEventArgs.cs
- WebPartManagerInternals.cs
- TripleDES.cs
- MenuItemCollection.cs
- DataGridViewColumnConverter.cs
- Util.cs
- DataRowCollection.cs
- AxisAngleRotation3D.cs
- Geometry3D.cs
- ClaimTypes.cs
- ActivityScheduledRecord.cs
- TempFiles.cs
- OutOfMemoryException.cs
- DiscoveryDocumentSerializer.cs
- DataGridClipboardCellContent.cs
- EventProviderBase.cs
- DrawListViewSubItemEventArgs.cs
- PerfService.cs