Skip to content

Commit 577d6da

Browse files
committed
content updates.
1 parent 3bc5fff commit 577d6da

File tree

16 files changed

+171
-57
lines changed

16 files changed

+171
-57
lines changed

Docs/reference/content/examples/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ draft = true
44
title = "Examples"
55
[menu.main]
66
weight = 90
7-
pre = "<i class='fa'></i>"
7+
pre = "<i class='fa fa-code'></i>"
88
+++
99

1010
## Examples

Docs/reference/content/getting_started/reading_and_writing.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,16 @@ var result = await collection.UpdateOneAsync(
6565

6666
This will generate a filter of `{ Name: "Tom" }` and an update specification of `{ $set: { Profession: "Musician" } }`. Only one document will get updated even if there is more than one person named "Tom" because we used [`UpdateOneAsync`]({{< apiref "M_MongoDB_Driver_IMongoCollection_1_UpdateOneAsync" >}}) instead of [`UpdateManyAsync`]({{< apiref "M_MongoDB_Driver_IMongoCollection_1_UpdateManyAsync" >}}). More information on updates is available in the [reference guide]({{< relref "reference\driver\crud\writing.md#update-and-replace" >}}).
6767

68-
Alternatively, if we want to replace a document completely, we can use the [`ReplaceOneAsync`]({{< apiref "M_MongoDB_Driver_IMongoCollection_1_ReplaceOneAsync" >}}) method. Assuming Tom's `Id` value is "550c4aa98e59471bddf68eef":
68+
Alternatively, if we want to replace a document completely, we can use the [`ReplaceOneAsync`]({{< apiref "M_MongoDB_Driver_IMongoCollection_1_ReplaceOneAsync" >}}) method. Assuming Tom's `Id` value is `550c4aa98e59471bddf68eef`:
6969

7070
```csharp
71-
var tom = await collection.Find(x => x.Id == ObjectId.Parse("550c4aa98e59471bddf68eef")).SingleAsync();
71+
var tom = await collection.Find(x => x.Id == ObjectId.Parse("550c4aa98e59471bddf68eef"))
72+
.SingleAsync();
73+
7274
tom.Name = "Thomas";
7375
tom.Age = 43;
7476
tom.Profession = "Hacker";
77+
7578
var result = await collection.ReplaceOneAsync(x => x.Id == tom.Id, tom);
7679
```
7780

Docs/reference/content/reference/bson/bson.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,12 @@ using (var writer = new JsonWriter(output))
9292

9393
[`JsonWriter`]({{< apiref "T_MongoDB_Bson_IO_JsonWriter" >}}) supports writing strict JSON as well as both flavors of [MongoDB Extended JSON]({{< docsref "reference/mongodb-extended-json/" >}}). This, and other things, can be customized with the [`JsonWriterSettings`]({{< apiref "T_MongoDB_Bson_IO_JsonWriterSettings" >}}) class.
9494

95-
For instance, to write in a format for the [MongoDB Shell](http://docs.mongodb.org/manual/administration/scripting/), you can set the [`OutputMode`]({{< apiref "M_MongoDB_Bson_IO_JsonWriterSettings_OutputMode" >}}) to `Shell` and also set the [`Version`]({{< apiref "M_MongoDB_Bson_IO_JsonWriterSettings_Version" >}}) to the desired shell version.
95+
For instance, to write in a format for the [MongoDB Shell](http://docs.mongodb.org/manual/administration/scripting/), you can set the [`OutputMode`]({{< apiref "P_MongoDB_Bson_IO_JsonWriterSettings_OutputMode" >}}) to `Shell` and also set the [`ShellVersion`]({{< apiref "P_MongoDB_Bson_IO_JsonWriterSettings_ShellVersion" >}}) to the desired shell version.
9696

9797
```csharp
9898
var settings = new JsonWriterSettings
9999
{
100100
OutputMode = JsonOutputMode.Shell,
101-
Version = new Version(3.0) // target the syntax of MongoDB 3.0
101+
ShellVersion = new Version(3.0) // target the syntax of MongoDB 3.0
102102
};
103103
```

Docs/reference/content/reference/bson/mapping/index.md

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ The .NET BSON library supports mapping these classes to and from BSON/JSON using
1919

2020
In a majority of cases, the driver will be able to automatically map your class for you. This will happen if you begin to use a class for which no [serializer]({{< relref "reference\bson\serialization.md#serializers" >}}) has yet been registered in the [serializer registry]({{< relref "reference\bson\serialization.md#serializer-registry" >}}).
2121

22-
You can choose to register the class map using the [`RegisterClassMap`]({{< apiref "M_MongoDB_Bson_Serialization_BsonClassMap_RegisterClassMap_1" >}}) method:
22+
You can choose to register the class map using the [`RegisterClassMap`]({{< apiref "M_MongoDB_Bson_Serialization_BsonClassMap_RegisterClassMap__1_1" >}}) method:
2323

2424
```csharp
2525
BsonClassMap.RegisterClassMap<MyClass>();
2626
```
2727

2828
{{% note %}}It is very important that the registration of class maps occur prior to them being needed. The best place to register them is at app startup prior to initializing a connection with MongoDB.{{% /note %}}
2929

30-
If you want to control the creation of the class map, you can provide your own initializatzion code in the form of a lambda expression:
30+
If you want to control the creation of the class map, you can provide your own initialization code in the form of a lambda expression:
3131

3232
```csharp
3333
BsonClassMap.RegisterClassMap<MyClass>(cm =>
@@ -37,11 +37,11 @@ BsonClassMap.RegisterClassMap<MyClass>(cm =>
3737
});
3838
```
3939

40-
When your lambda expression is executed, the `cm` (short for class map) parameter is passed an empty class map for you to fill in. In this example, two properties are added to the class map by calling the [`MapMember`]({{< apiref "M_MongoDB_Bson_Serialization_BsonClassMap_1_MapMember_1" >}}) method. The arguments to the method are themselves lambda expressions which identify the member of the class. The advantage of using a lambda expression instead of just a string parameter with the name of the property is that Intellisense and compile time checking ensure that you can’t misspell the name of the property.
40+
When your lambda expression is executed, the `cm` (short for class map) parameter is passed an empty class map for you to fill in. In this example, two properties are added to the class map by calling the [`MapMember`]({{< apiref "M_MongoDB_Bson_Serialization_BsonClassMap_1_MapMember__1" >}}) method. The arguments to the method are themselves lambda expressions which identify the member of the class. The advantage of using a lambda expression instead of just a string parameter with the name of the property is that Intellisense and compile time checking ensure that you can’t misspell the name of the property.
4141

4242
## AutoMap
4343

44-
It is also possible to use automapping and then override some of the results using the [`AutoMap`]({{< apiref "M_MongoDB_Bson_Serialization_BsonClassMap_1_AutoMap" >}}) method. This method should be called first in the lambda expression.
44+
It is also possible to use automapping and then override some of the results using the [`AutoMap`]({{< apiref "M_MongoDB_Bson_Serialization_BsonClassMap_AutoMap" >}}) method. This method should be called first in the lambda expression.
4545

4646
```csharp
4747
BsonClassMap.RegisterClassMap<MyClass>(cm =>
@@ -52,7 +52,7 @@ BsonClassMap.RegisterClassMap<MyClass>(cm =>
5252
});
5353
```
5454

55-
[`AutoMap`]({{< apiref "M_MongoDB_Bson_Serialization_BsonClassMap_1_AutoMap" >}}) uses conventions to map the class and its members. See the [convention documentation]({{< relref "reference\bson\mapping\conventions.md" >}}) for more information.
55+
[`AutoMap`]({{< apiref "M_MongoDB_Bson_Serialization_BsonClassMap_AutoMap" >}}) uses conventions to map the class and its members. See the [convention documentation]({{< relref "reference\bson\mapping\conventions.md" >}}) for more information.
5656

5757

5858
## Class Customization
@@ -87,7 +87,7 @@ BsonClassMap.RegisterClassMap<MyClass>(cm =>
8787

8888
### Supporting Extra Elements
8989

90-
You can design your class to be capable of handling any extra elements that might be found in a BSON document during deserialization. To do so, you must have a property of type [`BsonDocument`]({{< apiref "T_MongoDB_Bson_BsonDocument" >}}) (or [`IDictionary<string, object>`]({{< msdnref "" >}})) and you must identify that property as the one that should hold any extra elements that are found. By [convention]({{< relref "reference\bson\mapping\conventions.md" >}}), the member may be named "ExtraElements". For example:
90+
You can design your class to be capable of handling any extra elements that might be found in a BSON document during deserialization. To do so, you must have a property of type [`BsonDocument`]({{< apiref "T_MongoDB_Bson_BsonDocument" >}}) (or [`IDictionary<string, object>`]({{< msdnref "s4ys34ea" >}})) and you must identify that property as the one that should hold any extra elements that are found. By [convention]({{< relref "reference\bson\mapping\conventions.md" >}}), the member may be named `ExtraElements`. For example:
9191

9292
```csharp
9393
public MyClass
@@ -322,19 +322,19 @@ BsonClassMap.RegisterClassMap<MyClass>(cm =>
322322

323323
When you Insert a document, the driver checks to see if the `Id` member has been assigned a value and, if not, generates a new unique value for it. Since the `Id` member can be of any type, the driver requires the help of an [`IIdGenerator`]({{< apiref "T_MongoDB_Bson_Serialization_IIdGenerator" >}}) to check whether the `Id` has a value assigned to it and to generate a new value if necessary. The driver has the following Id generators built-in:
324324

325-
- [`ObjectIdGenerator`]({{ apiref "T_MongoDB_Bson_Serialization_IdGenerators_ObjectIdGenerator" >}})
326-
- [`StringObjectIdGenerator`]({{ apiref "T_MongoDB_Bson_Serialization_IdGenerators_StringObjectIdGenerator" >}})
327-
- [`GuidGenerator`]({{ apiref "T_MongoDB_Bson_Serialization_IdGenerators_GuidGenerator" >}})
328-
- [`CombGuidGenerator`]({{ apiref "T_MongoDB_Bson_Serialization_IdGenerators_CombGuidGenerator" >}})
329-
- [`NullIdChecker`]({{ apiref "T_MongoDB_Bson_Serialization_IdGenerators_NullIdChecker" >}})
330-
- [`ZeroIdChecker<T>`]({{ apiref "T_MongoDB_Bson_Serialization_IdGenerators_ZeroIdChecker_1" >}})
331-
- [`BsonObjectIdGenerator`]({{ apiref "T_MongoDB_Bson_Serialization_IdGenerators_BsonObjectIdGenerator" >}})
325+
- [`ObjectIdGenerator`]({{< apiref "T_MongoDB_Bson_Serialization_IdGenerators_ObjectIdGenerator" >}})
326+
- [`StringObjectIdGenerator`]({{< apiref "T_MongoDB_Bson_Serialization_IdGenerators_StringObjectIdGenerator" >}})
327+
- [`GuidGenerator`]({{< apiref "T_MongoDB_Bson_Serialization_IdGenerators_GuidGenerator" >}})
328+
- [`CombGuidGenerator`]({{< apiref "T_MongoDB_Bson_Serialization_IdGenerators_CombGuidGenerator" >}})
329+
- [`NullIdChecker`]({{< apiref "T_MongoDB_Bson_Serialization_IdGenerators_NullIdChecker" >}})
330+
- [`ZeroIdChecker<T>`]({{< apiref "T_MongoDB_Bson_Serialization_IdGenerators_ZeroIdChecker_1" >}})
331+
- [`BsonObjectIdGenerator`]({{< apiref "T_MongoDB_Bson_Serialization_IdGenerators_BsonObjectIdGenerator" >}})
332332

333333
Some of these Id generators are used automatically for commonly used `Id` types:
334334

335-
- [`GuidGenerator`]({{ apiref "T_MongoDB_Bson_Serialization_IdGenerators_GuidGenerator" >}}) is used for a [`Guid`]({{< msdnref "system.guid" >}})
336-
- [`ObjectIdGenerator`]({{ apiref "T_MongoDB_Bson_Serialization_IdGenerators_ObjectIdGenerator" >}}) is used for an [`ObjectId`]({{< apiref "T_MongoDB_Bson_ObjectId" >}})
337-
- [`StringObjectIdGenerator`]({{ apiref "T_MongoDB_Bson_Serialization_IdGenerators_StringObjectIdGenerator" >}}) is used for a [`string`]({{< msdnref "system.string" >}}) represented externally as [`ObjectId`]({{< apiref "T_MongoDB_Bson_ObjectId" >}})
335+
- [`GuidGenerator`]({{< apiref "T_MongoDB_Bson_Serialization_IdGenerators_GuidGenerator" >}}) is used for a [`Guid`]({{< msdnref "system.guid" >}})
336+
- [`ObjectIdGenerator`]({{< apiref "T_MongoDB_Bson_Serialization_IdGenerators_ObjectIdGenerator" >}}) is used for an [`ObjectId`]({{< apiref "T_MongoDB_Bson_ObjectId" >}})
337+
- [`StringObjectIdGenerator`]({{< apiref "T_MongoDB_Bson_Serialization_IdGenerators_StringObjectIdGenerator" >}}) is used for a [`string`]({{< msdnref "system.string" >}}) represented externally as [`ObjectId`]({{< apiref "T_MongoDB_Bson_ObjectId" >}})
338338

339339
To specify the Id generator via an attribute:
340340

@@ -356,7 +356,7 @@ BsonClassMap.RegisterClassMap<MyClass>(cm =>
356356
});
357357
```
358358

359-
You could also say that you want to use the [`CombGuidGenerator`]({{ apiref "T_MongoDB_Bson_Serialization_IdGenerators_CombGuidGenerator" >}}) for all Guids.
359+
You could also say that you want to use the [`CombGuidGenerator`]({{< apiref "T_MongoDB_Bson_Serialization_IdGenerators_CombGuidGenerator" >}}) for all Guids.
360360

361361
```csharp
362362
BsonSerializer.RegisterIdGenerator(
@@ -388,7 +388,7 @@ BsonClassMap.RegisterClassMap<MyClass>(cm =>
388388
});
389389
```
390390

391-
When using code, [`AutoMap`]({{< apiref "M_MongoDB_Bson_Serialization_BsonClassMap_1_AutoMap" >}}) will have initially added the property to the class map automatically. [`UnmapMember`]({{< apiref "M_MongoDB_Bson_Serialization_BsonClassMap_1_UnmapMember_1" >}}) will remove it.
391+
When using code, [`AutoMap`]({{< apiref "M_MongoDB_Bson_Serialization_BsonClassMap_AutoMap" >}}) will have initially added the property to the class map automatically. [`UnmapMember`]({{< apiref "M_MongoDB_Bson_Serialization_BsonClassMap_1_UnmapMember__1" >}}) will remove it.
392392

393393

394394
### Ignoring Default Values
@@ -448,7 +448,7 @@ public class MyClass
448448

449449
### Ignoring a Member at Runtime
450450

451-
Sometimes the decision whether to serialize a member or not is more complicated than just whether the value is `null` or equal to the default value. In these cases, you can write a method that determines whether a value should be serialized. Usually the method for member Xyz is named ShouldSerializeXyz. If you follow this naming convention then [`AutoMap`]({{< apiref "M_MongoDB_Bson_Serialization_BsonClassMap_1_AutoMap" >}}) will automatically detect the method and use it. For example:
451+
Sometimes the decision whether to serialize a member or not is more complicated than just whether the value is `null` or equal to the default value. In these cases, you can write a method that determines whether a value should be serialized. Usually the method for member Xyz is named ShouldSerializeXyz. If you follow this naming convention then [`AutoMap`]({{< apiref "M_MongoDB_Bson_Serialization_BsonClassMap_AutoMap" >}}) will automatically detect the method and use it. For example:
452452

453453
```csharp
454454
public class Employee
@@ -551,7 +551,7 @@ public class C
551551
}
552552
```
553553

554-
When done via code, a [`DictionaryInterfaceImplementerSerializer`]({{< apiref "T_MongoDB_Bson_Serialization_Serializers_DictionaryInterfaceImplementerSerializer" >}}) should be set:
554+
When done via code, a [`DictionaryInterfaceImplementerSerializer`]({{< apiref "T_MongoDB_Bson_Serialization_Serializers_DictionaryInterfaceImplementerSerializer_1" >}}) should be set:
555555

556556
```csharp
557557
BsonClassMap.RegisterClassMap<C>(cm =>
@@ -621,8 +621,8 @@ BsonClassMap.RegisterClassMap<Employee>(cm =>
621621

622622
It is possible to implement custom attributes to contribute to the serialization infrastructure. There are 3 interfaces you might want to implement:
623623

624-
- [`IBsonClassMapAttribute`]({{< apiref "T_MongoDB_Bson_Serialization_Attributes_IBsonClassMapAttribute" >}}) is used to contribute to a class map.
625-
- [`IBsonMemberMapAttribute`]({{< apiref "T_MongoDB_Bson_Serialization_Attributes_IBsonMemberMapAttribute" >}}) is used to contribute to a member map.
626-
- [`IBsonCreatorMapAttribute`]({{< apiref "T_MongoDB_Bson_Serialization_Attributes_IBsonCreatorMapAttribute" >}}) is used to contribute to a creator map.
624+
- [`IBsonClassMapAttribute`]({{< apiref "T_MongoDB_Bson_Serialization_IBsonClassMapAttribute" >}}) is used to contribute to a class map.
625+
- [`IBsonMemberMapAttribute`]({{< apiref "T_MongoDB_Bson_Serialization_IBsonMemberMapAttribute" >}}) is used to contribute to a member map.
626+
- [`IBsonCreatorMapAttribute`]({{< apiref "T_MongoDB_Bson_Serialization_IBsonCreatorMapAttribute" >}}) is used to contribute to a creator map.
627627

628628
All the provided attributes implement one or more of these interfaces, so they are good examples of how these interfaces function.

Docs/reference/content/reference/bson/serialization.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Serialization is the process of mapping an object to and from a BSON document. T
1616

1717
## Serializer Registry
1818

19-
The serializer registry contains all the [`IBsonSerializers`]({{< apiref "T_MongoDB_Bson_Serialization_IBsonSerializer" >}}) that have been registered. It can be accessed via the [`SerializerRegistry`]({{< apiref "P_MongoDB_Bson_BsonSerializer_SerializerRegistry" >}}) property of the static class [`BsonSerializer`]({{< apiref "MongoDB_Bson_BsonSerializer" >}}).
19+
The serializer registry contains all the [`IBsonSerializers`]({{< apiref "T_MongoDB_Bson_Serialization_IBsonSerializer" >}}) that have been registered. It can be accessed via the [`SerializerRegistry`]({{< apiref "P_MongoDB_Bson_Serialization_BsonSerializer_SerializerRegistry" >}}) property of the static class [`BsonSerializer`]({{< apiref "T_MongoDB_Bson_Serialization_BsonSerializer" >}}).
2020

2121
{{% note %}}This is a global registry. Currently, you cannot use multiple registries in a single application.{{% /note %}}
2222

@@ -28,7 +28,7 @@ The [serializer registry]({{< relref "#serializer-registry" >}}) is powered by a
2828

2929
### Implementation
3030

31-
To implement an [`IBsonSerializationProvider`]({{< apiref "T_MongoDB_Bson_Serialization_IBsonSerializationProvider" >}}), create a class that implements the interface and register it using the [`RegisterSerializationProvider`]({{< apiref "T_MongoDB_Bson_BsonSerializer_RegisterSerializationProvider" >}}) method.
31+
To implement an [`IBsonSerializationProvider`]({{< apiref "T_MongoDB_Bson_Serialization_IBsonSerializationProvider" >}}), create a class that implements the interface and register it using the [`RegisterSerializationProvider`]({{< apiref "M_MongoDB_Bson_Serialization_BsonSerializer_RegisterSerializationProvider" >}}) method.
3232

3333
```csharp
3434
class MyProvider : IBsonSerializationProvider
@@ -67,7 +67,7 @@ using (var reader = new JsonReader(jsonString))
6767

6868
{{% note class="warning" %}}Writing custom serializers to handle both normal cases and edge cases can be very tricky.{{% /note %}}
6969

70-
To implement a custom [`IBsonSerializer`]({{< apiref "T_MongoDB_Bson_Serialization_IBsonSerializer" >}}), it is best to inherit from [`SerializerBase<T>`]({{< apiref "T_MongoDB_Bson_Serialization_Serializers_SerializerBase_1" >}}) and override the [`Deserializer`]({{< apiref "M_MongoDB_Bson_Serialization_Serializers_SerializerBase_1_Deserialize" >}}) and [`Serialize`]({{< apiref "M_MongoDB_Bson_Serialization_Serializers_SerializerBase_1_Serialize" >}}) methods.
70+
To implement a custom [`IBsonSerializer`]({{< apiref "T_MongoDB_Bson_Serialization_IBsonSerializer" >}}), it is best to inherit from [`SerializerBase<T>`]({{< apiref "T_MongoDB_Bson_Serialization_Serializers_SerializerBase_1" >}}) and override the [`Deserialize`]({{< apiref "M_MongoDB_Bson_Serialization_Serializers_SerializerBase_1_Deserialize" >}}) and [`Serialize`]({{< apiref "M_MongoDB_Bson_Serialization_Serializers_SerializerBase_1_Serialize" >}}) methods.
7171

7272
For example, it implement a serializer that reads an [`Int32`]({{< msdnref "system.int32" >}}):
7373

@@ -122,7 +122,7 @@ Notice that we are testing the current BsonType while reading and making decisio
122122

123123
{{% note %}}The built-in [`Int32Serializer`]({{< apiref "T_MongoDB_Bson_Serialization_Serializers_Int32Serializer" >}}) accounts for this as well as other such items.{{% /note %}}
124124

125-
You can register your serializer using the [`RegisterSerializer`]({{< apiref "T_MongoDB_Bson_BsonSerializer_RegisterSerializer" >}}) or implement a [serialization provider]({{< relref "#serialization-provider" >}}).
125+
You can register your serializer using the [`RegisterSerializer`]({{< apiref "M_MongoDB_Bson_Serialization_BsonSerializer_RegisterSerializer" >}}) or implement a [serialization provider]({{< relref "#serialization-provider" >}}).
126126

127127

128128
### Opt-in Interfaces

0 commit comments

Comments
 (0)