当前位置: 首页>>代码示例>>C#>>正文


C# StringIO.GetReadableContent方法代码示例

本文整理汇总了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;
 }
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:6,代码来源:StringIO.cs

示例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;
        }
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:17,代码来源:StringIO.cs

示例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;
        }
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:12,代码来源:StringIO.cs

示例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;
        }
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:14,代码来源:StringIO.cs

示例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");
                }
            }
        }
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:20,代码来源:StringIO.cs

示例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++);
        }
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:10,代码来源:StringIO.cs

示例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++));
        }
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:9,代码来源:StringIO.cs

示例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;
        }
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:24,代码来源:StringIO.cs

示例9: Eof

 public static bool Eof(StringIO/*!*/ self) {
     var context = self.GetReadableContent();
     return self._position >= context.GetByteCount();
 }
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:4,代码来源:StringIO.cs

示例10: CloseRead

 public static void CloseRead(StringIO/*!*/ self) {
     self.GetReadableContent();
     self._mode = self._mode.CloseRead();
 }
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:4,代码来源:StringIO.cs


注:本文中的IronRuby.StandardLibrary.StringIO.StringIO.GetReadableContent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。