WriteNameValueSeparator() public method

public WriteNameValueSeparator ( ) : void
return void
コード例 #1
0
        private void WriteIDictionaryOfStringToObject(JsonWriter writer, object instance, IJsonSerializeOperationInfo info)
        {
            writer.WriteOpenObject();

            var dictionary = (IDictionary <string, object>)instance;

            var first = true;

            foreach (var item in dictionary)
            {
                if (first)
                {
                    first = false;
                }
                else
                {
                    writer.WriteItemSeparator();
                }

                writer.WriteValue(item.Key);
                writer.WriteNameValueSeparator();
                _valueSerializer.SerializeObject(writer, item.Value, info);
            }

            writer.WriteCloseObject();
        }
コード例 #2
0
        private void WriteIDictionaryOfStringToAnything(JsonWriter writer, object instance, IJsonSerializeOperationInfo info)
        {
            writer.WriteOpenObject();

            var dictionary = (IEnumerable)instance;

            var first = true;

            Func <object, object> getKeyFunc   = null;
            Func <object, object> getValueFunc = null;

            foreach (var item in dictionary)
            {
                if (first)
                {
                    first = false;
                    var itemType = item.GetType();
                    getKeyFunc   = _getKeyFuncCache.GetOrAdd(itemType, GetGetKeyFunc);
                    getValueFunc = _getValueFuncCache.GetOrAdd(itemType, GetGetValueFunc);
                }
                else
                {
                    writer.WriteItemSeparator();
                }

                writer.WriteValue((string)getKeyFunc(item));
                writer.WriteNameValueSeparator();
                _valueSerializer.SerializeObject(writer, getValueFunc(item), info);
            }

            writer.WriteCloseObject();
        }
コード例 #3
0
            public void SerializeObject(JsonWriter writer, object instance, IJsonSerializeOperationInfo info)
            {
                var jsonObject = (JsonObject)instance;

                writer.WriteOpenObject();

                var first = true;

                foreach (var item in jsonObject)
                {
                    if (first)
                    {
                        first = false;
                    }
                    else
                    {
                        writer.WriteItemSeparator();
                    }

                    writer.WriteValue(item.Key);
                    writer.WriteNameValueSeparator();
                    _dynamicJsonSerializer.SerializeObject(writer, item.Value, info);
                }

                writer.WriteCloseObject();
            }
コード例 #4
0
        public void WriteValue(JsonWriter writer, object instance, IJsonSerializeOperationInfo info)
        {
            var value = _getValue(instance);

            writer.WriteValue(Name);
            writer.WriteNameValueSeparator();
            _serializer.Value.SerializeObject(writer, value, info);
        }
コード例 #5
0
        private void WriteIDictionaryOfAnythingToAnything(JsonWriter writer, object instance, IJsonSerializeOperationInfo info)
        {
            writer.WriteOpenObject();

            var dictionary = (IEnumerable)instance;

            var first = true;

            Func <object, object> getKeyFunc   = null;
            Func <object, object> getValueFunc = null;

            foreach (var item in dictionary)
            {
                if (first)
                {
                    first = false;
                    var itemType = item.GetType();
                    getKeyFunc   = _getKeyFuncCache.GetOrAdd(itemType, GetGetKeyFunc);
                    getValueFunc = _getValueFuncCache.GetOrAdd(itemType, GetGetValueFunc);
                }
                else
                {
                    writer.WriteItemSeparator();
                }

                var key = getKeyFunc(item);

                var keyString = key as string;
                if (keyString != null)
                {
                    writer.WriteValue(keyString);
                }
                else
                {
                    var sb = new StringBuilder();

                    using (var stringWriter = new StringWriterWithEncoding(sb, Encoding.UTF8))
                    {
                        using (var keyWriter = new JsonWriter(stringWriter, info))
                        {
                            _keySerializer.SerializeObject(keyWriter, key, info);
                        }
                    }

                    writer.WriteValue((sb.ToString()));
                }

                writer.WriteNameValueSeparator();
                _valueSerializer.SerializeObject(writer, getValueFunc(item), info);
            }

            writer.WriteCloseObject();
        }
