예제 #1
0
 private static Action<Stream> CreateErrorSerializer(ODataFormat responseFormat, HandleExceptionArgs args, Encoding encoding)
 {
     ErrorHandler handler = new ErrorHandler(args, encoding);
     if (responseFormat == ODataFormat.VerboseJson)
     {
         return new Action<Stream>(handler.SerializeJsonErrorToStream);
     }
     return new Action<Stream>(handler.SerializeXmlErrorToStream);
 }
예제 #2
0
 /// <summary>Creates a delegate that can serialize an error for the specified arguments.</summary>
 /// <param name="args">Arguments for the exception being handled.</param>
 /// <param name="encoding">Encoding to created over stream.</param>
 /// <returns>A delegate that can serialize an error for the specified arguments.</returns>
 private static Action<Stream> CreateErrorSerializer(HandleExceptionArgs args, Encoding encoding)
 {
     Debug.Assert(args != null, "args != null");
     Debug.Assert(encoding != null, "encoding != null");
     ErrorHandler handler = new ErrorHandler(args, encoding);
     if (WebUtil.CompareMimeType(args.ResponseContentType, XmlConstants.MimeApplicationJson))
     {
         return handler.SerializeJsonErrorToStream;
     }
     else
     {
         return handler.SerializeXmlErrorToStream;
     }
 }
예제 #3
0
 /// <summary>Serializes an error in XML format.</summary>
 /// <param name='args'>Arguments describing the error.</param>
 /// <param name='writer'>Writer to which error should be serialized.</param>
 internal static void SerializeXmlError(HandleExceptionArgs args, XmlWriter writer)
 {
     Debug.Assert(args != null, "args != null");
     Debug.Assert(writer != null, "writer != null");
     ErrorHandler serializer = new ErrorHandler(args, null);
     serializer.SerializeXmlError(writer);
 }