Skip to content

Commit a312bca

Browse files
committed
fix the issue of 'GetCustomAttributes'
1 parent 0acc692 commit a312bca

File tree

12 files changed

+482
-4
lines changed

12 files changed

+482
-4
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,5 @@ src/MongoDB.Driver/project.lock.json
6666
samples/MongoDB.Tests.ConsoleApp/project.lock.json
6767
src/RaisingStudio.MongoDB.Bson
6868
src/RaisingStudio.MongoDB.Driver.Core
69-
src/RaisingStudio.MongoDB.Driver
69+
src/RaisingStudio.MongoDB.Driver
70+
samples/MongoDB.Tests.WebApplication/project.lock.json

mongo-csharp-driver.sln

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio 14
4-
VisualStudioVersion = 14.0.25402.0
4+
VisualStudioVersion = 14.0.25420.1
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{B4E459B4-5B8C-4933-BECC-AEB36CEC84F6}"
77
EndProject
@@ -22,6 +22,8 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "MongoDB.Tests.ConsoleApp",
2222
EndProject
2323
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "MongoDB.Driver.GridFS", "src\MongoDB.Driver.GridFS\MongoDB.Driver.GridFS.xproj", "{9976071B-899E-4687-B0E7-B45AE6AFF6C8}"
2424
EndProject
25+
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "MongoDB.Tests.WebApplication", "samples\MongoDB.Tests.WebApplication\MongoDB.Tests.WebApplication.xproj", "{8888371D-74A8-4FBC-A93D-335E68FF9709}"
26+
EndProject
2527
Global
2628
GlobalSection(SolutionConfigurationPlatforms) = preSolution
2729
Debug|Any CPU = Debug|Any CPU
@@ -48,6 +50,10 @@ Global
4850
{9976071B-899E-4687-B0E7-B45AE6AFF6C8}.Debug|Any CPU.Build.0 = Debug|Any CPU
4951
{9976071B-899E-4687-B0E7-B45AE6AFF6C8}.Release|Any CPU.ActiveCfg = Release|Any CPU
5052
{9976071B-899E-4687-B0E7-B45AE6AFF6C8}.Release|Any CPU.Build.0 = Release|Any CPU
53+
{8888371D-74A8-4FBC-A93D-335E68FF9709}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
54+
{8888371D-74A8-4FBC-A93D-335E68FF9709}.Debug|Any CPU.Build.0 = Debug|Any CPU
55+
{8888371D-74A8-4FBC-A93D-335E68FF9709}.Release|Any CPU.ActiveCfg = Release|Any CPU
56+
{8888371D-74A8-4FBC-A93D-335E68FF9709}.Release|Any CPU.Build.0 = Release|Any CPU
5157
EndGlobalSection
5258
GlobalSection(SolutionProperties) = preSolution
5359
HideSolutionNode = FALSE
@@ -58,5 +64,6 @@ Global
5864
{22C3CF35-4EEE-40DE-A313-33E2CFAC1F08} = {B4E459B4-5B8C-4933-BECC-AEB36CEC84F6}
5965
{CCD9B0EE-086A-46F4-8307-9E46E50C57C2} = {EF7A690C-F868-4E61-8ED7-3D05AC39D209}
6066
{9976071B-899E-4687-B0E7-B45AE6AFF6C8} = {B4E459B4-5B8C-4933-BECC-AEB36CEC84F6}
67+
{8888371D-74A8-4FBC-A93D-335E68FF9709} = {EF7A690C-F868-4E61-8ED7-3D05AC39D209}
6168
EndGlobalSection
6269
EndGlobal
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Threading.Tasks;
5+
using Microsoft.AspNetCore.Mvc;
6+
using MongoDB.Bson;
7+
using MongoDB.Driver;
8+
9+
// For more information on enabling MVC for empty projects, visit http://go.microsoft.com/fwlink/?LinkID=397860
10+
11+
namespace MongoDB.Tests.WebApplication.Controllers
12+
{
13+
public class HomeController : Controller
14+
{
15+
16+
public static async Task Test1()
17+
{
18+
var client = new MongoClient("mongodb://localhost:27017");
19+
var database = client.GetDatabase("foo");
20+
var collection = database.GetCollection<BsonDocument>("bar");
21+
22+
await collection.InsertOneAsync(new BsonDocument("Name", "Jack"));
23+
24+
var list = await collection.Find(new BsonDocument("Name", "Jack"))
25+
.ToListAsync();
26+
27+
foreach (var document in list)
28+
{
29+
Console.WriteLine(document["Name"]);
30+
}
31+
}
32+
33+
public class Person
34+
{
35+
public ObjectId Id { get; set; }
36+
public string Name { get; set; }
37+
}
38+
39+
public static async Task Test2()
40+
{
41+
var client = new MongoClient("mongodb://localhost:27017");
42+
var database = client.GetDatabase("foo");
43+
IMongoCollection<Person> collection = null;
44+
try
45+
{
46+
collection = database.GetCollection<Person>("bar");
47+
}
48+
catch (Exception ex)
49+
{
50+
Console.WriteLine(ex);
51+
}
52+
53+
await collection.InsertOneAsync(new Person { Name = "Jack" });
54+
55+
var list = await collection.Find(x => x.Name == "Jack")
56+
.ToListAsync();
57+
58+
foreach (var person in list)
59+
{
60+
Console.WriteLine(person.Name);
61+
}
62+
}
63+
64+
// GET: /<controller>/
65+
public IActionResult Index()
66+
{
67+
Test1().GetAwaiter().GetResult();
68+
Test2().GetAwaiter().GetResult();
69+
70+
return View();
71+
}
72+
}
73+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
5+
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
6+
</PropertyGroup>
7+
8+
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
9+
<PropertyGroup Label="Globals">
10+
<ProjectGuid>8888371d-74a8-4fbc-a93d-335e68ff9709</ProjectGuid>
11+
<RootNamespace>MongoDB.Tests.WebApplication</RootNamespace>
12+
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
13+
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
14+
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
15+
</PropertyGroup>
16+
17+
<PropertyGroup>
18+
<SchemaVersion>2.0</SchemaVersion>
19+
</PropertyGroup>
20+
<ItemGroup>
21+
<DnxInvisibleContent Include="bower.json" />
22+
<DnxInvisibleContent Include=".bowerrc" />
23+
</ItemGroup>
24+
<Import Project="$(VSToolsPath)\DotNet.Web\Microsoft.DotNet.Web.targets" Condition="'$(VSToolsPath)' != ''" />
25+
</Project>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.IO;
4+
using System.Linq;
5+
using System.Threading.Tasks;
6+
using Microsoft.AspNetCore.Hosting;
7+
8+
namespace MongoDB.Tests.WebApplication
9+
{
10+
public class Program
11+
{
12+
public static void Main(string[] args)
13+
{
14+
var host = new WebHostBuilder()
15+
.UseKestrel()
16+
.UseContentRoot(Directory.GetCurrentDirectory())
17+
.UseIISIntegration()
18+
.UseStartup<Startup>()
19+
.Build();
20+
21+
host.Run();
22+
}
23+
}
24+
}
Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8" />
5+
<title>Welcome to ASP.NET Core</title>
6+
<style>
7+
html {
8+
background: #f1f1f1;
9+
height: 100%;
10+
}
11+
12+
body {
13+
background: #fff;
14+
color: #505050;
15+
font: 14px 'Segoe UI', tahoma, arial, helvetica, sans-serif;
16+
margin: 1%;
17+
min-height: 95.5%;
18+
border: 1px solid silver;
19+
position: relative;
20+
}
21+
22+
#header {
23+
padding: 0;
24+
}
25+
26+
#header h1 {
27+
font-size: 44px;
28+
font-weight: normal;
29+
margin: 0;
30+
padding: 10px 30px 10px 30px;
31+
}
32+
33+
#header span {
34+
margin: 0;
35+
padding: 0 30px;
36+
display: block;
37+
}
38+
39+
#header p {
40+
font-size: 20px;
41+
color: #fff;
42+
background: #007acc;
43+
padding: 0 30px;
44+
line-height: 50px;
45+
margin-top: 25px;
46+
47+
}
48+
49+
#header p a {
50+
color: #fff;
51+
text-decoration: underline;
52+
font-weight: bold;
53+
padding-right: 35px;
54+
background: no-repeat right bottom url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABcAAAAWCAMAAAAcqPc3AAAANlBMVEUAAAAAeswfitI9mthXp91us+KCvuaTx+mjz+2x1u+83PLH4vTR5/ba7Pjj8Pns9fv1+v3////wy3dWAAAAAXRSTlMAQObYZgAAAHxJREFUeNp9kVcSwCAIRMHUYoH7XzaxOxJ9P8oyQ1uIqNPwh3s2aLmIM2YtqrLcQIeQEylhuCeUOlhgve5yoBCfWmlnlgkN4H8ykbpaE7gR03AbUHiwoOxUH9Xp+ubd41p1HF3mBPrfC87BHeTdaB3ceeKL9HGpcvX9zu6+DdMWT9KQPvYAAAAASUVORK5CYII=);
55+
}
56+
57+
#main {
58+
padding: 5px 30px;
59+
clear: both;
60+
}
61+
62+
.section {
63+
width: 21.7%;
64+
float: left;
65+
margin: 0 0 0 4%;
66+
}
67+
68+
.section h2 {
69+
font-size: 13px;
70+
text-transform: uppercase;
71+
margin: 0;
72+
border-bottom: 1px solid silver;
73+
padding-bottom: 12px;
74+
margin-bottom: 8px;
75+
}
76+
77+
.section.first {
78+
margin-left: 0;
79+
}
80+
81+
.section.first h2 {
82+
font-size: 24px;
83+
text-transform: none;
84+
margin-bottom: 25px;
85+
border: none;
86+
}
87+
88+
.section.first li {
89+
border-top: 1px solid silver;
90+
padding: 8px 0;
91+
}
92+
93+
.section.last {
94+
margin-right: 0;
95+
}
96+
97+
ul {
98+
list-style: none;
99+
padding: 0;
100+
margin: 0;
101+
line-height: 20px;
102+
}
103+
104+
li {
105+
padding: 4px 0;
106+
}
107+
108+
a {
109+
color: #267cb2;
110+
text-decoration: none;
111+
}
112+
113+
a:hover {
114+
text-decoration: underline;
115+
}
116+
117+
#footer {
118+
clear: both;
119+
padding-top: 50px;
120+
}
121+
122+
#footer p {
123+
position: absolute;
124+
bottom: 10px;
125+
}
126+
</style>
127+
</head>
128+
<body>
129+
130+
<div id="header">
131+
<h1>Welcome to ASP.NET Core</h1>
132+
<span>
133+
We've made some big updates in this release, so it’s <b>important</b> that you spend
134+
a few minutes to learn what’s new.
135+
</span>
136+
<p>You've created a new ASP.NET Core project. <a href="http://go.microsoft.com/fwlink/?LinkId=518016">Learn what's new</a></p>
137+
</div>
138+
139+
<div id="main">
140+
<div class="section first">
141+
<h2>This application consists of:</h2>
142+
<ul>
143+
<li>Sample pages using ASP.NET Core MVC</li>
144+
<li><a href="http://go.microsoft.com/fwlink/?LinkId=518004">Bower</a> for managing client-side libraries</li>
145+
<li>Theming using <a href="http://go.microsoft.com/fwlink/?LinkID=398939">Bootstrap</a></li>
146+
</ul>
147+
</div>
148+
<div class="section">
149+
<h2>How to</h2>
150+
<ul>
151+
<li><a href="http://go.microsoft.com/fwlink/?LinkID=398600">Add a Controller and View</a></li>
152+
<li><a href="http://go.microsoft.com/fwlink/?LinkID=699562">Add an appsetting in config and access it in app.</a></li>
153+
<li><a href="http://go.microsoft.com/fwlink/?LinkId=699315">Manage User Secrets using Secret Manager.</a></li>
154+
<li><a href="http://go.microsoft.com/fwlink/?LinkId=699316">Use logging to log a message.</a></li>
155+
<li><a href="http://go.microsoft.com/fwlink/?LinkId=699317">Add packages using NuGet.</a></li>
156+
<li><a href="http://go.microsoft.com/fwlink/?LinkId=699318">Add client packages using Bower.</a></li>
157+
<li><a href="http://go.microsoft.com/fwlink/?LinkId=699319">Target development, staging or production environment.</a></li>
158+
</ul>
159+
</div>
160+
<div class="section">
161+
<h2>Overview</h2>
162+
<ul>
163+
<li><a href="http://go.microsoft.com/fwlink/?LinkId=518008">Conceptual overview of what is ASP.NET Core</a></li>
164+
<li><a href="http://go.microsoft.com/fwlink/?LinkId=699320">Fundamentals of ASP.NET Core such as Startup and middleware.</a></li>
165+
<li><a href="http://go.microsoft.com/fwlink/?LinkId=398602">Working with Data</a></li>
166+
<li><a href="http://go.microsoft.com/fwlink/?LinkId=398603">Security</a></li>
167+
<li><a href="http://go.microsoft.com/fwlink/?LinkID=699321">Client side development</a></li>
168+
<li><a href="http://go.microsoft.com/fwlink/?LinkID=699322">Develop on different platforms</a></li>
169+
<li><a href="http://go.microsoft.com/fwlink/?LinkID=699323">Read more on the documentation site</a></li>
170+
</ul>
171+
</div>
172+
<div class="section last">
173+
<h2>Run & Deploy</h2>
174+
<ul>
175+
<li><a href="http://go.microsoft.com/fwlink/?LinkID=517851">Run your app</a></li>
176+
<li><a href="http://go.microsoft.com/fwlink/?LinkID=517853">Run tools such as EF migrations and more</a></li>
177+
<li><a href="http://go.microsoft.com/fwlink/?LinkID=398609">Publish to Microsoft Azure Web Apps</a></li>
178+
</ul>
179+
</div>
180+
181+
<div id="footer">
182+
<p>We would love to hear your <a href="http://go.microsoft.com/fwlink/?LinkId=518015">feedback</a></p>
183+
</div>
184+
</div>
185+
186+
</body>
187+
</html>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"iisSettings": {
3+
"windowsAuthentication": false,
4+
"anonymousAuthentication": true,
5+
"iisExpress": {
6+
"applicationUrl": "http://localhost:60219/",
7+
"sslPort": 0
8+
}
9+
},
10+
"profiles": {
11+
"IIS Express": {
12+
"commandName": "IISExpress",
13+
"launchBrowser": true,
14+
"environmentVariables": {
15+
"ASPNETCORE_ENVIRONMENT": "Development"
16+
}
17+
},
18+
"MongoDB.Tests.WebApplication": {
19+
"commandName": "Project",
20+
"launchBrowser": true,
21+
"launchUrl": "http://localhost:5000",
22+
"environmentVariables": {
23+
"ASPNETCORE_ENVIRONMENT": "Development"
24+
}
25+
}
26+
}
27+
}

0 commit comments

Comments
 (0)