private static ByteString EncodeDictionary(object value, Type type) { var keyType = type.GetGenericArguments() [0]; var valueType = type.GetGenericArguments() [1]; var encodedDictionary = new KRPC.Schema.KRPC.Dictionary(); foreach (System.Collections.DictionaryEntry entry in (System.Collections.IDictionary)value) { var encodedEntry = new KRPC.Schema.KRPC.DictionaryEntry(); encodedEntry.Key = Encode(entry.Key, keyType); encodedEntry.Value = Encode(entry.Value, valueType); encodedDictionary.Entries.Add(encodedEntry); } return(Encode(encodedDictionary, typeof(KRPC.Schema.KRPC.Dictionary))); }
static void WriteDictionary(object value, CodedOutputStream stream) { var encodedDictionary = new KRPC.Schema.KRPC.Dictionary(); using (var internalBuffer = new MemoryStream()) { var internalStream = new CodedOutputStream(internalBuffer); foreach (DictionaryEntry entry in (IDictionary)value) { var encodedEntry = new KRPC.Schema.KRPC.DictionaryEntry(); encodedEntry.Key = EncodeObject(entry.Key, internalBuffer, internalStream); encodedEntry.Value = EncodeObject(entry.Value, internalBuffer, internalStream); encodedDictionary.Entries.Add(encodedEntry); } } encodedDictionary.WriteTo(stream); }
static void WriteDictionary(object value, Type type, Stream stream) { var keyType = type.GetGenericArguments() [0]; var valueType = type.GetGenericArguments() [1]; var encodedDictionary = new KRPC.Schema.KRPC.Dictionary(); using (var internalBuffer = new MemoryStream()) { var internalStream = new CodedOutputStream(internalBuffer); foreach (DictionaryEntry entry in (IDictionary)value) { var encodedEntry = new KRPC.Schema.KRPC.DictionaryEntry(); encodedEntry.Key = EncodeObject(entry.Key, keyType, internalBuffer, internalStream); encodedEntry.Value = EncodeObject(entry.Value, valueType, internalBuffer, internalStream); encodedDictionary.Entries.Add(encodedEntry); } } encodedDictionary.WriteTo(stream); }
static void WriteDictionary (object value, Type type, Stream stream) { var keyType = type.GetGenericArguments () [0]; var valueType = type.GetGenericArguments () [1]; var encodedDictionary = new KRPC.Schema.KRPC.Dictionary (); using (var internalBuffer = new MemoryStream ()) { var internalStream = new CodedOutputStream (internalBuffer); foreach (DictionaryEntry entry in (IDictionary) value) { var encodedEntry = new KRPC.Schema.KRPC.DictionaryEntry (); encodedEntry.Key = EncodeObject (entry.Key, keyType, internalBuffer, internalStream); encodedEntry.Value = EncodeObject (entry.Value, valueType, internalBuffer, internalStream); encodedDictionary.Entries.Add (encodedEntry); } } encodedDictionary.WriteTo (stream); }
private static ByteString EncodeDictionary(object value, Type type) { var keyType = type.GetGenericArguments () [0]; var valueType = type.GetGenericArguments () [1]; var encodedDictionary = new KRPC.Schema.KRPC.Dictionary (); foreach (System.Collections.DictionaryEntry entry in (System.Collections.IDictionary) value) { var encodedEntry = new KRPC.Schema.KRPC.DictionaryEntry (); encodedEntry.Key = Encode (entry.Key, keyType); encodedEntry.Value = Encode (entry.Value, valueType); encodedDictionary.Entries.Add (encodedEntry); } return Encode (encodedDictionary, typeof(KRPC.Schema.KRPC.Dictionary)); }
static void WriteDictionary (object value, CodedOutputStream stream) { var encodedDictionary = new KRPC.Schema.KRPC.Dictionary (); using (var internalBuffer = new MemoryStream ()) { var internalStream = new CodedOutputStream (internalBuffer); foreach (DictionaryEntry entry in (IDictionary) value) { var encodedEntry = new KRPC.Schema.KRPC.DictionaryEntry (); encodedEntry.Key = EncodeObject (entry.Key, internalBuffer, internalStream); encodedEntry.Value = EncodeObject (entry.Value, internalBuffer, internalStream); encodedDictionary.Entries.Add (encodedEntry); } } encodedDictionary.WriteTo (stream); }