Exemple #1
0
        private Representation HandleIterable(System.Collections.IEnumerable data)
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.util.List<Representation> results = new java.util.ArrayList<>();
            IList <Representation> results = new List <Representation>();

            foreach (Object value in data)
            {
                Representation rep = GetRepresentation(value);
                results.Add(rep);
            }

            RepresentationType representationType = GetType(results);

            return(new ListRepresentation(representationType, results));
        }
Exemple #2
0
 public static object Serialize(Representation repr)
 {
     if (repr is ValueRepresentation)
     {
         return(Serialize(( ValueRepresentation )repr));
     }
     else if (repr is MappingRepresentation)
     {
         return(Serialize(( MappingRepresentation )repr));
     }
     else if (repr is ListRepresentation)
     {
         return(Serialize(( ListRepresentation )repr));
     }
     else
     {
         throw new System.ArgumentException(repr.GetType().ToString());
     }
 }
Exemple #3
0
 public Response Response(Response.StatusType status, Representation representation)
 {
     return(Response(Response.status(status), representation));
 }
Exemple #4
0
 public virtual string Assemble(Representation representation)
 {
     return(representation.Serialize(_format, _baseUri, _extensions));
 }
Exemple #5
0
 public static void Write(Representation representation, RepresentationFormat format, URI baseUri)
 {
     representation.Serialize(format, baseUri, null);
 }
Exemple #6
0
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected:
//ORIGINAL LINE: private javax.ws.rs.core.Response.ResponseBuilder formatRepresentation(javax.ws.rs.core.Response.ResponseBuilder response, final Representation representation)
        private Response.ResponseBuilder FormatRepresentation(Response.ResponseBuilder response, Representation representation)
        {
            _representationWriteHandler.onRepresentationStartWriting();

            bool mustFail = representation is ExceptionRepresentation;

            if (_format is StreamingFormat)
            {
                return(response.entity(Stream(representation, ( StreamingFormat )_format, mustFail)));
            }
            else
            {
                return(response.entity(ToBytes(Assemble(representation), mustFail)));
            }
        }
Exemple #7
0
 protected internal virtual Response Response(Response.ResponseBuilder response, Representation representation)
 {
     return(FormatRepresentation(response, representation).type(HttpHeaderUtils.mediaTypeWithCharsetUtf8(MediaType)).build());
 }