コード例 #1
0
        public MetadataConfig GetEndpointConfig(string contentType)
        {
            contentType = contentType.ToLowerSafe();
            switch (contentType)
            {
            case MimeTypes.Soap11:
                return(this.Soap11);

            case MimeTypes.Soap12:
                return(this.Soap12);

            case MimeTypes.Xml:
                return(this.Xml);

            case MimeTypes.Json:
                return(this.Json);

            case MimeTypes.Jsv:
                return(this.Jsv);
            }

            var format = ContentFormat.GetContentFormat(contentType);

            return(Custom.Create(format));
        }
コード例 #2
0
        public void Register(string contentType, StreamSerializerDelegate streamSerializer, StreamDeserializerDelegate streamDeserializer)
        {
            if (contentType.IsNullOrEmpty())
            {
                throw new ArgumentNullException(nameof(contentType));
            }

            var format = ContentFormat.GetContentFormat(contentType);

            var normalizedContentType = ContentFormat.NormalizeContentType(contentType);

            ContentTypeFormats[format] = normalizedContentType;

            SetContentTypeSerializer(normalizedContentType, streamSerializer);
            SetContentTypeDeserializer(normalizedContentType, streamDeserializer);
        }
コード例 #3
0
ファイル: ContentTypes.cs プロジェクト: akrisiun/Gistlyn
        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;

            if (streamSerializer != null)
            {
                ContentTypeSerializersAsync[normalizedContentType] = streamSerializer;
            }

            if (streamDeserializer != null)
            {
                ContentTypeDeserializersAsync[normalizedContentType] = streamDeserializer;
            }
        }