Skip to content

Commit 22245c8

Browse files
rstamcraiggwilson
authored andcommitted
Moved all the BsonDocument wrappers to Legacy.
1 parent 3115667 commit 22245c8

39 files changed

+223
-89
lines changed

src/MongoDB.Driver.Legacy.Tests/MongoDB.Driver.Legacy.Tests/MongoDB.Driver.Legacy.Tests.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
<Compile Include="Jira\CSharp111Tests.cs" />
7171
<Compile Include="Jira\CSharp112Tests.cs" />
7272
<Compile Include="Jira\CSharp134Tests.cs" />
73+
<Compile Include="Jira\CSharp140Tests.cs" />
7374
<Compile Include="Jira\CSharp163Tests.cs" />
7475
<Compile Include="Jira\CSharp172Tests.cs" />
7576
<Compile Include="Jira\CSharp198Tests.cs" />
@@ -86,6 +87,7 @@
8687
<Compile Include="Jira\CSharp269Tests.cs" />
8788
<Compile Include="Jira\CSharp281Tests.cs" />
8889
<Compile Include="Jira\CSharp282Tests.cs" />
90+
<Compile Include="Jira\CSharp290Tests.cs" />
8991
<Compile Include="Jira\CSharp307Tests.cs" />
9092
<Compile Include="Jira\CSharp325Tests.cs" />
9193
<Compile Include="Jira\CSharp330Tests.cs" />
@@ -99,6 +101,7 @@
99101
<Compile Include="Jira\CSharp524Tests.cs" />
100102
<Compile Include="Jira\CSharp538Tests.cs" />
101103
<Compile Include="Jira\CSharp542Tests.cs" />
104+
<Compile Include="Jira\CSharp594Tests.cs" />
102105
<Compile Include="Jira\CSharp613Tests.cs" />
103106
<Compile Include="Jira\CSharp653Tests.cs" />
104107
<Compile Include="Jira\CSharp714Tests.cs" />

src/MongoDB.Driver.Legacy/MongoDB.Driver.Legacy/MongoDB.Driver.Legacy.csproj

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,31 @@
115115
<Compile Include="SystemProfileInfo.cs" />
116116
<Compile Include="UpdateFlags.cs" />
117117
<Compile Include="ValidateCollectionArgs.cs" />
118+
<Compile Include="Wrappers\BaseWrapper.cs" />
119+
<Compile Include="Wrappers\CollectionOptionsDocument.cs" />
120+
<Compile Include="Wrappers\CollectionOptionsWrapper.cs" />
121+
<Compile Include="Wrappers\CommandDocument.cs" />
122+
<Compile Include="Wrappers\CommandWrapper.cs" />
123+
<Compile Include="Wrappers\FieldsDocument.cs" />
124+
<Compile Include="Wrappers\FieldsWrapper.cs" />
125+
<Compile Include="Wrappers\GeoHaystackSearchOptionsDocument.cs" />
126+
<Compile Include="Wrappers\GeoHaystackSearchOptionsWrapper.cs" />
127+
<Compile Include="Wrappers\GeoNearOptionsDocument.cs" />
128+
<Compile Include="Wrappers\GeoNearOptionsWrapper.cs" />
129+
<Compile Include="Wrappers\GroupByDocument.cs" />
130+
<Compile Include="Wrappers\GroupByWrapper.cs" />
131+
<Compile Include="Wrappers\IndexKeysDocument.cs" />
132+
<Compile Include="Wrappers\IndexKeysWrapper.cs" />
133+
<Compile Include="Wrappers\IndexOptionsDocument.cs" />
134+
<Compile Include="Wrappers\IndexOptionsWrapper.cs" />
135+
<Compile Include="Wrappers\QueryDocument.cs" />
136+
<Compile Include="Wrappers\QueryWrapper.cs" />
137+
<Compile Include="Wrappers\ScopeDocument.cs" />
138+
<Compile Include="Wrappers\ScopeWrapper.cs" />
139+
<Compile Include="Wrappers\SortByDocument.cs" />
140+
<Compile Include="Wrappers\SortByWrapper.cs" />
141+
<Compile Include="Wrappers\UpdateDocument.cs" />
142+
<Compile Include="Wrappers\UpdateWrapper.cs" />
118143
<Compile Include="XYPoint.cs" />
119144
</ItemGroup>
120145
<ItemGroup>

