public AspNetRequest(HttpRequest request) { ContractUtils.RequiresNotNull(request, "request"); // http or https this.scheme = request.Url.Scheme; // move headers to a Ruby Hash this.headers = new Hash(IronRubyEngine.Context); foreach (string key in request.Headers.AllKeys) { string value = request.Headers.Get(key); if (string.IsNullOrEmpty(value)) { continue; } headers.Add(key, value); } this.queryString = request.QueryString.ToString(); this.body = new RubyIO(IronRubyEngine.Context, request.InputStream, IOMode.ReadOnly); // Save the origional request incase it's needed. OrigionalRequest = request; }
public static int Seek(StringIO /*!*/ self, [DefaultProtocol] int pos, [DefaultProtocol, DefaultParameterValue(RubyIO.SEEK_SET)] int seekOrigin) { self.SetPosition(RubyIO.GetSeekPosition( self._content.GetByteCount(), self._position, pos, RubyIO.ToSeekOrigin(seekOrigin) )); return(0); }
private static TextReader CheckYamlPort(object port) { MutableString ms = port as MutableString; if (ms != null) { return(new MutableStringReader(ms)); } string str = port as string; if (str != null) { return(new StringReader(str)); } RubyIO io = port as RubyIO; if (io != null) { RubyIOOps.Binmode(io); return(new RubyIOReader(io)); } throw RubyExceptions.CreateTypeError("instance of IO needed"); }
public static object Parse(RubyModule self, object io) { try { foreach (object obj in MakeComposer(CheckYamlPort(io))) { return(obj); } return(null); } finally { RubyIO rio = io as RubyIO; if (rio != null) { rio.Close(); } } }
public static object Load(RubyScope /*!*/ scope, RubyModule /*!*/ self, object io) { try { foreach (object obj in MakeConstructor(scope, CheckYamlPort(io))) { return(obj); } return(null); } finally { RubyIO rio = io as RubyIO; if (rio != null) { rio.Close(); } } }
public static object Load(ConversionStorage <MutableString> /*!*/ toStr, RespondToStorage /*!*/ respondTo, RubyScope /*!*/ scope, RubyModule /*!*/ self, object io) { try { foreach (object obj in MakeConstructor(scope.GlobalScope, GetStream(toStr, respondTo, io))) { return(obj); } return(null); } catch (Exception e) { throw RubyExceptions.CreateArgumentError(e, e.Message); } finally { RubyIO rio = io as RubyIO; if (rio != null) { rio.Close(); } } }
public static object Emit(YamlCallSiteStorage /*!*/ siteStorage, YamlStream /*!*/ self, [Optional] RubyIO io) { return(RubyYaml.DumpAll(siteStorage, self._documents, io)); }
public static object Emit(RubyContext /*!*/ context, YamlStream /*!*/ self, [Optional] RubyIO io) { return(RubyYaml.DumpAll(context, self.Documents, io)); }
public static object DumpAll(YamlCallSiteStorage /*!*/ siteStorage, RubyModule /*!*/ self, [NotNull] IList /*!*/ objs, [Optional] RubyIO io) { return(DumpAll(siteStorage, objs, io)); }
public static object DumpAll(RubyModule /*!*/ self, [NotNull] IEnumerable objs, [Optional] RubyIO io) { return(DumpAll(self.Context, objs, io)); }
public static object Dump(RubyModule /*!*/ self, object obj, [Optional] RubyIO io) { return(DumpAll(self, new object[] { obj }, io)); }
public static GZipReader /*!*/ Create(RubyClass /*!*/ self, [NotNull] RubyIO /*!*/ io) { using (BinaryReader reader = io.GetBinaryReader()) { return(new GZipReader(reader)); } }
internal RubyIOWriter(RubyIO /*!*/ io) { Assert.NotNull(io); _io = io; }
internal static object DumpAll(RubyRepresenter /*!*/ rep, IEnumerable /*!*/ objs, RubyIO io) { TextWriter writer; if (io != null) { writer = new RubyIOWriter(io); } else { // the output is ascii: writer = new MutableStringWriter(MutableString.CreateMutable(RubyEncoding.Binary)); } YamlOptions cfg = YamlOptions.DefaultOptions; Serializer s = new Serializer(writer, cfg); foreach (object obj in objs) { s.Serialize(rep.Represent(obj)); rep.ForgetObjects(); } s.Close(); if (io != null) { return(io); } else { return(((MutableStringWriter)writer).String); } }
internal static object DumpAll(YamlCallSiteStorage /*!*/ siteStorage, IEnumerable /*!*/ objs, RubyIO io) { return(DumpAll(new RubyRepresenter(siteStorage), objs, io)); }
internal static object DumpAll(RubyContext /*!*/ context, [NotNull] IEnumerable objs, [Optional] RubyIO io) { TextWriter writer; if (io != null) { writer = new RubyIOWriter(io); } else { writer = new MutableStringWriter(); } YamlOptions cfg = YamlOptions.DefaultOptions; using (Serializer s = new Serializer(new Emitter(writer, cfg), cfg)) { RubyRepresenter r = new RubyRepresenter(context, s, cfg); foreach (object obj in objs) { r.Represent(obj); } } if (null != io) { return(io); } else { return(((MutableStringWriter)writer).String); } }
internal RubyIOReader(RubyIO io) { _io = io; }
public static object Dump(YamlCallSiteStorage /*!*/ siteStorage, RubyModule /*!*/ self, object obj, [Optional] RubyIO io) { return(DumpAll(siteStorage, new object[] { obj }, io)); }