本文整理汇总了C#中IFileSystemResourceAccessor.OpenRead方法的典型用法代码示例。如果您正苦于以下问题:C# IFileSystemResourceAccessor.OpenRead方法的具体用法?C# IFileSystemResourceAccessor.OpenRead怎么用?C# IFileSystemResourceAccessor.OpenRead使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IFileSystemResourceAccessor
的用法示例。
在下文中一共展示了IFileSystemResourceAccessor.OpenRead方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ResourceAccessorTextureImageSource
/// <summary>
/// Constructs a <see cref="ResourceAccessorTextureImageSource"/> for the given data.
/// </summary>
/// <param name="resourceAccessor">The resource accessor to load the texture data from.</param>
/// <param name="rotation">Desired rotation for the given image.</param>
public ResourceAccessorTextureImageSource(IFileSystemResourceAccessor resourceAccessor, RightAngledRotation rotation)
{
_key = resourceAccessor.CanonicalLocalResourcePath.Serialize();
_resourceAccessor = resourceAccessor;
_stream = _resourceAccessor.OpenRead();
_rotation = rotation;
}
示例2: ZipResourceProxy
public ZipResourceProxy(string key, IFileSystemResourceAccessor zipFileAccessor)
{
_key = key;
_zipFileResourceAccessor = zipFileAccessor;
_zipFileStream = _zipFileResourceAccessor.OpenRead(); // Not sure if the ZipFile closes the stream appropriately, so we keep a reference to it
try
{
_zipFile = new ZipFile(_zipFileStream);
}
catch
{
_zipFileStream.Dispose();
throw;
}
}
示例3: IsoResourceProxy
public IsoResourceProxy(string key, IFileSystemResourceAccessor isoFileResourceAccessor)
{
_key = key;
_isoFileResourceAccessor = isoFileResourceAccessor;
_underlayingStream = _isoFileResourceAccessor.OpenRead();
try
{
_diskFileSystem = GetFileSystem(_underlayingStream);
}
catch
{
_underlayingStream.Dispose();
throw;
}
}
示例4: IsResource
public bool IsResource(IFileSystemResourceAccessor baseResourceAccessor, string path)
{
string entryPath = ZipResourceAccessor.ToEntryPath(path);
lock (_syncObj)
{
string key = baseResourceAccessor.CanonicalLocalResourcePath.Serialize();
try
{
ZipResourceProxy proxy;
if (_zipUsages.TryGetValue(key, out proxy))
return path.Equals("/") || ZipResourceAccessor.IsResource(proxy.ZipFile, entryPath);
}
catch (Exception)
{
return false;
}
}
using (Stream resourceStream = baseResourceAccessor.OpenRead()) // Not sure if the ZipFile will close the stream so we dispose it here
try
{
using (ZipFile zFile = new ZipFile(resourceStream))
return path.Equals("/") || ZipResourceAccessor.IsResource(zFile, entryPath);
}
catch (Exception)
{
return false;
}
}
示例5: ReadMediaInfo
protected MediaInfoWrapper ReadMediaInfo(IFileSystemResourceAccessor mediaItemAccessor)
{
MediaInfoWrapper result = new MediaInfoWrapper();
ILocalFsResourceAccessor localFsResourceAccessor = mediaItemAccessor as ILocalFsResourceAccessor;
if (ReferenceEquals(localFsResourceAccessor, null))
{
Stream stream = null;
try
{
stream = mediaItemAccessor.OpenRead();
if (stream != null)
result.Open(stream);
}
finally
{
if (stream != null)
stream.Close();
}
}
else
{
using (localFsResourceAccessor.EnsureLocalFileSystemAccess())
result.Open(localFsResourceAccessor.LocalFileSystemPath);
}
return result;
}
示例6: ReadMetaInfo
private void ReadMetaInfo(IFileSystemResourceAccessor mediaItemAccessor)
{
using (Stream mediaStream = mediaItemAccessor.OpenRead())
ReadMetaInfo(mediaStream);
}
示例7: IsResource
public bool IsResource(IFileSystemResourceAccessor baseResourceAccessor, string path)
{
string resourceName = baseResourceAccessor.ResourceName;
if (string.IsNullOrEmpty(resourceName) || !baseResourceAccessor.IsFile)
return false;
// Test if we have already an ISO proxy for that ISO file...
lock (_syncObj)
{
string key = baseResourceAccessor.CanonicalLocalResourcePath.Serialize();
try
{
IsoResourceProxy proxy;
if (_isoUsages.TryGetValue(key, out proxy))
lock (proxy.SyncObj)
return IsoResourceAccessor.IsResource(proxy.DiskFileSystem, path);
}
catch (Exception)
{
return false;
}
}
// ... if not, test the resource in a new disk file system instance
using (Stream underlayingStream = baseResourceAccessor.OpenRead())
{
try
{
IFileSystem diskFileSystem = IsoResourceProxy.GetFileSystem(underlayingStream);
using (diskFileSystem as IDisposable)
return IsoResourceAccessor.IsResource(diskFileSystem, path);
}
catch
{
return false;
}
}
}
示例8: ReadMediaInfo
protected MediaInfoWrapper ReadMediaInfo(IFileSystemResourceAccessor mediaItemAccessor)
{
MediaInfoWrapper result = new MediaInfoWrapper();
Stream stream = null;
try
{
stream = mediaItemAccessor.OpenRead();
if (stream != null)
result.Open(stream);
}
finally
{
if (stream != null)
stream.Close();
}
return result;
}