public Stream OpenRead()
 {
     if (_underlayingResource == null)
     {
         throw new IllegalCallException("Path '{0} cannot be opened for reading", _path);
     }
     return(_underlayingResource.OpenRead());
 }
示例#2
0
 public Stream OpenRead()
 {
     if (_underlayingResource == null)
     {
         return(null);
     }
     using (ServiceRegistration.Get <IImpersonationService>().CheckImpersonationFor(CanonicalLocalResourcePath))
         return(_underlayingResource.OpenRead());
 }
示例#3
0
 public Stream OpenRead()
 {
     if (_underlayingResource == null)
     {
         return(null);
     }
     using (ImpersonateUser(_impersonationContext))
         return(_underlayingResource.OpenRead());
 }
示例#4
0
 /// <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);
 }
示例#5
0
 /// <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);
 }