コード例 #6
0
            public void SerializeObject(JsonWriter writer, object instance, IJsonSerializeOperationInfo info)
            {
                var jsonObject = (JsonObject)instance;

                writer.WriteOpenObject();

                var first = true;

                foreach (var item in jsonObject)
                {
                    if (first)
                    {
                        first = false;
                    }
                    else
                    {
                        writer.WriteItemSeparator();
                    }

                    writer.WriteValue(item.Key);
                    writer.WriteNameValueSeparator();
                    _dynamicJsonSerializer.SerializeObject(writer, item.Value, info);
                }

                writer.WriteCloseObject();
            }
コード例 #7
0
 public void WriteValue(JsonWriter writer, object instance, IJsonSerializeOperationInfo info)
 {
     var value = _getValue(instance);
     writer.WriteValue(Name);
     writer.WriteNameValueSeparator();
     _serializer.Value.SerializeObject(writer, value, info);
 }
コード例 #8
0
        private void WriteIDictionaryOfAnythingToAnything(JsonWriter writer, object instance, IJsonSerializeOperationInfo info)
        {
            writer.WriteOpenObject();

            var dictionary = (IEnumerable)instance;

            var first = true;

            Func<object, object> getKeyFunc = null;
            Func<object, object> getValueFunc = null;

            foreach (var item in dictionary)
            {
                if (first)
                {
                    first = false;
                    var itemType = item.GetType();
                    getKeyFunc = _getKeyFuncCache.GetOrAdd(itemType, GetGetKeyFunc);
                    getValueFunc = _getValueFuncCache.GetOrAdd(itemType, GetGetValueFunc);
                }
                else
                {
                    writer.WriteItemSeparator();
                }

                var key = getKeyFunc(item);

                var keyString = key as string;
                if (keyString != null)
                {
                    writer.WriteValue(keyString);
                }
                else
                {
                    var sb = new StringBuilder();

                    using (var stringWriter = new StringWriterWithEncoding(sb, Encoding.UTF8))
                    {
                        using (var keyWriter = new JsonWriter(stringWriter, info))
                        {
                            _keySerializer.SerializeObject(keyWriter, key, info);
                        }
                    }

                    writer.WriteValue((sb.ToString()));
                }

                writer.WriteNameValueSeparator();
                _valueSerializer.SerializeObject(writer, getValueFunc(item), info);
            }

            writer.WriteCloseObject();
        }
コード例 #9
0
        private void WriteIDictionaryOfStringToAnything(JsonWriter writer, object instance, IJsonSerializeOperationInfo info)
        {
            writer.WriteOpenObject();

            var dictionary = (IEnumerable)instance;

            var first = true;

            Func<object, object> getKeyFunc = null;
            Func<object, object> getValueFunc = null;

            foreach (var item in dictionary)
            {
                if (first)
                {
                    first = false;
                    var itemType = item.GetType();
                    getKeyFunc = _getKeyFuncCache.GetOrAdd(itemType, GetGetKeyFunc);
                    getValueFunc = _getValueFuncCache.GetOrAdd(itemType, GetGetValueFunc);
                }
                else
                {
                    writer.WriteItemSeparator();
                }

                writer.WriteValue((string)getKeyFunc(item));
                writer.WriteNameValueSeparator();
                _valueSerializer.SerializeObject(writer, getValueFunc(item), info);
            }

            writer.WriteCloseObject();
        }
コード例 #10
0
        private void WriteIDictionaryOfStringToObject(JsonWriter writer, object instance, IJsonSerializeOperationInfo info)
        {
            writer.WriteOpenObject();

            var dictionary = (IDictionary<string, object>)instance;

            var first = true;

            foreach (var item in dictionary)
            {
                if (first)
                {
                    first = false;
                }
                else
                {
                    writer.WriteItemSeparator();
                }

                writer.WriteValue(item.Key);
                writer.WriteNameValueSeparator();
                _valueSerializer.SerializeObject(writer, item.Value, info);
            }

            writer.WriteCloseObject();
        }