IronRuby.Builtins.RubyIOOps.Read C# (CSharp) Method

Read() private method

private Read ( object>.ConversionStorage toHash, ConversionStorage fixnumCast, ConversionStorage toPath, RubyClass self, object path, [ optionsOrLength, [ optionsOrOffset, [ options ) : MutableString
toHash object>.ConversionStorage
fixnumCast ConversionStorage
toPath ConversionStorage
self RubyClass
path object
optionsOrLength [
optionsOrOffset [
options [
return MutableString
        public static MutableString/*!*/ Read(
            ConversionStorage<IDictionary<object, object>>/*!*/ toHash,
            ConversionStorage<int>/*!*/ fixnumCast,
            ConversionStorage<MutableString>/*!*/ toPath,
            RubyClass/*!*/ self,
            object path, 
            [Optional]object optionsOrLength, 
            [Optional]object optionsOrOffset,
            [DefaultParameterValue(null), DefaultProtocol]IDictionary<object, object> options) {

            Protocols.TryConvertToOptions(toHash, ref options, ref optionsOrLength, ref optionsOrOffset);
            var site = fixnumCast.GetSite(ConvertToFixnumAction.Make(fixnumCast.Context));

            int length = (optionsOrLength != Missing.Value && optionsOrLength != null) ? site.Target(site, optionsOrLength) : 0;
            int offset = (optionsOrOffset != Missing.Value && optionsOrOffset != null) ? site.Target(site, optionsOrOffset) : 0;

            if (offset < 0) {
                throw RubyExceptions.CreateEINVAL();
            }

            if (length < 0) {
                throw RubyExceptions.CreateArgumentError("negative length {0} given", length);
            }

            // TODO: options

            using (RubyIO io = new RubyFile(self.Context, self.Context.DecodePath(Protocols.CastToPath(toPath, path)), IOMode.ReadOnly)) {
                if (offset > 0) {
                    io.Seek(offset, SeekOrigin.Begin);
                }

                if (optionsOrLength != Missing.Value && optionsOrLength != null) {
                    return Read(io, length, null);
                } else {
                    return Read(io);
                }
            }
        }

Same methods

RubyIOOps::Read ( RubyIO self ) : MutableString
RubyIOOps::Read ( RubyIO self, Microsoft.Scripting.Runtime.DynamicNull bytes, [ buffer ) : MutableString
RubyIOOps::Read ( RubyIO self, [ bytes, [ buffer ) : MutableString

Usage Example

Example #1
0
 public static MutableString /*!*/ Read(RubyContext /*!*/ context, [DefaultProtocol] int bytes, [DefaultProtocol, Optional] MutableString buffer)
 {
     return(RubyIOOps.Read(context.InputProvider.GetOrResetCurrentStream(), bytes, buffer));
 }
All Usage Examples Of IronRuby.Builtins.RubyIOOps::Read