示例#1
0
        public byte[] Serialize <T>(T obj, string?mimeType = null)
        {
            var activity = MessageDiagnostics.StartMessageSerialize();

            var serializer = GetSerializer(mimeType);
            var result     = serializer.Serialize(obj);

            MessageDiagnostics.StopMessageSerialize(activity);

            return(result);
        }
示例#2
0
        public List <byte[]> SerializeBatch <T>(IEnumerable <T> enumerable, string?mimeType = null)
        {
            var activity = MessageDiagnostics.StartMessageSerialize();

            var serializer = GetSerializer(mimeType);
            var list       = new List <byte[]>();

            foreach (var item in enumerable)
            {
                list.Add(serializer.Serialize(item));
            }

            MessageDiagnostics.StopMessageSerialize(activity);

            return(list);
        }