// 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); }
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); }
/// <summary> /// Loads color profile given by profileUri /// </summary> private void Initialize(Uri profileUri, bool isStandardProfileUriNotFromUser) { bool tryProfileFromResource = false; if (profileUri == null) { throw new ArgumentNullException("profileUri"); } if (!profileUri.IsAbsoluteUri) { throw new ArgumentException(SR.Get(SRID.UriNotAbsolute), "profileUri"); } _profileUri = new SecurityCriticalData <Uri>(profileUri); _isProfileUriNotFromUser = new SecurityCriticalDataForSet <bool>(isStandardProfileUriNotFromUser); Stream profileStream = null; try { profileStream = WpfWebRequestHelper.CreateRequestAndGetResponseStream(profileUri); } catch (WebException) { // // If we couldn't load the system's default color profile (e.g. in partial trust), load a color profile from // a resource so the image shows up at least. If the user specified a color profile and we weren't // able to load it, we'll fail to avoid letting the user use this resource fallback as a way to discover // files on disk. // if (isStandardProfileUriNotFromUser) { tryProfileFromResource = true; } } if (profileStream == null) { if (tryProfileFromResource) { ResourceManager resourceManager = new ResourceManager(_colorProfileResources, Assembly.GetAssembly(typeof(ColorContext))); byte[] sRGBProfile = (byte[])resourceManager.GetObject(_sRGBProfileName); profileStream = new MemoryStream(sRGBProfile); } else { // // SECURITY WARNING: This exception includes the profile URI which may contain sensitive information. However, as of right now, // this is safe because it can only happen when the URI is given to us by the user. // Invariant.Assert(!isStandardProfileUriNotFromUser); throw new FileNotFoundException(SR.Get(SRID.FileNotFoundExceptionWithFileName, profileUri.AbsolutePath), profileUri.AbsolutePath); } } FromStream(profileStream, profileUri.AbsolutePath); }
private void BeginLoadStream() { if (m_lastRequestedAbsoluteUri != null) // Only reload if the new source is non-null { m_streamLoadInProgress = true; // Step 1: Perform an asynchronous load of the WebResponse and its associated Stream Task.Run(() => { Stream result = WpfWebRequestHelper.CreateRequestAndGetResponseStream(m_lastRequestedAbsoluteUri); LoadStreamCallback(result); }); } }
// Token: 0x06003247 RID: 12871 RVA: 0x000DC6B8 File Offset: 0x000DA8B8 internal Stream GetPageStream() { Uri uri = this._ResolveUri(); Stream stream = null; if (uri != null) { stream = WpfWebRequestHelper.CreateRequestAndGetResponseStream(uri); if (stream == null) { throw new ApplicationException(SR.Get("PageContentNotFound")); } } return(stream); }
internal Stream GetPageStream() { Uri uriToLoad = _ResolveUri(); Stream pageStream = null; if (uriToLoad != null) { pageStream = WpfWebRequestHelper.CreateRequestAndGetResponseStream(uriToLoad); if (pageStream == null) { throw new ApplicationException(SR.Get(SRID.PageContentNotFound)); } } return(pageStream); }
/// <summary> /// This method is invoked whenever the source property changes. /// </summary> private void UriSourcePropertyChangedHook(DependencyPropertyChangedEventArgs e) { // Decided against comparing the URI because the user might want to change the shader on the filesystem // and reload it. // We do not support async loading of shaders here. If that is desired the user needs to use the SetStreamSource // API. Uri newUri = (Uri)e.NewValue; Stream stream = null; try { if (newUri != null) { if (!newUri.IsAbsoluteUri) { newUri = BaseUriHelper.GetResolvedUri(BaseUriHelper.BaseUri, newUri); } Debug.Assert(newUri.IsAbsoluteUri); // Now the URI is an absolute URI. // // Only allow file and pack URIs. if (!newUri.IsFile && !PackUriHelper.IsPackUri(newUri)) { throw new ArgumentException(SR.Get(SRID.Effect_SourceUriMustBeFileOrPack)); } stream = WpfWebRequestHelper.CreateRequestAndGetResponseStream(newUri); } LoadPixelShaderFromStreamIntoMemory(stream); } finally { if (stream != null) { stream.Dispose(); } } }
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; }
// 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; }
// Token: 0x06005655 RID: 22101 RVA: 0x0017E6BD File Offset: 0x0017C8BD private Stream LoadStreamAsync(Uri uri) { return(WpfWebRequestHelper.CreateRequestAndGetResponseStream(uri)); }