public Stream OpenRead() { if (_underlayingResource == null) { throw new IllegalCallException("Path '{0} cannot be opened for reading", _path); } return(_underlayingResource.OpenRead()); }
public Stream OpenRead() { if (_underlayingResource == null) { return(null); } using (ServiceRegistration.Get <IImpersonationService>().CheckImpersonationFor(CanonicalLocalResourcePath)) return(_underlayingResource.OpenRead()); }
public Stream OpenRead() { if (_underlayingResource == null) { return(null); } using (ImpersonateUser(_impersonationContext)) return(_underlayingResource.OpenRead()); }
/// <summary> /// Loads an image from filesystem an returns a new <see cref="FanArtImage"/>. /// </summary> /// <param name="resourceLocator">Resource to load</param> /// <param name="maxWidth">Maximum width for image. <c>0</c> returns image in original size.</param> /// <param name="maxHeight">Maximum height for image. <c>0</c> returns image in original size.</param> /// <param name="mediaType">MediaType</param> /// <param name="fanArtType">FanArtType</param> /// <param name="fanArtName">Fanart name</param> /// <returns>FanArtImage or <c>null</c>.</returns> public static FanArtImage FromResource(IResourceLocator resourceLocator, int maxWidth, int maxHeight, FanArtConstants.FanArtMediaType mediaType, FanArtConstants.FanArtType fanArtType, string fanArtName) { try { using (var ra = resourceLocator.CreateAccessor()) { ILocalFsResourceAccessor fsra = ra as ILocalFsResourceAccessor; if (fsra != null) { fsra.PrepareStreamAccess(); using (var fileStream = fsra.OpenRead()) return(FromStream(fileStream, maxWidth, maxHeight, mediaType, fanArtType, fanArtName, fsra.LocalFileSystemPath)); } } } catch { } return(null); }
/// <summary> /// Loads an image from filesystem an returns a new <see cref="FanArtImage"/>. /// </summary> /// <param name="resourceLocator">Resource to load</param> /// <param name="maxWidth">Maximum width for image. <c>0</c> returns image in original size.</param> /// <param name="maxHeight">Maximum height for image. <c>0</c> returns image in original size.</param> /// <param name="mediaType">MediaType</param> /// <param name="fanArtType">FanArtType</param> /// <param name="fanArtName">Fanart name</param> /// <returns>FanArtImage or <c>null</c>.</returns> public static FanArtImage FromResource(IResourceLocator resourceLocator, int maxWidth, int maxHeight) { try { using (var ra = resourceLocator.CreateAccessor()) { ILocalFsResourceAccessor fsra = ra as ILocalFsResourceAccessor; if (fsra != null) { fsra.PrepareStreamAccess(); using (var fileStream = fsra.OpenRead()) // Calling EnsureLocalFileSystemAccess not necessary; only string operation return(FromStream(fileStream, maxWidth, maxHeight, fsra.LocalFileSystemPath)); } } } catch { } return(null); }