コード例 #1
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 Object stream(final Representation representation, final StreamingFormat streamingFormat, final boolean mustFail)
        private object Stream(Representation representation, StreamingFormat streamingFormat, bool mustFail)
        {
            return(( StreamingOutput )output =>
            {
                RepresentationFormat outputStreamFormat = streamingFormat.WriteTo(output);
                try
                {
                    representation.Serialize(outputStreamFormat, _baseUri, _extensions);

                    if (!mustFail)
                    {
                        _representationWriteHandler.onRepresentationWritten();
                    }
                }
                catch (Exception e)
                {
                    if (e is NodeNotFoundException || e is RelationshipNotFoundException)
                    {
                        throw new WebApplicationException(NotFound(e));
                    }
                    if (e is BadInputException)
                    {
                        throw new WebApplicationException(BadRequest(e));
                    }
                    throw new WebApplicationException(e, ServerError(e));
                }
                finally
                {
                    _representationWriteHandler.onRepresentationFinal();
                }
            });
        }
コード例 #2
0
        internal override string Serialize(RepresentationFormat format, URI baseUri, ExtensionInjector extensions)
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final String result = format.serializeValue(type, value);
            string result = format.SerializeValue(Type, _value);

            format.Complete();
            return(result);
        }
コード例 #3
0
 private RepresentationFormat ForMediaTypes(IList <MediaType> acceptable)
 {
     foreach (MediaType type in acceptable)
     {
         RepresentationFormat format = _formats[type];
         if (format != null)
         {
             return(format);
         }
     }
     return(null);
 }
コード例 #4
0
        public OutputFormat OutputFormat(IList <MediaType> acceptable, URI baseUri, MultivaluedMap <string, string> requestHeaders)
        {
            RepresentationFormat format = ForHeaders(acceptable, requestHeaders);

            if (format == null)
            {
                format = ForMediaTypes(acceptable);
            }
            if (format == null)
            {
                format = UseDefault(acceptable);
            }
            return(new OutputFormat(format, baseUri, ExtensionManager));
        }
コード例 #5
0
        public InputFormat InputFormat(MediaType type)
        {
            if (type == null)
            {
                return(UseDefault());
            }

            RepresentationFormat format = _formats[type];

            if (format != null)
            {
                return(format);
            }

            format = _formats[new MediaType(type.Type, type.Subtype)];
            if (format != null)
            {
                return(format);
            }

            return(UseDefault(type));
        }
コード例 #6
0
 internal override string serialize(RepresentationFormat format, URI baseUri, ExtensionInjector extensions)
 {
     return(Serializer.JoinBaseWithRelativePath(baseUri, _path));
 }
コード例 #7
0
 public DefaultFormat(RepresentationFormat inner, ICollection <MediaType> supported, params MediaType[] requested) : base(MediaType.APPLICATION_JSON_TYPE)
 {
     this._inner     = inner;
     this._supported = supported;
     this._requested = requested;
 }
コード例 #8
0
 public OutputFormat(RepresentationFormat format, URI baseUri, ExtensionInjector extensions)
 {
     this._format     = format;
     this._baseUri    = baseUri;
     this._extensions = extensions;
 }
コード例 #9
0
 public static void Write(Representation representation, RepresentationFormat format, URI baseUri)
 {
     representation.Serialize(format, baseUri, null);
 }
コード例 #10
0
 public ParameterListAnonymousInnerClass(RepresentationFormat outerInstance, UnknownType readMap) : base(readMap)
 {
     this.outerInstance = outerInstance;
 }