// Token: 0x06002CDC RID: 11484 RVA: 0x000CA334 File Offset: 0x000C8534
        private static object ValidateAndLoadPartFromAbsoluteUri(Uri AbsoluteUriDoc, bool validateOnly, string rootElement, out ContentType mimeType)
        {
            mimeType = null;
            object result = null;

            try
            {
                Stream        stream        = WpfWebRequestHelper.CreateRequestAndGetResponseStream(AbsoluteUriDoc, out mimeType);
                ParserContext parserContext = new ParserContext();
                parserContext.BaseUri = AbsoluteUriDoc;
                XpsValidatingLoader xpsValidatingLoader = new XpsValidatingLoader();
                if (validateOnly)
                {
                    xpsValidatingLoader.Validate(stream, null, parserContext, mimeType, rootElement);
                }
                else
                {
                    result = xpsValidatingLoader.Load(stream, null, parserContext, mimeType);
                }
            }
            catch (Exception ex)
            {
                if (!(ex is WebException) && !(ex is InvalidOperationException))
                {
                    throw;
                }
            }
            return(result);
        }
Esempio n. 2
0
        private FixedDocument _LoadDocument()
        {
            FixedDocument fixedDocument = null;
            Uri           uri           = this._ResolveUri();

            if (uri != null)
            {
                ContentType contentType = null;
                Stream      stream      = WpfWebRequestHelper.CreateRequestAndGetResponseStream(uri, out contentType);
                if (stream == null)
                {
                    throw new ApplicationException(SR.Get("DocumentReferenceNotFound"));
                }
                ParserContext parserContext = new ParserContext();
                parserContext.BaseUri = uri;
                if (BindUriHelper.IsXamlMimeType(contentType))
                {
                    XpsValidatingLoader xpsValidatingLoader = new XpsValidatingLoader();
                    fixedDocument = (xpsValidatingLoader.Load(stream, ((IUriContext)this).BaseUri, parserContext, contentType) as FixedDocument);
                }
                else
                {
                    if (!MimeTypeMapper.BamlMime.AreTypeAndSubTypeEqual(contentType))
                    {
                        throw new ApplicationException(SR.Get("DocumentReferenceUnsupportedMimeType"));
                    }
                    fixedDocument = (XamlReader.LoadBaml(stream, parserContext, null, true) as FixedDocument);
                }
                fixedDocument.DocumentReference = this;
            }
            return(fixedDocument);
        }
        // Token: 0x06002CED RID: 11501 RVA: 0x000CAB00 File Offset: 0x000C8D00
        public XpsSchemaValidator(XpsValidatingLoader loader, XpsSchema schema, ContentType mimeType, Stream objectStream, Uri packageUri, Uri baseUri)
        {
            XmlReader xmlReader = new XpsSchemaValidator.XmlEncodingEnforcingTextReader(objectStream)
            {
                ProhibitDtd   = true,
                Normalization = true
            };

            string[] array = XpsSchemaValidator._predefinedNamespaces;
            if (!string.IsNullOrEmpty(schema.RootNamespaceUri))
            {
                array    = new string[XpsSchemaValidator._predefinedNamespaces.Length + 1];
                array[0] = schema.RootNamespaceUri;
                XpsSchemaValidator._predefinedNamespaces.CopyTo(array, 1);
            }
            xmlReader = new XmlCompatibilityReader(xmlReader, array);
            xmlReader = XmlReader.Create(xmlReader, schema.GetXmlReaderSettings());
            if (schema.HasUriAttributes(mimeType) && packageUri != null && baseUri != null)
            {
                xmlReader = new XpsSchemaValidator.RootXMLNSAndUriValidatingXmlReader(loader, schema, xmlReader, packageUri, baseUri);
            }
            else
            {
                xmlReader = new XpsSchemaValidator.RootXMLNSAndUriValidatingXmlReader(loader, schema, xmlReader);
            }
            this._compatReader = xmlReader;
        }
 // Token: 0x06008480 RID: 33920 RVA: 0x00248506 File Offset: 0x00246706
 public RootXMLNSAndUriValidatingXmlReader(XpsValidatingLoader loader, XpsSchema schema, XmlReader xmlReader, Uri packageUri, Uri baseUri) : base(xmlReader)
 {
     this._loader     = loader;
     this._schema     = schema;
     this._packageUri = packageUri;
     this._baseUri    = baseUri;
 }