src/MongoDB.Driver.Tests/Builders/QueryBuilderTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public void TestAndNullSecond()
122122
[Test]
123123
public void TestAndWithEmptyQuery()
124124
{
125-
var emptyQuery = new QueryDocument();
125+
var emptyQuery = Query.Empty;
126126
var expected = "{ }";
127127
var negated = "{ \"$nor\" : [{ }] }";
128128

@@ -566,7 +566,7 @@ public void TestOrNullSecond()
566566
[Test]
567567
public void TestOrWithEmptyQuery()
568568
{
569-
var emptyQuery = new QueryDocument();
569+
var emptyQuery = Query.Empty;
570570
var expected = "{ }";
571571
var negated = "{ \"$nor\" : [{ }] }";
572572

src/MongoDB.Driver.Tests/Jira/CSharp321Tests.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public void TestNoArgs()
3434
public void TestOneNestedAnd()
3535
{
3636
var query = Query.And(
37-
new QueryDocument("$and", new BsonArray { new BsonDocument("x", 1), new BsonDocument("y", 2) })
37+
Query.Create("$and", new BsonArray { new BsonDocument("x", 1), new BsonDocument("y", 2) })
3838
);
3939
var expected = "{ 'x' : 1, 'y' : 2 }".Replace("'", "\"");
4040
var json = query.ToJson();
@@ -68,7 +68,7 @@ public void TestTwoClauses()
6868
public void TestCombineAndWithOneClause()
6969
{
7070
var query = Query.And(
71-
new QueryDocument("$and", new BsonArray { new BsonDocument("x", 1), new BsonDocument("y", 2) }),
71+
Query.Create("$and", new BsonArray { new BsonDocument("x", 1), new BsonDocument("y", 2) }),
7272
Query.EQ("z", 3)
7373
);
7474
var expected = "{ 'x' : 1, 'y' : 2, 'z' : 3 }".Replace("'", "\"");
@@ -80,8 +80,8 @@ public void TestCombineAndWithOneClause()
8080
public void TestCombineAndWithAnd()
8181
{
8282
var query = Query.And(
83-
new QueryDocument("$and", new BsonArray { new BsonDocument("a", 1), new BsonDocument("b", 2) }),
84-
new QueryDocument("$and", new BsonArray { new BsonDocument("x", 1), new BsonDocument("y", 2) })
83+
Query.Create("$and", new BsonArray { new BsonDocument("a", 1), new BsonDocument("b", 2) }),
84+
Query.Create("$and", new BsonArray { new BsonDocument("x", 1), new BsonDocument("y", 2) })
8585
);
8686
var expected = "{ 'a' : 1, 'b' : 2, 'x' : 1, 'y' : 2 }".Replace("'", "\"");
8787
var json = query.ToJson();
@@ -94,7 +94,7 @@ public void TestCombineTwoClausesWithAnd()
9494
var query = Query.And(
9595
Query.EQ("a", 1),
9696
Query.EQ("b", 2),
97-
new QueryDocument("$and", new BsonArray { new BsonDocument("x", 1), new BsonDocument("y", 2) })
97+
Query.Create("$and", new BsonArray { new BsonDocument("x", 1), new BsonDocument("y", 2) })
9898
);
9999
var expected = "{ 'a' : 1, 'b' : 2, 'x' : 1, 'y' : 2 }".Replace("'", "\"");
100100
var json = query.ToJson();
@@ -156,7 +156,7 @@ public void TestCombineTwoNonCombinableClausesForSameField()
156156
public void TestNestedAndClause()
157157
{
158158
var query = Query.And(
159-
new QueryDocument("$and", new BsonArray { new BsonDocument("x", 1), new BsonDocument("y", 2) }),
159+
Query.Create("$and", new BsonArray { new BsonDocument("x", 1), new BsonDocument("y", 2) }),
160160
Query.EQ("z", 3)
161161
);
162162
var expected = "{ 'x' : 1, 'y' : 2, 'z' : 3 }".Replace("'", "\"");

src/MongoDB.Driver.Tests/MongoDB.Driver.Tests.csproj

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,8 @@
162162
<Compile Include="Jira\CSharp598Tests.cs" />
163163
<Compile Include="Jira\CSharp532Tests.cs" />
164164
<Compile Include="Jira\CSharp137Tests.cs" />
165-
<Compile Include="Jira\CSharp140Tests.cs" />
166165
<Compile Include="Jira\CSharp283Tests.cs" />
167-
<Compile Include="Jira\CSharp290Tests.cs" />
168166
<Compile Include="Jira\CSharp321Tests.cs" />
169-
<Compile Include="Jira\CSharp594Tests.cs" />
170167
<Compile Include="Linq\Utils\BsonSerializationInfoHelperTests.cs" />
171168
<Compile Include="Properties\AssemblyInfo.cs" />
172169
<Compile Include="MongoBulkWriteExceptionTests.cs" />
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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+
16+
using MongoDB.Bson;
17+
using MongoDB.Bson.Serialization;
18+
using MongoDB.Bson.Serialization.Attributes;
19+
using MongoDB.Bson.Serialization.Serializers;
20+
21+
namespace MongoDB.Driver.Builders
22+
{
23+
[BsonSerializer(typeof(MongoQueryWrapper.Serializer))]
24+
internal class MongoQueryWrapper : IMongoQuery
25+
{
26+
// fields
27+
private readonly BsonDocument _wrapped;
28+
29+
// constructors
30+
public MongoQueryWrapper(BsonDocument wrapped)
31+
{
32+
_wrapped = wrapped;
33+
}
34+
35+
// methods
36+
public override string ToString()
37+
{
38+
return _wrapped.ToJson();
39+
}
40+
41+
// nested classes
42+
internal class Serializer : SerializerBase<MongoQueryWrapper>
43+
{
44+
public override void Serialize(BsonSerializationContext context, BsonSerializationArgs args, MongoQueryWrapper value)
45+
{
46+
BsonDocumentSerializer.Instance.Serialize(context, value._wrapped);
47+
}
48+
}
49+
}
50+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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+
16+
using System;
17+
using MongoDB.Bson.Serialization;
18+
using MongoDB.Bson.Serialization.Attributes;
19+
using MongoDB.Bson.Serialization.Serializers;
20+
21+
namespace MongoDB.Driver.Builders
22+
{
23+
[BsonSerializer(typeof(MongoUpdateWrapper.Serializer))]
24+
internal class MongoUpdateWrapper : IMongoUpdate
25+
{
26+
// fields
27+
private Type _nominalType;
28+
private IBsonSerializer _serializer;
29+
private readonly object _wrapped;
30+
31+
// constructors
32+
public MongoUpdateWrapper(object wrapped, IBsonSerializer serializer, Type nominalType)
33+
{
34+
_wrapped = wrapped;
35+
_serializer = serializer;
36+
_nominalType = nominalType;
37+
}
38+
39+
// nested classes
40+
internal class Serializer : SerializerBase<MongoUpdateWrapper>
41+
{
42+
public override void Serialize(BsonSerializationContext context, BsonSerializationArgs args, MongoUpdateWrapper value)
43+
{
44+
value._serializer.Serialize(context, new BsonSerializationArgs { NominalType = value._nominalType }, value._wrapped);
45+
}
46+
}
47+
}
48+
}

0 commit comments

Comments
 (0)