IBsonSerializer.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /* Copyright 2010-2014 MongoDB Inc.
  2. *
  3. * Licensed under the Apache License, Version 2.0 (the "License");
  4. * you may not use this file except in compliance with the License.
  5. * You may obtain a copy of the License at
  6. *
  7. * http://www.apache.org/licenses/LICENSE-2.0
  8. *
  9. * Unless required by applicable law or agreed to in writing, software
  10. * distributed under the License is distributed on an "AS IS" BASIS,
  11. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. * See the License for the specific language governing permissions and
  13. * limitations under the License.
  14. */
  15. using System;
  16. using MongoDB.Bson.IO;
  17. namespace MongoDB.Bson.Serialization
  18. {
  19. /// <summary>
  20. /// An interface implemented by BSON serializers.
  21. /// </summary>
  22. public interface IBsonSerializer
  23. {
  24. /// <summary>
  25. /// Deserializes an object from a BsonReader.
  26. /// </summary>
  27. /// <param name="bsonReader">The BsonReader.</param>
  28. /// <param name="nominalType">The nominal type of the object.</param>
  29. /// <param name="options">The serialization options.</param>
  30. /// <returns>An object.</returns>
  31. object Deserialize(BsonReader bsonReader, Type nominalType, IBsonSerializationOptions options);
  32. /// <summary>
  33. /// Deserializes an object from a BsonReader.
  34. /// </summary>
  35. /// <param name="bsonReader">The BsonReader.</param>
  36. /// <param name="nominalType">The nominal type of the object.</param>
  37. /// <param name="actualType">The actual type of the object.</param>
  38. /// <param name="options">The serialization options.</param>
  39. /// <returns>An object.</returns>
  40. object Deserialize(BsonReader bsonReader, Type nominalType, Type actualType, IBsonSerializationOptions options);
  41. /// <summary>
  42. /// Gets the default serialization options for this serializer.
  43. /// </summary>
  44. /// <returns>The default serialization options for this serializer.</returns>
  45. IBsonSerializationOptions GetDefaultSerializationOptions();
  46. /// <summary>
  47. /// Serializes an object to a BsonWriter.
  48. /// </summary>
  49. /// <param name="bsonWriter">The BsonWriter.</param>
  50. /// <param name="nominalType">The nominal type.</param>
  51. /// <param name="value">The object.</param>
  52. /// <param name="options">The serialization options.</param>
  53. void Serialize(BsonWriter bsonWriter, Type nominalType, object value, IBsonSerializationOptions options);
  54. }
  55. }