Пример #1
0
        public override void Serialize(HessianOutput output, object map, string customTypeName)
        {
            var typeName = customTypeName ?? _type.FullName;
            var defIdx   = output.WriteMapDefinition(typeName, _fieldNames);

            if (defIdx < 0)
            {
                output.WriteMapStart(typeName);
                for (int i = 0; i < _fields.Length; i++)
                {
                    output.WriteString(_fieldNames[i]);
                    _fieldSerializers[i].WriteField(output, map);
                }
                output.WriteMapEnd();
            }
            else
            {
                output.WriteMapStart(defIdx);

                for (int i = 0; i < _fields.Length; i++)
                {
                    _fieldSerializers[i].WriteField(output, map);
                }
            }
        }
Пример #2
0
        public override void Serialize(HessianOutput output, object map, string customTypeName)
        {
            var typeName = customTypeName ?? _type.FullName;

            output.WriteMapStart(typeName);

            // entries
            foreach (var fieldInfo in _fields)
            {
                output.WriteString(fieldInfo.Name);
                output.WriteObject(fieldInfo.GetValue(map));
            }

            output.WriteMapEnd();
        }
Пример #3
0
        public override void Serialize(HessianOutput output, object map, string customTypeName)
        {
            var dict     = (IDictionary)map;
            var typeName = customTypeName;

            output.WriteMapStart(typeName);

            foreach (var key in dict.Keys)
            {
                output.WriteObject(key);
                output.WriteObject(dict[key]);
            }

            output.WriteMapEnd();
        }
Пример #4
0
        public override void Serialize(HessianOutput output, object map, string customTypeName)
        {
            var typeName = customTypeName ?? _type.FullName;
            var value    = Enum.GetName(_type, map);

            var defIdx = output.WriteMapDefinition(typeName, _fieldNames);

            if (defIdx < 0)
            {
                output.WriteMapStart(typeName);
                output.WriteString("name");
                output.WriteString(value);
                output.WriteMapEnd();
            }
            else
            {
                output.WriteMapStart(defIdx);
                output.WriteString(value);
            }
        }