public bool CanWriteResult(OutputFormatterCanWriteContext context) { if (typeof(ResourceResult).GetTypeInfo().IsAssignableFrom(context.ObjectType.GetTypeInfo())) return true; return false; }
/// <inheritdoc /> public bool CanWriteResult(OutputFormatterCanWriteContext context) { // ignore the contentType and just look at the content. // This formatter will be selected if the content is null. // We check for Task as a user can directly create an ObjectContentResult with the unwrapped type. if (context.ObjectType == typeof(void) || context.ObjectType == typeof(Task)) { return true; } return TreatNullValueAsNoContent && context.Object == null; }
public override bool CanWriteResult(OutputFormatterCanWriteContext context) { if (base.CanWriteResult(context)) { var actionReturnString = context.Object as string; if (actionReturnString != null) { return true; } } return false; }
/// <inheritdoc /> public bool CanWriteResult(OutputFormatterCanWriteContext context) { // ignore the contentType and just look at the content. // This formatter will be selected if the content is null. // We check for Task as a user can directly create an ObjectContentResult with the unwrapped type. if (context.ObjectType == typeof(void) || context.ObjectType == typeof(Task)) { return(true); } return(TreatNullValueAsNoContent && context.Object == null); }
/// <inheritdoc /> public bool CanWriteResult(OutputFormatterCanWriteContext context) { if (context == null) { throw new ArgumentNullException(nameof(context)); } // Ignore the passed in content type, if the object is a Stream. if (context.Object is Stream) { return true; } return false; }
/// <inheritdoc /> public bool CanWriteResult(OutputFormatterCanWriteContext context) { if (context == null) { throw new ArgumentNullException(nameof(context)); } // Ignore the passed in content type, if the object is a Stream. if (context.Object is Stream) { return(true); } return(false); }
public override bool CanWriteResult(OutputFormatterCanWriteContext context) { if (base.CanWriteResult(context)) { if (context.Object is Product) { return true; } if (context.Object is string) { return true; } } return false; }
public override bool CanWriteResult(OutputFormatterCanWriteContext context) { if (context == null) { throw new ArgumentNullException(nameof(context)); } // Ignore the passed in content type, if the object is string // always return it as a text/plain format. if (context.ObjectType == typeof(string) || context.Object is string) { context.ContentType = SupportedMediaTypes[0]; return(true); } return(false); }
public override bool CanWriteResult(OutputFormatterCanWriteContext context) { if (context == null) { throw new ArgumentNullException(nameof(context)); } // Ignore the passed in content type, if the object is string // always return it as a text/plain format. if (context.ObjectType == typeof(string) || context.Object is string) { context.ContentType = SupportedMediaTypes[0]; return true; } return false; }
/// <inheritdoc /> public virtual bool CanWriteResult(OutputFormatterCanWriteContext context) { if (context == null) { throw new ArgumentNullException(nameof(context)); } if (!CanWriteType(context.ObjectType)) { return(false); } if (context.ContentType == null) { // If the desired content type is set to null, then the current formatter can write anything // it wants. if (SupportedMediaTypes.Count > 0) { context.ContentType = SupportedMediaTypes[0]; return(true); } else { return(false); } } else { // Confirm this formatter supports a more specific media type than requested e.g. OK if "text/*" // requested and formatter supports "text/plain". contentType is typically what we got in an Accept // header. for (var i = 0; i < SupportedMediaTypes.Count; i++) { var mediaType = SupportedMediaTypes[i]; if (mediaType.IsSubsetOf(context.ContentType)) { context.ContentType = mediaType; return(true); } } } return(false); }
public override bool CanWriteResult(OutputFormatterCanWriteContext context) { return context.ObjectType == typeof(QuerySummary); }
public virtual bool CanWriteResult(OutputFormatterCanWriteContext context) { return false; }
/// <inheritdoc /> public virtual bool CanWriteResult(OutputFormatterCanWriteContext context) { if (context == null) { throw new ArgumentNullException(nameof(context)); } if (!CanWriteType(context.ObjectType)) { return false; } if (context.ContentType == null) { // If the desired content type is set to null, then the current formatter can write anything // it wants. if (SupportedMediaTypes.Count > 0) { context.ContentType = SupportedMediaTypes[0]; return true; } else { return false; } } else { // Confirm this formatter supports a more specific media type than requested e.g. OK if "text/*" // requested and formatter supports "text/plain". contentType is typically what we got in an Accept // header. for (var i = 0; i < SupportedMediaTypes.Count; i++) { var mediaType = SupportedMediaTypes[i]; if (mediaType.IsSubsetOf(context.ContentType)) { context.ContentType = mediaType; return true; } } } return false; }
public override bool CanWriteResult(OutputFormatterCanWriteContext context) { // Do not set the selected media Type. // The WriteResponseHeaders should do it for you. return(true); }
/// <inheritdoc /> public bool CanWriteResult(OutputFormatterCanWriteContext context) { return(context.FailedContentNegotiation ?? false); }
public bool CanWriteResult(OutputFormatterCanWriteContext context) { return true; }
public bool CanWriteResult(OutputFormatterCanWriteContext context) { return context.Object is HttpResponseMessage; }
public override bool CanWriteResult(OutputFormatterCanWriteContext context) { // Do not set the selected media Type. // The WriteResponseHeaders should do it for you. return true; }
/// <inheritdoc /> public bool CanWriteResult(OutputFormatterCanWriteContext context) { return context.FailedContentNegotiation ?? false; }