public override bool CanWriteType(Type type) { if (null == type) { throw new ArgumentNullException(nameof(type)); } bool result = SchematizedMediaTypeFormatter.CanProcessType(type); return(result); }
private async Task <object> ReadFromStream(Type type, Stream readStream, HttpContent content) { if (null == type) { throw new ArgumentNullException(nameof(type)); } if (null == readStream) { throw new ArgumentNullException(nameof(readStream)); } if ( !typeof(IDictionary <string, object>).IsAssignableFrom(type) && !typeof(Schematized).IsAssignableFrom(type) && typeof(string) != type ) { throw new NotSupportedException(type.FullName); } string characters = await SchematizedMediaTypeFormatter.ReadFromStream(readStream).ConfigureAwait(false); string information = string.Concat(SystemForCrossDomainIdentityManagementServiceResources.InformationRead, characters); IInformationNotification notification = InformationNotificationFactory.Instance.CreateNotification( information, null, ServiceNotificationIdentifiers.SchematizedMediaTypeFormatterReadFromStream); this.Monitor.Inform(notification); if ( string.Equals( content?.Headers?.ContentType?.MediaType, MediaTypes.JavaWebToken, StringComparison.Ordinal) ) { return(characters); } Dictionary <string, object> json = JsonFactory.Instance.Create( characters, this.DeserializingFactory.AcceptLargeObjects); if (typeof(IDictionary <string, object>).IsAssignableFrom(type)) { return(json); } try { Schematized result = this.DeserializingFactory.Create(json); return(result); } catch (ArgumentException) { return(new HttpResponseException(HttpStatusCode.BadRequest)); } catch (NotSupportedException) { return(new HttpResponseException(HttpStatusCode.BadRequest)); } #pragma warning disable CA1031 // Do not catch general exception types catch { return(new HttpResponseException(HttpStatusCode.BadRequest)); } #pragma warning restore CA1031 // Do not catch general exception types }