/FireEngine.Net/Bson/Serialization/IBsonSerializable.cs

https://code.google.com/ · C# · 57 lines · 13 code · 3 blank · 41 comment · 0 complexity · c0f571aa69db47e2945b0a1c7e6aed5b MD5 · raw file

  1. /* Copyright 2010-2011 10gen 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 System.Collections.Generic;
  17. using System.Linq;
  18. using System.Text;
  19. using MongoDB.Bson.IO;
  20. namespace MongoDB.Bson.Serialization {
  21. /// <summary>
  22. /// An interface implemented by classes that handle their own BSON serialization.
  23. /// </summary>
  24. public interface IBsonSerializable {
  25. /// <summary>
  26. /// Deserializes this object from a BsonReader.
  27. /// </summary>
  28. /// <param name="bsonReader">The BsonReader.</param>
  29. /// <param name="nominalType">The nominal type of the object.</param>
  30. /// <param name="options">The serialization options.</param>
  31. /// <returns>Normally itself, though sometimes an instance of a subclass or null.</returns>
  32. object Deserialize(BsonReader bsonReader, Type nominalType, IBsonSerializationOptions options);
  33. /// <summary>
  34. /// Gets the document Id.
  35. /// </summary>
  36. /// <param name="id">The Id.</param>
  37. /// <param name="idNominalType">The nominal type of the Id.</param>
  38. /// <param name="idGenerator">The IdGenerator for the Id type.</param>
  39. /// <returns>True if the document has an Id.</returns>
  40. bool GetDocumentId(out object id, out Type idNominalType, out IIdGenerator idGenerator);
  41. /// <summary>
  42. /// Serializes this object to a BsonWriter.
  43. /// </summary>
  44. /// <param name="bsonWriter">The BsonWriter.</param>
  45. /// <param name="nominalType">The nominal type of this object.</param>
  46. /// <param name="options">The serialization options.</param>
  47. void Serialize(BsonWriter bsonWriter, Type nominalType, IBsonSerializationOptions options);
  48. /// <summary>
  49. /// Sets the document Id.
  50. /// </summary>
  51. /// <param name="id">The Id.</param>
  52. void SetDocumentId(object id);
  53. }
  54. }