Esempio n. 5
0
 public RootXMLNSAndUriValidatingXmlReader(
     XpsValidatingLoader loader,
     XpsSchema schema,
     XmlReader xmlReader)
     : base(xmlReader)
 {
     _loader = loader;
     _schema = schema;
 }
Esempio n. 6
0
        XpsSchemaValidator(
            XpsValidatingLoader loader,
            XpsSchema schema,
            ContentType mimeType,
            Stream objectStream,
            Uri packageUri,
            Uri baseUri
            )
        {
            XmlTextReader xmlTextReader = new XmlEncodingEnforcingTextReader(objectStream);

            xmlTextReader.ProhibitDtd   = true;
            xmlTextReader.Normalization = true;

            XmlReader xmlReader = xmlTextReader;

            string [] predefinedNamespaces = _predefinedNamespaces;
            if (!string.IsNullOrEmpty(schema.RootNamespaceUri))
            {
                predefinedNamespaces    = new string[_predefinedNamespaces.Length + 1];
                predefinedNamespaces[0] = schema.RootNamespaceUri;
                _predefinedNamespaces.CopyTo(predefinedNamespaces, 1);
            }

            xmlReader = new XmlCompatibilityReader(xmlReader, predefinedNamespaces);
            xmlReader = XmlReader.Create(xmlReader, schema.GetXmlReaderSettings());

            if (schema.HasUriAttributes(mimeType) && packageUri != null && baseUri != null)
            {
                xmlReader = new RootXMLNSAndUriValidatingXmlReader(loader, schema,
                                                                   xmlReader, packageUri, baseUri);
            }
            else
            {
                xmlReader = new RootXMLNSAndUriValidatingXmlReader(loader, schema, xmlReader);
            }

            _compatReader = xmlReader;
        }
Esempio n. 7
0
        XpsSchemaValidator(
            XpsValidatingLoader loader, 
            XpsSchema schema, 
            ContentType mimeType,
            Stream  objectStream, 
            Uri packageUri,
            Uri baseUri
            )
        { 
            XmlTextReader xmlTextReader = new XmlEncodingEnforcingTextReader(objectStream);
 
            xmlTextReader.ProhibitDtd = true; 
            xmlTextReader.Normalization = true;
 
            XmlReader xmlReader = xmlTextReader;

            string [] predefinedNamespaces = _predefinedNamespaces;
            if ( !string.IsNullOrEmpty(schema.RootNamespaceUri) ) 
            {
                predefinedNamespaces = new string[_predefinedNamespaces.Length + 1]; 
                predefinedNamespaces[0] = schema.RootNamespaceUri; 
                _predefinedNamespaces.CopyTo(predefinedNamespaces, 1);
            } 

            xmlReader = new XmlCompatibilityReader(xmlReader, predefinedNamespaces);
            xmlReader = XmlReader.Create(xmlReader, schema.GetXmlReaderSettings());
 
            if (schema.HasUriAttributes(mimeType) && packageUri != null && baseUri != null)
            { 
                xmlReader = new RootXMLNSAndUriValidatingXmlReader(loader, schema, 
                                                        xmlReader, packageUri, baseUri);
            } 
            else
            {
                xmlReader = new RootXMLNSAndUriValidatingXmlReader(loader, schema, xmlReader);
            } 

            _compatReader = xmlReader; 
        } 
