示例#1
0
        public void RegisterAsync(string contentType,
                                  StreamSerializerDelegateAsync streamSerializer, StreamDeserializerDelegateAsync streamDeserializer)
        {
            if (contentType.IsNullOrEmpty())
            {
                throw new ArgumentNullException(nameof(contentType));
            }

            var parts  = contentType.Split('/');
            var format = parts[parts.Length - 1];

            this.ContentTypeFormats[format] = contentType;

            this.ContentTypeSerializersAsync[contentType]   = streamSerializer;
            this.ContentTypeDeserializersAsync[contentType] = streamDeserializer;
        }
        public void RegisterAsync(string contentType, StreamSerializerDelegateAsync streamSerializer, StreamDeserializerDelegateAsync streamDeserializer)
        {
            if (contentType.IsNullOrEmpty())
            {
                throw new ArgumentNullException(nameof(contentType));
            }

            var format = ContentFormat.GetContentFormat(contentType);

            var normalizedContentType = ContentFormat.NormalizeContentType(contentType);

            ContentTypeFormats[format] = normalizedContentType;

            ContentTypeSerializersAsync[normalizedContentType]   = streamSerializer;
            ContentTypeDeserializersAsync[normalizedContentType] = streamDeserializer;
        }