本文整理汇总了C#中IronRuby.StandardLibrary.StringIO.StringIO.GetReadableContent方法的典型用法代码示例。如果您正苦于以下问题:C# StringIO.GetReadableContent方法的具体用法?C# StringIO.GetReadableContent怎么用?C# StringIO.GetReadableContent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IronRuby.StandardLibrary.StringIO.StringIO
的用法示例。
在下文中一共展示了StringIO.GetReadableContent方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EachLine
public static object EachLine(BlockParam block, StringIO/*!*/ self, [DefaultProtocol]MutableString separator) {
// TODO: improve MSOps.EachLine
var content = self.GetReadableContent();
var result = MutableStringOps.EachLine(block, content, separator, self._position);
return ReferenceEquals(result, content) ? self : result;
}
示例2: EachByte
public static object EachByte(BlockParam block, StringIO/*!*/ self) {
MutableString content;
int pos;
while ((pos = self._position) < (content = self.GetReadableContent()).GetByteCount()) {
if (block == null) {
throw RubyExceptions.NoBlockGiven();
}
self._position++;
object result;
if (block.Yield(ScriptingRuntimeHelpers.Int32ToObject(content.GetByte(pos)), out result)) {
return result;
}
}
return null;
}
示例3: Gets
public static MutableString Gets(RubyScope/*!*/ scope, StringIO/*!*/ self, [DefaultProtocol]MutableString separator) {
var content = self.GetReadableContent();
int position = self._position;
MutableString result = ReadLine(content, separator, ref position);
self._position = position;
scope.GetInnerMostClosureScope().LastInputLine = result;
self._lineNumber++;
return result;
}
示例4: ReadLines
public static RubyArray/*!*/ ReadLines(StringIO/*!*/ self, [DefaultProtocol]MutableString separator) {
var content = self.GetReadableContent();
RubyArray result = new RubyArray();
// no dynamic call, doesn't modify $_ scope variable:
MutableString line;
int position = self._position;
while ((line = ReadLine(content, separator, ref position)) != null) {
result.Add(line);
self._lineNumber++;
}
self._position = position;
return result;
}
示例5: SetPreviousByte
public static void SetPreviousByte(StringIO/*!*/ self, [DefaultProtocol]int b) {
// MRI: this checks if the IO is readable although it actually modifies the string:
MutableString content = self.GetReadableContent();
int pos = self._position - 1;
if (pos >= 0) {
int length = content.GetByteCount();
try {
if (pos >= length) {
content.Append(0, pos - length);
content.Append(unchecked((byte)b));
} else {
content.SetByte(pos, unchecked((byte)b));
}
self._position = pos;
} catch (InvalidOperationException) {
throw RubyExceptions.CreateIOError("not modifiable string");
}
}
}
示例6: ReadChar
public static int ReadChar(StringIO/*!*/ self) {
var content = self.GetReadableContent();
int length = content.GetByteCount();
if (self._position >= length) {
throw new EOFError("end of file reached");
}
return content.GetByte(self._position++);
}
示例7: GetByte
public static object GetByte(StringIO/*!*/ self) {
var content = self.GetReadableContent();
if (self._position >= content.GetByteCount()) {
return null;
}
return ScriptingRuntimeHelpers.Int32ToObject(content.GetByte(self._position++));
}
示例8: Read
public static MutableString Read(StringIO/*!*/ self, [DefaultProtocol]int count, [DefaultProtocol, Optional, NotNull]MutableString buffer) {
var content = self.GetReadableContent();
if (count < 0) {
throw RubyExceptions.CreateArgumentError("negative length -1 given");
}
if (buffer != null) {
buffer.Clear();
}
int length = content.GetByteCount();
if (self._position >= length) {
return null;
}
if (buffer == null) {
buffer = MutableString.CreateBinary();
}
int bytesRead = Math.Min(count, length - self._position);
buffer.Append(content, self._position, bytesRead).TaintBy(content);
self._position += bytesRead;
return buffer;
}
示例9: Eof
public static bool Eof(StringIO/*!*/ self) {
var context = self.GetReadableContent();
return self._position >= context.GetByteCount();
}
示例10: CloseRead
public static void CloseRead(StringIO/*!*/ self) {
self.GetReadableContent();
self._mode = self._mode.CloseRead();
}