Beispiel #1
0
            public JsonErrorHandler(ServiceEndpoint endpoint, bool includeExceptionDetailInFaults)
            {
                WebMessageEncodingBindingElement webMEBE = endpoint.Binding.CreateBindingElements().Find <WebMessageEncodingBindingElement>();

                outgoingContentType = JsonMessageEncoderFactory.GetContentType(webMEBE);
                this.includeExceptionDetailInFaults = includeExceptionDetailInFaults;
            }
Beispiel #2
0
        public static List <BsonDocument> TranslateMessagesToBsonDocuments(IEnumerable <MongoDBMessage> requests)
        {
            var docs = new List <BsonDocument>();

            foreach (var request in requests)
            {
                using (var stringWriter = new StringWriter())
                {
                    var encoderFactory = new JsonMessageEncoderFactory(stringWriter, null);

                    request.GetEncoder(encoderFactory).WriteMessage(request);
                    docs.Add(BsonDocument.Parse(stringWriter.GetStringBuilder().ToString()));
                }
            }
            return(docs);
        }
 public void GetDeleteMessageEncoder_should_return_a_DeleteMessageJsonEncoder()
 {
     using (var textWriter = new StringWriter())
     {
         var encoderFactory = new JsonMessageEncoderFactory(null, textWriter, __messageEncoderSettings);
         var encoder = encoderFactory.GetDeleteMessageEncoder();
         encoder.Should().BeOfType<DeleteMessageJsonEncoder>();
     }
 }
 public void GetReplyMessageEncoder_should_return_a_ReplyMessageJsonEncoder()
 {
     using (var textReader = new StringReader(""))
     {
         var encoderFactory = new JsonMessageEncoderFactory(textReader, null, __messageEncoderSettings);
         var encoder = encoderFactory.GetReplyMessageEncoder<BsonDocument>(BsonDocumentSerializer.Instance);
         encoder.Should().BeOfType<ReplyMessageJsonEncoder<BsonDocument>>();
     }
 }
 public void GetInsertMessageEncoder_should_return_a_InsertMessageJsonEncoder()
 {
     using (var textWriter = new StringWriter())
     {
         var encoderFactory = new JsonMessageEncoderFactory(null, textWriter, __messageEncoderSettings);
         var encoder = encoderFactory.GetInsertMessageEncoder<BsonDocument>(BsonDocumentSerializer.Instance);
         encoder.Should().BeOfType<InsertMessageJsonEncoder<BsonDocument>>();
     }
 }
 public void GetDeleteMessageEncoder_should_return_a_DeleteMessageJsonEncoder()
 {
     using (var stringWriter = new StringWriter())
     using (var jsonWriter = new JsonWriter(stringWriter))
     {
         var encoderFactory = new JsonMessageEncoderFactory(null, jsonWriter);
         var encoder = encoderFactory.GetDeleteMessageEncoder();
         encoder.Should().BeOfType<DeleteMessageJsonEncoder>();
     }
 }
 public void GetReplyMessageEncoder_should_return_a_ReplyMessageJsonEncoder()
 {
     using (var stringWriter = new StringWriter())
     using (var jsonWriter = new JsonWriter(stringWriter))
     {
         var encoderFactory = new JsonMessageEncoderFactory(null, jsonWriter);
         var encoder = encoderFactory.GetReplyMessageEncoder<BsonDocument>(BsonDocumentSerializer.Instance);
         encoder.Should().BeOfType<ReplyMessageJsonEncoder<BsonDocument>>();
     }
 }