internal DeferrableContent(Stream stream, Baml2006SchemaContext schemaContext, IXamlObjectWriterFactory objectWriterFactory, IServiceProvider serviceProvider, object rootObject)
        {
            this.ObjectWriterParentSettings = objectWriterFactory.GetParentSettings();
            if (this.ObjectWriterParentSettings.AccessLevel != null)
            {
                XamlLoadPermission xamlLoadPermission = new XamlLoadPermission(this.ObjectWriterParentSettings.AccessLevel);
                xamlLoadPermission.Demand();
                this.LoadPermission = xamlLoadPermission;
            }
            bool flag = false;

            if (schemaContext.LocalAssembly != null)
            {
                flag = schemaContext.LocalAssembly.ImageRuntimeVersion.StartsWith("v2", StringComparison.Ordinal);
            }
            if (flag)
            {
                this.ObjectWriterParentSettings.SkipProvideValueOnRoot = true;
            }
            this.Stream              = stream;
            this.SchemaContext       = schemaContext;
            this.ObjectWriterFactory = objectWriterFactory;
            this.ServiceProvider     = serviceProvider;
            this.RootObject          = rootObject;
        }
 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;
 }
示例#3
0
        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;
        }