public void Deserialize <PARSER>(PARSER parser, ref Single3 outValue) where PARSER : IParser <PARSER> { var it = parser.ListItems.GetEnumerator(); it.MoveNext(); m_d.Deserialize(it.Current, ref outValue.x); it.MoveNext(); m_d.Deserialize(it.Current, ref outValue.y); it.MoveNext(); m_d.Deserialize(it.Current, ref outValue.z); }
public void Deserialize <PARSER>(PARSER parser, ref T memberOwner) where PARSER : IParser <PARSER> { var value = default(U); m_deserializer.Deserialize(parser, ref value); m_setter(ref memberOwner, value); }
public void Deserialize <PARSER>(PARSER parser, ref Quaternion outValue) where PARSER : IParser <PARSER> { var it = parser.ListItems.GetEnumerator(); var a = it.MoveNext(); m_d.Deserialize(it.Current, ref outValue.x); var b = it.MoveNext(); m_d.Deserialize(it.Current, ref outValue.y); var c = it.MoveNext(); m_d.Deserialize(it.Current, ref outValue.z); var d = it.MoveNext(); m_d.Deserialize(it.Current, ref outValue.w); }
public void DeserializeBoxed <PARSER>(PARSER parser, object boxed) where PARSER : IParser <PARSER> { var u = default(U); m_deserializer.Deserialize(parser, ref u); m_fi.SetValue(boxed, u); }
public static T Deserialize <PARSER, T>(this IDeserializerBase <T> d, PARSER parser) where PARSER : IParser <PARSER> { var value = default(T); d.Deserialize(parser, ref value); return(value); }
void OnRequestBytes(ArraySegment <Byte> x, IWritable transport) { var req = default(RPCRequest <PARSER>); try { var parser = new PARSER(); parser.SetBytes(x); m_d.Deserialize(parser, ref req); } catch (Exception ex) { // parse error var errorResponse = new RPCResponse <PARSER> { Id = req.Id, Error = ex.Message, }; var responseFormatter = new FORMATTER(); m_s.Serialize(errorResponse, responseFormatter); transport.WriteAsync(responseFormatter.GetStore().Bytes).Subscribe(); return; } try { var formatter = new FORMATTER(); var context = new RPCContext <PARSER>(req, formatter); m_dispatcher.DispatchRequest(context); var responseFormatter = new FORMATTER(); m_s.Serialize(context.Response, responseFormatter); transport.WriteAsync(responseFormatter.GetStore().Bytes).Subscribe(); } catch (Exception ex) { // call error var errorResponse = new RPCResponse <PARSER> { Id = req.Id, Error = ex.Message, }; var responseFormatter = new FORMATTER(); m_s.Serialize(errorResponse, responseFormatter); transport.WriteAsync(responseFormatter.GetStore().Bytes).Subscribe(); return; } }
public void Deserialize <PARSER>(PARSER json, ref U outValue) where PARSER : IParser <PARSER> { if (outValue == null) { outValue = (U)(IList <T>) new List <T>(); } outValue.Clear(); foreach (var item in json.ListItems) { var value = default(T); m_elementDeserializer.Deserialize(item, ref value); outValue.Add(value); } }
public RPCTransporter(IDuplexStream transport) { m_transport = transport; var r = new TypeRegistry(); m_s = r.GetSerializer <RPCRequest <PARSER> >(); m_d = r.GetDeserializer <RPCResponse <PARSER> >(); transport.ReadObservable.Subscribe(x => { var parser = new PARSER(); parser.SetBytes(x); var response = default(RPCResponse <PARSER>); m_d.Deserialize(parser, ref response); m_subject.OnNext(response); }); }
public void Deserialize <PARSER>(PARSER json, ref T[] outValue) where PARSER : IParser <PARSER> { var count = json.ListItems.Count(); if (outValue == null || outValue.Length != count) { outValue = new T[count]; } int i = 0; foreach (var item in json.ListItems) { m_elementDeserializer.Deserialize(item, ref outValue[i++]); } }