static void WriteList(object value, CodedOutputStream stream) { var encodedList = new KRPC.Schema.KRPC.List(); var list = (IList)value; using (var internalBuffer = new MemoryStream()) { var internalStream = new CodedOutputStream(internalBuffer); foreach (var item in list) { encodedList.Items.Add(EncodeObject(item, internalBuffer, internalStream)); } } encodedList.WriteTo(stream); }
static void WriteList(object value, Type type, Stream stream) { var encodedList = new KRPC.Schema.KRPC.List(); var list = (IList)value; var valueType = type.GetGenericArguments().Single(); using (var internalBuffer = new MemoryStream()) { var internalStream = new CodedOutputStream(internalBuffer); foreach (var item in list) { encodedList.Items.Add(EncodeObject(item, valueType, internalBuffer, internalStream)); } } encodedList.WriteTo(stream); }
static void WriteList (object value, Type type, Stream stream) { var encodedList = new KRPC.Schema.KRPC.List (); var list = (IList)value; var valueType = type.GetGenericArguments ().Single (); using (var internalBuffer = new MemoryStream ()) { var internalStream = new CodedOutputStream (internalBuffer); foreach (var item in list) encodedList.Items.Add (EncodeObject (item, valueType, internalBuffer, internalStream)); } encodedList.WriteTo (stream); }
static void WriteList (object value, CodedOutputStream stream) { var encodedList = new KRPC.Schema.KRPC.List (); var list = (IList)value; using (var internalBuffer = new MemoryStream ()) { var internalStream = new CodedOutputStream (internalBuffer); foreach (var item in list) encodedList.Items.Add (EncodeObject (item, internalBuffer, internalStream)); } encodedList.WriteTo (stream); }