Esempio n. 8
0
        private FixedDocument _LoadDocument()
        {
            FixedDocument idp       = null;
            Uri           uriToLoad = _ResolveUri();

            if (uriToLoad != null)
            {
                ContentType mimeType  = null;
                Stream      docStream = null;

                docStream = WpfWebRequestHelper.CreateRequestAndGetResponseStream(uriToLoad, out mimeType);
                if (docStream == null)
                {
                    throw new ApplicationException(SR.Get(SRID.DocumentReferenceNotFound));
                }

                ParserContext pc = new ParserContext();

                pc.BaseUri = uriToLoad;

                if (BindUriHelper.IsXamlMimeType(mimeType))
                {
                    XpsValidatingLoader loader = new XpsValidatingLoader();
                    idp = loader.Load(docStream, ((IUriContext)this).BaseUri, pc, mimeType) as FixedDocument;
                }
                else if (MS.Internal.MimeTypeMapper.BamlMime.AreTypeAndSubTypeEqual(mimeType))
                {
                    idp = XamlReader.LoadBaml(docStream, pc, null, true) as FixedDocument;
                }
                else
                {
                    throw new ApplicationException(SR.Get(SRID.DocumentReferenceUnsupportedMimeType));
                }
                idp.DocumentReference = this;
            }

            return(idp);
        }
        internal static void _LoadPageImpl(Uri baseUri, Uri uriToLoad, out FixedPage fixedPage, out Stream pageStream)
        {
            ContentType mimeType;

            pageStream = WpfWebRequestHelper.CreateRequestAndGetResponseStream(uriToLoad, out mimeType);
            object o = null;

            if (pageStream == null)
            {
                throw new ApplicationException(SR.Get(SRID.PageContentNotFound));
            }

            ParserContext pc = new ParserContext();

            pc.BaseUri = uriToLoad;

            if (BindUriHelper.IsXamlMimeType(mimeType))
            {
                XpsValidatingLoader loader = new XpsValidatingLoader();
                o = loader.Load(pageStream, baseUri, pc, mimeType);
            }
            else if (MS.Internal.MimeTypeMapper.BamlMime.AreTypeAndSubTypeEqual(mimeType))
            {
                o = XamlReader.LoadBaml(pageStream, pc, null, true);
            }
            else
            {
                throw new ApplicationException(SR.Get(SRID.PageContentUnsupportedMimeType));
            }

            if (o != null && !(o is FixedPage))
            {
                throw new ApplicationException(SR.Get(SRID.PageContentUnsupportedPageType, o.GetType()));
            }

            fixedPage = (FixedPage)o;
        }
Esempio n. 10
0
        // Token: 0x06003252 RID: 12882 RVA: 0x000DC99C File Offset: 0x000DAB9C
        internal static void _LoadPageImpl(Uri baseUri, Uri uriToLoad, out FixedPage fixedPage, out Stream pageStream)
        {
            ContentType contentType;

            pageStream = WpfWebRequestHelper.CreateRequestAndGetResponseStream(uriToLoad, out contentType);
            if (pageStream == null)
            {
                throw new ApplicationException(SR.Get("PageContentNotFound"));
            }
            ParserContext parserContext = new ParserContext();

            parserContext.BaseUri = uriToLoad;
            object obj;

            if (BindUriHelper.IsXamlMimeType(contentType))
            {
                XpsValidatingLoader xpsValidatingLoader = new XpsValidatingLoader();
                obj = xpsValidatingLoader.Load(pageStream, baseUri, parserContext, contentType);
            }
            else
            {
                if (!MimeTypeMapper.BamlMime.AreTypeAndSubTypeEqual(contentType))
                {
                    throw new ApplicationException(SR.Get("PageContentUnsupportedMimeType"));
                }
                obj = XamlReader.LoadBaml(pageStream, parserContext, null, true);
            }
            if (obj != null && !(obj is FixedPage))
            {
                throw new ApplicationException(SR.Get("PageContentUnsupportedPageType", new object[]
                {
                    obj.GetType()
                }));
            }
            fixedPage = (FixedPage)obj;
        }
Esempio n. 11
0
 public RootXMLNSAndUriValidatingXmlReader(
             XpsValidatingLoader loader, 
             XpsSchema schema, 
             XmlReader xmlReader )
     : base(xmlReader) 
 {
     _loader = loader;
     _schema = schema;
 } 
