本文整理汇总了C#中Ownership类的典型用法代码示例。如果您正苦于以下问题:C# Ownership类的具体用法?C# Ownership怎么用?C# Ownership使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Ownership类属于命名空间,在下文中一共展示了Ownership类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: BZip2DecoderStream
/// <summary>
/// Initializes a new instance of the BZip2DecoderStream class.
/// </summary>
/// <param name="stream">The compressed input stream.</param>
/// <param name="ownsStream">Whether ownership of stream passes to the new instance.</param>
public BZip2DecoderStream(Stream stream, Ownership ownsStream)
{
_compressedStream = stream;
_ownsCompressed = ownsStream;
_bitstream = new BigEndianBitStream(new BufferedStream(stream));
// The Magic BZh
byte[] magic = new byte[3];
magic[0] = (byte)_bitstream.Read(8);
magic[1] = (byte)_bitstream.Read(8);
magic[2] = (byte)_bitstream.Read(8);
if (magic[0] != 0x42 || magic[1] != 0x5A || magic[2] != 0x68)
{
throw new InvalidDataException("Bad magic at start of stream");
}
// The size of the decompression blocks in multiples of 100,000
int blockSize = (int)_bitstream.Read(8) - 0x30;
if (blockSize < 1 || blockSize > 9)
{
throw new InvalidDataException("Unexpected block size in header: " + blockSize);
}
blockSize *= 100000;
_rleStream = new BZip2RleStream();
_blockDecoder = new BZip2BlockDecoder(blockSize);
_blockBuffer = new byte[blockSize];
if (ReadBlock() == 0)
{
_eof = true;
}
}
开发者ID:alexcmd,项目名称:DiscUtils,代码行数:40,代码来源:BZip2DecoderStream.cs
示例2: VirtualMachine
/// <summary>
/// Creates a new instance from a stream.
/// </summary>
/// <param name="fileStream">The stream containing the .XVA file</param>
/// <param name="ownership">Whether to transfer ownership of <c>fileStream</c> to the new instance.</param>
public VirtualMachine(Stream fileStream, Ownership ownership)
{
_fileStream = fileStream;
_ownership = ownership;
_fileStream.Position = 0;
_archive = new TarFile(fileStream);
}
开发者ID:joconno4,项目名称:MediaPortal-2,代码行数:12,代码来源:VirtualMachine.cs
示例3: BlockCacheStream
/// <summary>
/// Initializes a new instance of the BlockCacheStream class.
/// </summary>
/// <param name="toWrap">The stream to wrap.</param>
/// <param name="ownership">Whether to assume ownership of <c>toWrap</c>.</param>
/// <param name="settings">The cache settings.</param>
public BlockCacheStream(SparseStream toWrap, Ownership ownership, BlockCacheSettings settings)
{
if (!toWrap.CanRead)
{
throw new ArgumentException("The wrapped stream does not support reading", "toWrap");
}
if (!toWrap.CanSeek)
{
throw new ArgumentException("The wrapped stream does not support seeking", "toWrap");
}
_wrappedStream = toWrap;
_ownWrapped = ownership;
_settings = new BlockCacheSettings(settings);
if (_settings.OptimumReadSize % _settings.BlockSize != 0)
{
throw new ArgumentException("Invalid settings, OptimumReadSize must be a multiple of BlockSize", "settings");
}
_readBuffer = new byte[_settings.OptimumReadSize];
_blocksInReadBuffer = _settings.OptimumReadSize / _settings.BlockSize;
int totalBlocks = (int)(_settings.ReadCacheSize / _settings.BlockSize);
_cache = new BlockCache<Block>(_settings.BlockSize, totalBlocks);
_stats = new BlockCacheStatistics();
_stats.FreeReadBlocks = totalBlocks;
}
开发者ID:easymetadata,项目名称:DiscUtils,代码行数:36,代码来源:BlockCacheStream.cs
示例4: HostedSparseExtentStream
public HostedSparseExtentStream(Stream file, Ownership ownsFile, long diskOffset, SparseStream parentDiskStream, Ownership ownsParentDiskStream)
{
_fileStream = file;
_ownsFileStream = ownsFile;
_diskOffset = diskOffset;
_parentDiskStream = parentDiskStream;
_ownsParentDiskStream = ownsParentDiskStream;
file.Position = 0;
byte[] headerSector = Utilities.ReadFully(file, Sizes.Sector);
_hostedHeader = HostedSparseExtentHeader.Read(headerSector, 0);
if (_hostedHeader.GdOffset == -1)
{
// Fall back to secondary copy that (should) be at the end of the stream, just before the end-of-stream sector marker
file.Position = file.Length - Sizes.OneKiB;
headerSector = Utilities.ReadFully(file, Sizes.Sector);
_hostedHeader = HostedSparseExtentHeader.Read(headerSector, 0);
if (_hostedHeader.MagicNumber != HostedSparseExtentHeader.VmdkMagicNumber)
{
throw new IOException("Unable to locate valid VMDK header or footer");
}
}
_header = _hostedHeader;
if (_hostedHeader.CompressAlgorithm != 0 && _hostedHeader.CompressAlgorithm != 1)
{
throw new NotSupportedException("Only uncompressed and DEFLATE compressed disks supported");
}
_gtCoverage = _header.NumGTEsPerGT * _header.GrainSize * Sizes.Sector;
LoadGlobalDirectory();
}
开发者ID:AnotherAltr,项目名称:Rc.Core,代码行数:35,代码来源:HostedSparseExtentStream.cs
示例5: DiskImageFile
/// <summary>
/// Initializes a new instance of the DiskImageFile class.
/// </summary>
/// <param name="stream">The stream to interpret</param>
/// <param name="ownsStream">Indicates if the new instance should control the lifetime of the stream.</param>
public DiskImageFile(Stream stream, Ownership ownsStream)
{
_stream = stream;
_ownsStream = ownsStream;
ReadHeader();
}
开发者ID:easymetadata,项目名称:discutils_Ewf-POC,代码行数:12,代码来源:DiskImageFile.cs
示例6: StripedStream
public StripedStream(long stripeSize, Ownership ownsWrapped, params SparseStream[] wrapped)
{
_wrapped = new List<SparseStream>(wrapped);
_stripeSize = stripeSize;
_ownsWrapped = ownsWrapped;
_canRead = _wrapped[0].CanRead;
_canWrite = _wrapped[0].CanWrite;
long subStreamLength = _wrapped[0].Length;
foreach (var stream in _wrapped)
{
if (stream.CanRead != _canRead || stream.CanWrite != _canWrite)
{
throw new ArgumentException("All striped streams must have the same read/write permissions", "wrapped");
}
if (stream.Length != subStreamLength)
{
throw new ArgumentException("All striped streams must have the same length", "wrapped");
}
}
_length = subStreamLength * wrapped.Length;
}
开发者ID:JGTM2016,项目名称:discutils,代码行数:25,代码来源:StripedStream.cs
示例7: SdiFile
/// <summary>
/// Initializes a new instance of the SdiFile class.
/// </summary>
/// <param name="stream">The stream formatted as an SDI file.</param>
/// <param name="ownership">Whether to pass ownership of <c>stream</c> to the new instance.</param>
public SdiFile(Stream stream, Ownership ownership)
{
_stream = stream;
_ownership = ownership;
byte[] page = Utilities.ReadFully(_stream, 512);
_header = new FileHeader();
_header.ReadFrom(page, 0);
_stream.Position = _header.PageAlignment * 512;
byte[] toc = Utilities.ReadFully(_stream, (int)(_header.PageAlignment * 512));
_sections = new List<SectionRecord>();
int pos = 0;
while (Utilities.ToUInt64LittleEndian(toc, pos) != 0)
{
SectionRecord record = new SectionRecord();
record.ReadFrom(toc, pos);
_sections.Add(record);
pos += SectionRecord.RecordSize;
}
}
开发者ID:easymetadata,项目名称:DiscUtils,代码行数:30,代码来源:SdiFile.cs
示例8: ContentStream
public ContentStream(SparseStream fileStream, BlockAllocationTable bat, long length, SparseStream parentStream, Ownership ownsParent)
{
_fileStream = fileStream;
_bat = bat;
_length = length;
_parentStream = parentStream;
_ownsParent = ownsParent;
}
开发者ID:marinehero,项目名称:ThinkAway.net,代码行数:8,代码来源:ContentStream.cs
示例9: OpenContent
public override SparseStream OpenContent(SparseStream parent, Ownership ownsParent)
{
if (ownsParent == Ownership.Dispose && parent != null)
{
parent.Dispose();
}
return SparseStream.FromStream(Content, Ownership.None);
}
开发者ID:marinehero,项目名称:ThinkAway.net,代码行数:9,代码来源:DiscImageFile.cs
示例10: DiskStream
public DiskStream(Stream fileStream, Ownership ownsStream, HeaderRecord fileHeader)
{
_fileStream = fileStream;
_fileHeader = fileHeader;
_ownsStream = ownsStream;
ReadBlockTable();
}
开发者ID:joconno4,项目名称:MediaPortal-2,代码行数:9,代码来源:DiskStream.cs
示例11: WrappingStream
/// <summary>
/// Initializes a new instance of the <see cref="WrappingStream"/> class.
/// </summary>
/// <param name="streamBase">The wrapped stream.</param>
/// <param name="ownership">Use Owns if the wrapped stream should be disposed when this stream is disposed.</param>
public WrappingStream(Stream streamBase, Ownership ownership)
{
// check parameters
if (streamBase == null)
throw new ArgumentNullException("streamBase");
m_streamBase = streamBase;
m_ownership = ownership;
}
开发者ID:mattrudder,项目名称:mono-embed,代码行数:14,代码来源:WrappingStream.cs
示例12: DiskImageFile
/// <summary>
/// Initializes a new instance of the DiskImageFile class.
/// </summary>
/// <param name="stream">The stream to interpret</param>
/// <param name="ownsStream">Indicates if the new instance should control the lifetime of the stream.</param>
public DiskImageFile(Stream stream, Ownership ownsStream)
{
_fileStream = stream;
_ownsStream = ownsStream;
ReadFooter(true);
ReadHeaders();
}
开发者ID:marinehero,项目名称:ThinkAway.net,代码行数:14,代码来源:DiskImageFile.cs
示例13: Disk
/// <summary>
/// Initializes a new instance of the Disk class. Differencing disks are not supported.
/// </summary>
/// <param name="stream">The stream to read</param>
/// <param name="ownsStream">Indicates if the new instance should control the lifetime of the stream.</param>
public Disk(Stream stream, Ownership ownsStream)
{
_files = new List<DiscUtils.Tuple<DiskImageFile, Ownership>>();
_files.Add(new DiscUtils.Tuple<DiskImageFile, Ownership>(new DiskImageFile(stream, ownsStream), Ownership.Dispose));
if (_files[0].First.NeedsParent)
{
throw new NotSupportedException("Differencing disks cannot be opened from a stream");
}
}
开发者ID:JGTM2016,项目名称:discutils,代码行数:15,代码来源:Disk.cs
示例14: Disk
/// <summary>
/// Initializes a new instance of the Disk class. Only monolithic sparse streams are supported.
/// </summary>
/// <param name="stream">The stream containing the VMDK file</param>
/// <param name="ownsStream">Indicates if the new instances owns the stream.</param>
public Disk(Stream stream, Ownership ownsStream)
{
FileStream fileStream = stream as FileStream;
if (fileStream != null)
{
_path = fileStream.Name;
}
_files = new List<ThinkAway.Tuple<VirtualDiskLayer, Ownership>>();
_files.Add(new ThinkAway.Tuple<VirtualDiskLayer, Ownership>(new DiskImageFile(stream, ownsStream), Ownership.Dispose));
}
开发者ID:marinehero,项目名称:ThinkAway.net,代码行数:16,代码来源:Disk.cs
示例15: SubStream
public SubStream(Stream parent, Ownership ownsParent, long first, long length)
{
_parent = parent;
_ownsParent = ownsParent;
_first = first;
_length = length;
if (_first + _length > _parent.Length)
{
throw new ArgumentException("Substream extends beyond end of parent stream");
}
}
开发者ID:marinehero,项目名称:ThinkAway.net,代码行数:12,代码来源:SubStream.cs
示例16: ThreadSafeStream
/// <summary>
/// Creates a new instance, wrapping an existing stream.
/// </summary>
/// <param name="toWrap">The stream to wrap</param>
/// <param name="ownership">Whether to transfer ownership of <c>toWrap</c> to the new instance</param>
/// <remarks>Do not directly modify <c>toWrap</c> after wrapping it, unless the thread-safe views
/// will no longer be used.</remarks>
public ThreadSafeStream(SparseStream toWrap, Ownership ownership)
{
if (!toWrap.CanSeek)
{
throw new ArgumentException("Wrapped stream must support seeking", "toWrap");
}
_common = new CommonState {
WrappedStream = toWrap,
WrappedStreamOwnership = ownership };
_ownsCommon = true;
}
开发者ID:joconno4,项目名称:MediaPortal-2,代码行数:19,代码来源:ThreadSafeStream.cs
示例17: DiskImageFile
/// <summary>
/// Initializes a new instance of the DiskImageFile class.
/// </summary>
/// <param name="stream">The stream to interpret</param>
/// <param name="ownsStream">Indicates if the new instance should control the lifetime of the stream.</param>
/// <param name="geometry">The emulated geometry of the disk.</param>
public DiskImageFile(Stream stream, Ownership ownsStream, Geometry geometry)
{
_content = stream as SparseStream;
_ownsContent = ownsStream;
if (_content == null)
{
_content = SparseStream.FromStream(stream, ownsStream);
_ownsContent = Ownership.Dispose;
}
_geometry = geometry ?? DetectGeometry(_content);
}
开发者ID:JGTM2016,项目名称:discutils,代码行数:19,代码来源:DiskImageFile.cs
示例18: ContentStream
public ContentStream(SparseStream fileStream, Stream batStream, FreeSpaceTable freeSpaceTable, Metadata metadata, long length, SparseStream parentStream, Ownership ownsParent)
{
_fileStream = fileStream;
_batStream = batStream;
_freeSpaceTable = freeSpaceTable;
_metadata = metadata;
_fileParameters = _metadata.FileParameters;
_length = length;
_parentStream = parentStream;
_ownsParent = ownsParent;
_chunks = new ObjectCache<int, Chunk>();
}
开发者ID:JGTM2016,项目名称:discutils,代码行数:13,代码来源:ContentStream.cs
示例19: ConcatStream
public ConcatStream(Ownership ownsStreams, params SparseStream[] streams)
{
_ownsStreams = ownsStreams;
_streams = streams;
// Only allow writes if all streams can be written
_canWrite = true;
foreach (var stream in streams)
{
if (!stream.CanWrite)
{
_canWrite = false;
}
}
}
开发者ID:JGTM2016,项目名称:discutils,代码行数:15,代码来源:ConcatStream.cs
示例20: ServerSparseExtentStream
public ServerSparseExtentStream(Stream file, Ownership ownsFile, long diskOffset, SparseStream parentDiskStream, Ownership ownsParentDiskStream)
{
_fileStream = file;
_ownsFileStream = ownsFile;
_diskOffset = diskOffset;
_parentDiskStream = parentDiskStream;
_ownsParentDiskStream = ownsParentDiskStream;
file.Position = 0;
byte[] firstSectors = Utilities.ReadFully(file, Sizes.Sector * 4);
_serverHeader = ServerSparseExtentHeader.Read(firstSectors, 0);
_header = _serverHeader;
_gtCoverage = _header.NumGTEsPerGT * (long)_header.GrainSize * Sizes.Sector;
LoadGlobalDirectory();
}
开发者ID:JGTM2016,项目名称:discutils,代码行数:17,代码来源:ServerSparseExtentStream.cs
注:本文中的Ownership类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论