本文整理汇总了C#中IronRuby.StandardLibrary.StringIO.StringIO类的典型用法代码示例。如果您正苦于以下问题:C# StringIO类的具体用法?C# StringIO怎么用?C# StringIO使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
StringIO类属于IronRuby.StandardLibrary.StringIO命名空间,在下文中一共展示了StringIO类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: OpenIO
public static object OpenIO([NotNull]BlockParam/*!*/ block, RubyClass/*!*/ self, [Optional]MutableString initialString, [Optional]MutableString mode) {
MutableStringStream stream = new MutableStringStream(initialString ?? MutableString.CreateBinary());
string ioMode = (mode != null) ? mode.ConvertToString() : "rb+";
RubyIO io = new StringIO(self.Context, stream, ioMode);
object result;
block.Yield(io, out result);
if (!io.Closed) {
io.Close();
}
return result;
}
开发者ID:joshholmes,项目名称:ironruby,代码行数:12,代码来源:StringIO.cs
示例2: Write
public static int Write(StringIO/*!*/ self, [NotNull]MutableString/*!*/ value) {
var content = self.GetWritableContent();
int length = content.GetByteCount();
var bytesWritten = value.GetByteCount();
int pos;
if ((self._mode & IOMode.WriteAppends) != 0) {
pos = length;
} else {
pos = self._position;
}
try {
content.WriteBytes(pos, value, 0, bytesWritten);
} catch (InvalidOperationException) {
throw RubyExceptions.CreateIOError("not modifiable string");
}
content.TaintBy(value);
self._position = pos + bytesWritten;
return bytesWritten;
}
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:22,代码来源:StringIO.cs
示例3: IsConsole
public static bool IsConsole(StringIO/*!*/ self) {
// nop
return false;
}
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:4,代码来源:StringIO.cs
示例4: Sync
public static bool Sync(StringIO/*!*/ self) {
// nop
return true;
}
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:4,代码来源:StringIO.cs
示例5: GetDescriptor
public static object GetDescriptor(StringIO/*!*/ self) {
// nop
return null;
}
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:4,代码来源:StringIO.cs
示例6: SetBinaryMode
public static StringIO/*!*/ SetBinaryMode(StringIO/*!*/ self) {
// nop
return self;
}
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:4,代码来源:StringIO.cs
示例7: 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;
}
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:6,代码来源:StringIO.cs
示例8: 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;
}
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:14,代码来源:StringIO.cs
示例9: 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++));
}
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:9,代码来源:StringIO.cs
示例10: SystemRead
public static MutableString/*!*/ SystemRead(StringIO/*!*/ self, [DefaultProtocol]int bytes, [DefaultProtocol, Optional, NotNull]MutableString buffer) {
var result = Read(self, bytes, buffer);
if (result == null) {
throw new EOFError("end of file reached");
}
return result;
}
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:7,代码来源:StringIO.cs
示例11: 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;
}
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:24,代码来源:StringIO.cs
示例12: ReadLine
public static MutableString/*!*/ ReadLine(RubyScope/*!*/ scope, StringIO/*!*/ self, [DefaultProtocol]MutableString separator) {
// no dynamic call, modifies $_ scope variable:
MutableString result = Gets(scope, self, separator);
if (result == null) {
throw new EOFError("end of file reached");
}
return result;
}
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:9,代码来源:StringIO.cs
示例13: 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");
}
}
}
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:20,代码来源:StringIO.cs
示例14: 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++);
}
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:10,代码来源:StringIO.cs
示例15: 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;
}
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:17,代码来源:StringIO.cs
示例16: GetLineNo
public static int GetLineNo(StringIO/*!*/ self) {
return self._lineNumber;
}
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:3,代码来源:StringIO.cs
示例17: FileControl
public static void FileControl(StringIO/*!*/ self) {
throw new NotImplementedError();
}
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:3,代码来源:StringIO.cs
示例18: SetLineNo
public static void SetLineNo(StringIO/*!*/ self, [DefaultProtocol]int value) {
self._lineNumber = value;
}
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:3,代码来源:StringIO.cs
示例19: FSync
public static int FSync(StringIO/*!*/ self) {
// nop
return 0;
}
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:4,代码来源:StringIO.cs
示例20: Gets
public static MutableString Gets(RubyScope/*!*/ scope, StringIO/*!*/ self) {
return Gets(scope, self, scope.RubyContext.InputSeparator);
}
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:3,代码来源:StringIO.cs
注:本文中的IronRuby.StandardLibrary.StringIO.StringIO类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论