Example #1
0
        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)));
        }
Example #2
0
        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);
        }
Example #3
0
        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);
        }
Example #4
0
 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);
 }
Example #5
0
 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));
 }
Example #6
0
 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);
 }