本文整理汇总了C#中OutputStream类的典型用法代码示例。如果您正苦于以下问题:C# OutputStream类的具体用法?C# OutputStream怎么用?C# OutputStream使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
OutputStream类属于命名空间,在下文中一共展示了OutputStream类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PpmdArchiveDecoder
public PpmdArchiveDecoder(ImmutableArray<byte> settings, long length)
{
if (settings.IsDefault)
throw new ArgumentNullException(nameof(settings));
if (settings.Length != 5)
throw new InvalidDataException();
if (length < 0)
throw new ArgumentOutOfRangeException(nameof(length));
mOutput = new OutputStream(this);
mLength = length;
mSettingOrder = settings[0];
if (mSettingOrder < PPMD.PPMD7_MIN_ORDER || mSettingOrder > PPMD.PPMD7_MAX_ORDER)
throw new InvalidDataException();
mSettingMemory = (uint)settings[1] | ((uint)settings[2] << 8) | ((uint)settings[3] << 16) | ((uint)settings[4] << 24);
if (mSettingMemory < PPMD.PPMD7_MIN_MEM_SIZE || mSettingMemory > PPMD.PPMD7_MAX_MEM_SIZE)
throw new InvalidDataException();
mRangeDecoder = new PPMD.CPpmd7z_RangeDec();
PPMD.Ppmd7z_RangeDec_CreateVTable(mRangeDecoder);
mRangeDecoder.Stream = new PPMD.IByteIn { Read = x => ReadByte() };
PPMD.Ppmd7_Construct(mState);
if (!PPMD.Ppmd7_Alloc(mState, mSettingMemory, mAlloc))
throw new OutOfMemoryException();
}
示例2: WriteMoreDataThanCredited_OnlyCreditedDataWritten
public void WriteMoreDataThanCredited_OnlyCreditedDataWritten()
{
using (Stream transport = new QueueStream())
using (WriteQueue queue = new WriteQueue(transport))
{
Task pumpTask = queue.PumpToStreamAsync();
OutputStream output = new OutputStream(1, Framing.Priority.Pri1, queue);
FrameReader reader = new FrameReader(transport, false, CancellationToken.None);
int dataLength = 0x1FFFF; // More than the 0x10000 default
Task writeTask = output.WriteAsync(new byte[dataLength], 0, dataLength);
Assert.False(writeTask.IsCompleted);
Frame frame = reader.ReadFrameAsync().Result;
Assert.False(frame.IsControl);
Assert.Equal(0x10000, frame.FrameLength);
Task<Frame> nextFrameTask = reader.ReadFrameAsync();
Assert.False(nextFrameTask.IsCompleted);
// Free up some space
output.AddFlowControlCredit(10);
frame = nextFrameTask.Result;
Assert.False(frame.IsControl);
Assert.Equal(10, frame.FrameLength);
nextFrameTask = reader.ReadFrameAsync();
Assert.False(nextFrameTask.IsCompleted);
}
}
示例3: WriteMultipleData_OneFramePerWrite
public void WriteMultipleData_OneFramePerWrite()
{
using (Stream transport = new QueueStream())
using (WriteQueue queue = new WriteQueue(transport))
{
Task pumpTask = queue.PumpToStreamAsync();
Stream output = new OutputStream(1, Framing.Priority.Pri1, queue);
FrameReader reader = new FrameReader(transport, false, CancellationToken.None);
int dataLength = 100;
output.Write(new byte[dataLength], 0, dataLength);
output.Write(new byte[dataLength * 2], 0, dataLength * 2);
output.Write(new byte[dataLength * 3], 0, dataLength * 3);
Frame frame = reader.ReadFrameAsync().Result;
Assert.False(frame.IsControl);
Assert.Equal(dataLength, frame.FrameLength);
frame = reader.ReadFrameAsync().Result;
Assert.False(frame.IsControl);
Assert.Equal(dataLength * 2, frame.FrameLength);
frame = reader.ReadFrameAsync().Result;
Assert.False(frame.IsControl);
Assert.Equal(dataLength * 3, frame.FrameLength);
}
}
示例4: IndexingVariantContextWriter
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Requires({"name != null", "! ( location == null && output == null )", "! ( enableOnTheFlyIndexing && location == null )"}) protected IndexingVariantContextWriter(final String name, final File location, final OutputStream output, final net.sf.samtools.SAMSequenceDictionary refDict, final boolean enableOnTheFlyIndexing)
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not allowed in .NET:
protected internal IndexingVariantContextWriter(string name, File location, OutputStream output, SAMSequenceDictionary refDict, bool enableOnTheFlyIndexing)
{
outputStream = output;
this.name = name;
this.refDict = refDict;
if (enableOnTheFlyIndexing)
{
try
{
idxStream = new LittleEndianOutputStream(new FileOutputStream(Tribble.indexFile(location)));
//System.out.println("Creating index on the fly for " + location);
indexer = new DynamicIndexCreator(IndexFactory.IndexBalanceApproach.FOR_SEEK_TIME);
indexer.initialize(location, indexer.defaultBinSize());
positionalOutputStream = new PositionalOutputStream(output);
outputStream = positionalOutputStream;
}
catch (IOException ex)
{
// No matter what we keep going, since we don't care if we can't create the index file
idxStream = null;
indexer = null;
positionalOutputStream = null;
}
}
}
示例5: VCFWriter
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not allowed in .NET:
//ORIGINAL LINE: public VCFWriter(final File location, final OutputStream output, final net.sf.samtools.SAMSequenceDictionary refDict, final boolean enableOnTheFlyIndexing, boolean doNotWriteGenotypes, final boolean allowMissingFieldsInHeader)
public VCFWriter(File location, OutputStream output, SAMSequenceDictionary refDict, bool enableOnTheFlyIndexing, bool doNotWriteGenotypes, bool allowMissingFieldsInHeader) : base(writerName(location, output), location, output, refDict, enableOnTheFlyIndexing)
{
this.doNotWriteGenotypes = doNotWriteGenotypes;
this.allowMissingFieldsInHeader = allowMissingFieldsInHeader;
this.charset = Charset.forName("ISO-8859-1");
this.writer = new OutputStreamWriter(lineBuffer, charset);
}
示例6: Init
public void Init(IStreamHost host)
{
this.host = host;
this.path = host.CreateParameter<string>("Path");
this.to = host.CreateOutputStream<ImageStream>("Image Out");
}
示例7: Init
public void Init(IStreamHost host)
{
this.host = host;
this.testoutputstream = host.CreateOutputStream<DoubleStream>("Stream Out");
this.to2 = host.CreateOutputStream<ImageStream>("Image Out");
this.p1 = host.CreateParameter<double>("Param 1");
}
示例8: Lzma2ArchiveDecoder
public Lzma2ArchiveDecoder(ImmutableArray<byte> settings, long length)
{
System.Diagnostics.Debug.Assert(!settings.IsDefault && settings.Length == 1 && length >= 0);
mDecoder = new LZMA2.Decoder(new LZMA2.DecoderSettings(settings[0]));
mOutput = new OutputStream(this);
mBuffer = new byte[4 << 10]; // TODO: We shouldn't have to use a buffer here. Let the input stream submit directly into the decoder.
mLength = length;
}
示例9: Write
public void Write(Action<Stream> output)
{
Action complete = () => { };
var stream = new OutputStream((segment, continuation) =>
{
_response.BinaryWrite(segment);
return true;
}, complete);
output(stream);
}
示例10: Init
public void Init(IStreamHost host)
{
this.host = host;
this.testinputstream = host.CreateInputStream<IBaseStream>("Stream In");
this.testoutputstream = host.CreateOutputStream<IBaseStream>("Stream Out");
this.p1 = host.CreateParameter<double>("Param 1");
this.p2 = host.CreateParameter<double>("Param 2");
this.testoutdata = host.CreateOutput<double>("Out 1");
}
示例11: CopyArchiveDecoder
public CopyArchiveDecoder(ImmutableArray<byte> settings, long length)
{
if (settings.IsDefault)
throw new ArgumentNullException(nameof(settings));
if (!settings.IsEmpty)
throw new InvalidDataException();
if (length < 0)
throw new ArgumentOutOfRangeException(nameof(length));
mOutput = new OutputStream(this);
mLength = length;
}
示例12: CopyStream
public static void CopyStream(Stream inputStream, OutputStream os)
{
int buffer_size = 1024;
try {
byte[] bytes = new byte[buffer_size];
for (;;) {
int count = inputStream.Read (bytes, 0, buffer_size);
if (count <= 0)
break;
os.Write (bytes, 0, count);
}
} catch (Exception ex) {
}
}
示例13: create
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not allowed in .NET:
//ORIGINAL LINE: public static VariantContextWriter create(final java.io.File location, final java.io.OutputStream output, final net.sf.samtools.SAMSequenceDictionary refDict, final java.util.EnumSet<Options> options)
public static VariantContextWriter create(File location, OutputStream output, SAMSequenceDictionary refDict, EnumSet<Options> options)
{
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final boolean enableBCF = isBCFOutput(location, options);
bool enableBCF = isBCFOutput(location, options);
if (enableBCF)
{
return new BCF2Writer(location, output, refDict, options.contains(Options.INDEX_ON_THE_FLY), options.contains(Options.DO_NOT_WRITE_GENOTYPES));
}
else
{
return new VCFWriter(location, output, refDict, options.contains(Options.INDEX_ON_THE_FLY), options.contains(Options.DO_NOT_WRITE_GENOTYPES), options.contains(Options.ALLOW_MISSING_FIELDS_IN_HEADER));
}
}
示例14: write__
public virtual void write__(OutputStream os__)
{
os__.startObject(null);
writeImpl__(os__);
os__.endObject();
}
示例15: ConnectedThread
public ConnectedThread(BluetoothChatService chatService, BluetoothSocket socket, string socketType)
{
Log.D(TAG, "create ConnectedThread: " + socketType);
this.chatService = chatService;
mmSocket = socket;
InputStream tmpIn = null;
OutputStream tmpOut = null;
// Get the BluetoothSocket input and output streams
try
{
tmpIn = socket.GetInputStream();
tmpOut = socket.GetOutputStream();
}
catch (IOException e)
{
Log.E(TAG, "temp sockets not created", e);
}
mmInStream = tmpIn;
mmOutStream = tmpOut;
}