Esempio n. 12
0
 public RootXMLNSAndUriValidatingXmlReader( 
             XpsValidatingLoader loader,
             XpsSchema schema,
             XmlReader xmlReader,
             Uri packageUri, 
             Uri baseUri)
             : base(xmlReader) 
 { 
     _loader = loader;
     _schema = schema; 
     _packageUri = packageUri;
     _baseUri = baseUri;
 }
        private static object ValidateAndLoadPartFromAbsoluteUri(Uri AbsoluteUriDoc, bool validateOnly, string rootElement, out ContentType mimeType)
        {
            mimeType = null;
            Stream pageStream = null;
            object o = null;

            try
            {
                pageStream = WpfWebRequestHelper.CreateRequestAndGetResponseStream(AbsoluteUriDoc, out mimeType);

                ParserContext pc = new ParserContext();
                pc.BaseUri = AbsoluteUriDoc;

                XpsValidatingLoader loader = new XpsValidatingLoader();
                if (validateOnly)
                {
                    loader.Validate(pageStream, null, pc, mimeType, rootElement);
                }
                else
                {
                    o = loader.Load(pageStream, null, pc, mimeType);
                }
            }
            catch (Exception e)
            {
                //System.Net.WebException will be thrown when the document structure does not exist in a non-container
                //and System.InvalidOperation will be thrown when calling Package.GetPart() in a container.
                //We ignore these but all others need to be rethrown
                if (!(e is System.Net.WebException || e is System.InvalidOperationException))
                {
                    throw;
                }
            }
            return o;
        }
Esempio n. 14
0
        internal static void _LoadPageImpl(Uri baseUri, Uri uriToLoad, out FixedPage fixedPage, out Stream pageStream)
        {
            ContentType mimeType;
            pageStream = WpfWebRequestHelper.CreateRequestAndGetResponseStream(uriToLoad, out mimeType);
            object o = null;
            if (pageStream == null)
            {
                throw new ApplicationException(SR.Get(SRID.PageContentNotFound));
            }

            ParserContext pc = new ParserContext();
            pc.BaseUri = uriToLoad;

            if (BindUriHelper.IsXamlMimeType(mimeType))
            {
                XpsValidatingLoader loader = new XpsValidatingLoader();
                o = loader.Load(pageStream, baseUri, pc, mimeType);
            }
            else if (MS.Internal.MimeTypeMapper.BamlMime.AreTypeAndSubTypeEqual(mimeType))
            {
                o = XamlReader.LoadBaml(pageStream, pc, null, true);
            }
            else
            {
                throw new ApplicationException(SR.Get(SRID.PageContentUnsupportedMimeType));
            }

            if (o != null && !(o is FixedPage))
            {
                throw new ApplicationException(SR.Get(SRID.PageContentUnsupportedPageType, o.GetType()));
            }

            fixedPage =  (FixedPage)o;
        }
Esempio n. 15
0
        private FixedDocument _LoadDocument()
        {
            FixedDocument idp = null;
            Uri uriToLoad = _ResolveUri();
            if (uriToLoad != null)
            {
                ContentType mimeType = null;
                Stream docStream = null;

                docStream = WpfWebRequestHelper.CreateRequestAndGetResponseStream(uriToLoad, out mimeType);
                if (docStream == null)
                {
                    throw new ApplicationException(SR.Get(SRID.DocumentReferenceNotFound));
                }

                ParserContext pc = new ParserContext();

                pc.BaseUri = uriToLoad;

                if (BindUriHelper.IsXamlMimeType(mimeType))
                {
                    XpsValidatingLoader loader = new XpsValidatingLoader();
                    idp = loader.Load(docStream, ((IUriContext)this).BaseUri, pc, mimeType) as FixedDocument;
                }
                else if (MS.Internal.MimeTypeMapper.BamlMime.AreTypeAndSubTypeEqual(mimeType))
                {
                    idp = XamlReader.LoadBaml(docStream, pc, null, true) as FixedDocument;
                }
                else
                {
                    throw new ApplicationException(SR.Get(SRID.DocumentReferenceUnsupportedMimeType));
                }
                idp.DocumentReference = this;
                
            }
 
           return idp;
        }