Browse Source
Set AssemblyVersion to 0.5.0.*. Removed internal use only projects so they're not part of the public driver. Created docs folder.
pull/1/head
Set AssemblyVersion to 0.5.0.*. Removed internal use only projects so they're not part of the public driver. Created docs folder.
pull/1/head

15 changed files with 2 additions and 640 deletions
-
3CSharpDriver/Properties/AssemblyInfo.cs
-
6CSharpDriverTest/App.config
-
73CSharpDriverTest/CSharpDriverTest.csproj
-
312CSharpDriverTest/Program.cs
-
51CSharpDriverTest/Properties/AssemblyInfo.cs
-
3CSharpDriverUnitTests/Properties/AssemblyInfo.cs
-
1GridFSBenchmark/.gitignore
-
3GridFSBenchmark/GridFSBenchmark.bat
-
69GridFSBenchmark/GridFSBenchmark.csproj
-
73GridFSBenchmark/Program.cs
-
36GridFSBenchmark/Properties/AssemblyInfo.cs
-
0docs/MongoDB C# Driver Tutorial (Draft 2010-09-12).docx
-
0docs/MongoDB C# Driver Tutorial (Draft 2010-09-12).pdf
-
0docs/csharp-transition-guide.txt
-
12mongo-csharp-driver.sln
@ -1,6 +0,0 @@ |
|||
<?xml version="1.0" encoding="utf-8" ?> |
|||
<configuration> |
|||
<connectionStrings> |
|||
<add name="test" providerName="MongoDB.MongoDBClient" connectionString="server=host1,host2:2134,host3;initial catalog=test;user id=someuser;password=thepassword"/> |
|||
</connectionStrings> |
|||
</configuration> |
@ -1,73 +0,0 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|||
<PropertyGroup> |
|||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
|||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> |
|||
<ProductVersion>9.0.30729</ProductVersion> |
|||
<SchemaVersion>2.0</SchemaVersion> |
|||
<ProjectGuid>{4FC21822-317C-49BF-8B10-150BD9AADFDE}</ProjectGuid> |
|||
<OutputType>Exe</OutputType> |
|||
<AppDesignerFolder>Properties</AppDesignerFolder> |
|||
<RootNamespace>MongoDB.CSharpDriver.Test</RootNamespace> |
|||
<AssemblyName>CSharpDriverTest</AssemblyName> |
|||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion> |
|||
<FileAlignment>512</FileAlignment> |
|||
</PropertyGroup> |
|||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> |
|||
<DebugSymbols>true</DebugSymbols> |
|||
<DebugType>full</DebugType> |
|||
<Optimize>false</Optimize> |
|||
<OutputPath>bin\Debug\</OutputPath> |
|||
<DefineConstants>DEBUG;TRACE</DefineConstants> |
|||
<ErrorReport>prompt</ErrorReport> |
|||
<WarningLevel>4</WarningLevel> |
|||
</PropertyGroup> |
|||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> |
|||
<DebugType>pdbonly</DebugType> |
|||
<Optimize>true</Optimize> |
|||
<OutputPath>bin\Release\</OutputPath> |
|||
<DefineConstants>TRACE</DefineConstants> |
|||
<ErrorReport>prompt</ErrorReport> |
|||
<WarningLevel>4</WarningLevel> |
|||
</PropertyGroup> |
|||
<ItemGroup> |
|||
<Reference Include="MongoDB.BsonLibrary, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> |
|||
<SpecificVersion>False</SpecificVersion> |
|||
<HintPath>..\..\csharp-bson\BsonLibrary\bin\Debug\MongoDB.BsonLibrary.dll</HintPath> |
|||
</Reference> |
|||
<Reference Include="System" /> |
|||
<Reference Include="System.configuration" /> |
|||
<Reference Include="System.Core"> |
|||
<RequiredTargetFramework>3.5</RequiredTargetFramework> |
|||
</Reference> |
|||
<Reference Include="System.Xml.Linq"> |
|||
<RequiredTargetFramework>3.5</RequiredTargetFramework> |
|||
</Reference> |
|||
<Reference Include="System.Data.DataSetExtensions"> |
|||
<RequiredTargetFramework>3.5</RequiredTargetFramework> |
|||
</Reference> |
|||
<Reference Include="System.Data" /> |
|||
<Reference Include="System.Xml" /> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<Compile Include="Program.cs" /> |
|||
<Compile Include="Properties\AssemblyInfo.cs" /> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<None Include="App.config" /> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<ProjectReference Include="..\CSharpDriver\CSharpDriver.csproj"> |
|||
<Project>{AE5166CD-76B0-4911-BD80-CED9521F37A1}</Project> |
|||
<Name>CSharpDriver</Name> |
|||
</ProjectReference> |
|||
</ItemGroup> |
|||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> |
|||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. |
|||
Other similar extension points exist, see Microsoft.Common.targets. |
|||
<Target Name="BeforeBuild"> |
|||
</Target> |
|||
<Target Name="AfterBuild"> |
|||
</Target> |
|||
--> |
|||
</Project> |
@ -1,312 +0,0 @@ |
|||
/* Copyright 2010 10gen Inc. |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Configuration; |
|||
using System.Data.Common; |
|||
using System.Data.SqlClient; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading; |
|||
|
|||
using MongoDB.BsonLibrary; |
|||
using MongoDB.CSharpDriver; |
|||
using MongoDB.CSharpDriver.Builders; |
|||
|
|||
namespace MongoDB.MongoDBClientTest { |
|||
public static class Program { |
|||
public static void Main(string[] args) { |
|||
#if false
|
|||
// test connection string pointing to server
|
|||
{ |
|||
string connectionString = "mongodb://localhost"; |
|||
var server = MongoServer.Create(connectionString); |
|||
var database = server.GetDatabase("test"); |
|||
var collection = database.GetCollection<BsonDocument>("library"); |
|||
foreach (var document in collection.FindAll().Skip(1).Limit(1)) { |
|||
Console.WriteLine(document.ToJson()); |
|||
} |
|||
} |
|||
#endif
|
|||
|
|||
#if false
|
|||
// test connection string pointing to database
|
|||
{ |
|||
string connectionString = "mongodb://localhost/test"; |
|||
var database = MongoDatabase.Create(connectionString); |
|||
var collection = database.GetCollection<BsonDocument>("library"); |
|||
foreach (var document in collection.FindAll().Snapshot()) { |
|||
Console.WriteLine(document.ToJson()); |
|||
} |
|||
} |
|||
#endif
|
|||
|
|||
#if true
|
|||
// test connection string pointing to database with default credentials
|
|||
{ |
|||
string connectionString = "mongodb://localhost/test"; |
|||
var database = MongoDatabase.Create(connectionString); |
|||
database.Server.Connect(TimeSpan.FromMinutes(3)); // time to debug
|
|||
var collection = database.GetCollection<BsonDocument>("books"); |
|||
//var fields = new BsonDocument {
|
|||
// { "author", 1 },
|
|||
// { "_id", 0 }
|
|||
//};
|
|||
var query = new { author = "Tolkien" }; |
|||
var fields = Fields.Include("author", "title").Exclude("_id").Slice("comments", 20, 10); |
|||
foreach (var document in collection.Find(query).Fields(fields).Skip(0).Limit(2)) { |
|||
Console.WriteLine(document.ToJson()); |
|||
} |
|||
} |
|||
#endif
|
|||
|
|||
#if false
|
|||
var connectionString = "server=localhost;database=test"; |
|||
var server = MongoServer.Create(connectionString); |
|||
foreach (string databaseName in server.GetDatabaseNames()) { |
|||
Console.WriteLine(databaseName); |
|||
} |
|||
|
|||
var database = MongoDatabase.Create(connectionString); |
|||
foreach (string collectionName in database.GetCollectionNames()) { |
|||
Console.WriteLine(collectionName); |
|||
} |
|||
#endif
|
|||
|
|||
#if false
|
|||
string connectionString = "mongodb://localhost/test"; |
|||
var database = MongoDatabase.Create(connectionString); |
|||
var collection = database.GetCollection<BsonDocument>("library"); |
|||
int count; |
|||
//count = collection.Count();
|
|||
//count = collection.Count(new BsonDocument { { "author" , "Hemmingway" } });
|
|||
//count = collection.FindAll().Count();
|
|||
//count = collection.Find(new BsonDocument { { "author" , "Hemmingway" } }).Count();
|
|||
count = collection.FindAll().Skip(2).Count(); |
|||
#endif
|
|||
|
|||
#if false
|
|||
string connectionString = "mongodb://localhost/test"; |
|||
var database = MongoDatabase.Create(connectionString); |
|||
var collection = database.GetCollection<BsonDocument>("library"); |
|||
var cursor = collection.FindAll(); |
|||
var explanation = cursor.Explain(false); |
|||
BsonJsonWriterSettings jsonSettings = new BsonJsonWriterSettings { |
|||
Indent = true, |
|||
IndentChars = " " |
|||
}; |
|||
Console.WriteLine(explanation.ToJson(jsonSettings)); |
|||
#endif
|
|||
|
|||
#if false
|
|||
string connectionString = "mongodb://localhost/test"; |
|||
var database = MongoDatabase.Create(connectionString); |
|||
var collection = database.GetCollection<BsonDocument>("library"); |
|||
var document = new BsonDocument { |
|||
{ "_id", "123456789" }, |
|||
{ "author" , "Tom Clancy" }, |
|||
{ "title", "Inside the CIA" } |
|||
}; |
|||
|
|||
database.UseDedicatedConnection = true; |
|||
var result = collection.Insert(document, false); // safeMode
|
|||
var lastError = database.GetLastError(); |
|||
database.ReleaseDedicatedConnection(); |
|||
#endif
|
|||
|
|||
#if false
|
|||
string connectionString = "mongodb://localhost/test"; |
|||
var database = MongoDatabase.Create(connectionString); |
|||
var result = database.CurrentOp(); |
|||
#endif
|
|||
|
|||
#if false
|
|||
string connectionString = "mongodb://localhost/test"; |
|||
var server = MongoServer.Create(connectionString); |
|||
var result = server.RenameCollection("test.library", "test.books"); |
|||
#endif
|
|||
|
|||
#if false
|
|||
string connectionString = "mongodb://localhost/test"; |
|||
var database = MongoDatabase.Create(connectionString); |
|||
var collection = database.GetCollection("books"); |
|||
var result = collection.Update( |
|||
new BsonDocument("author", "Dick"), // query
|
|||
new BsonDocument("$set", new BsonDocument("author", "Harry")), |
|||
true // safeMode
|
|||
); |
|||
#endif
|
|||
|
|||
#if false
|
|||
string connectionString = "mongodb://localhost/test"; |
|||
var database = MongoDatabase.Create(connectionString); |
|||
var collection = database.GetCollection("books"); |
|||
var result = collection.Distinct("author"); |
|||
#endif
|
|||
|
|||
#if false
|
|||
string connectionString = "mongodb://localhost/test"; |
|||
var database = MongoDatabase.Create(connectionString); |
|||
var collection = database.GetCollection("books"); |
|||
var query = new BsonDocument("author", "Tom Clancy"); |
|||
var result1 = collection.Remove(query, RemoveFlags.Single, true); |
|||
var result2 = collection.Remove(query, true); |
|||
#endif
|
|||
|
|||
#if false
|
|||
string connectionString = "mongodb://localhost/test"; |
|||
var database = MongoDatabase.Create(connectionString); |
|||
var collection = database.GetCollection("books"); |
|||
//var result = collection.FindAndModify(
|
|||
// new BsonDocument("author", "Hemmingway Jr."), // query
|
|||
// null, // sort
|
|||
// new BsonDocument("$set", new BsonDocument("author", "Hemmingway Sr.")), // update
|
|||
// true // returnNew
|
|||
//);
|
|||
var result = collection.FindAndRemove( |
|||
new BsonDocument("author", "Hemmingway Sr."), // query
|
|||
null // sort
|
|||
); |
|||
#endif
|
|||
|
|||
#if false
|
|||
string connectionString = "mongodb://localhost/test"; |
|||
var database = MongoDatabase.Create(connectionString); |
|||
var collection = database.GetCollection("books"); |
|||
var result = collection.Group( |
|||
new BsonDocument("author", new BsonDocument("$gt", "H")), // query
|
|||
new BsonDocument("author", 1), // keys
|
|||
new BsonDocument("total", 0), // initial
|
|||
new BsonJavaScriptWithScope( |
|||
"function(doc, prev) { prev.total += 1; }", // code
|
|||
new BsonDocument("xyz", 10) // scope (btw: scope doesn't seem to work with group)
|
|||
), // reduce
|
|||
null // finalize
|
|||
); |
|||
#endif
|
|||
|
|||
#if false
|
|||
string connectionString = "mongodb://localhost/test"; |
|||
var database = MongoDatabase.Create(connectionString); |
|||
var collection = database.GetCollection("books"); |
|||
var map = "function() { for (var key in this) { emit(key, {count: 1}); } }"; |
|||
var reduce = "function(key, emits) { total = 0; for (var i in emits) { total += emits[i].count; } return {count: total}; }"; |
|||
var mapReduceResult = collection.MapReduce(map, reduce); |
|||
var results = mapReduceResult.GetResults<BsonDocument>().ToArray(); |
|||
#endif
|
|||
|
|||
#if false
|
|||
string connectionString = "mongodb://localhost/test"; |
|||
var database = MongoDatabase.Create(connectionString); |
|||
var collection = database.GetCollection("books"); |
|||
var result = collection.Validate(); |
|||
Console.WriteLine(result.ToJson(new BsonJsonWriterSettings { Indent = true })); |
|||
#endif
|
|||
|
|||
#if false
|
|||
string connectionString = "mongodb://localhost,localhost/test"; // fake replica set test by using localhost twice
|
|||
var database = MongoDatabase.Create(connectionString); |
|||
var collection = database.GetCollection("books"); |
|||
database.Server.Connect(TimeSpan.FromMinutes(10)); |
|||
|
|||
database.UseDedicatedConnection = true; |
|||
var book = new BsonDocument { |
|||
{ "author", "Tom Jones" }, |
|||
{ "title", "Life is a song" } |
|||
}; |
|||
collection.Insert(book); |
|||
book = collection.FindOne<BsonDocument>(book); |
|||
database.UseDedicatedConnection = false; |
|||
#endif
|
|||
|
|||
#if false
|
|||
string connectionString = "mongodb://test:test@localhost/test"; |
|||
var database = MongoDatabase.Create(connectionString); |
|||
database.RequestStart(); |
|||
var collection = database.GetCollection<BsonDocument>("books"); |
|||
var books = collection.FindAll(); |
|||
//foreach (var book in books) {
|
|||
// Console.WriteLine(book.ToJson(new BsonJsonWriterSettings { Indent = true }));
|
|||
//}
|
|||
BsonDocument book; |
|||
// used all these to verify that LINQ is good about calling Dispose on enumerators
|
|||
//book = collection.FindOne();
|
|||
//book = collection.FindAll().First();
|
|||
//book = collection.FindAll().FirstOrDefault();
|
|||
//var e1 = collection.FindAll().DefaultIfEmpty(null);
|
|||
//book = collection.FindAll().ElementAt(0);
|
|||
//book = collection.FindAll().Last();
|
|||
////book = collection.FindAll().Single();
|
|||
//var array = collection.FindAll().ToArray();
|
|||
//var list = collection.FindAll().ToList();
|
|||
var count = collection.Count(); |
|||
database.RequestDone(); |
|||
#endif
|
|||
|
|||
#if false
|
|||
string connectionString = "mongodb://test:test@localhost/test"; |
|||
var database = MongoDatabase.Create(connectionString); |
|||
var collection = database.GetCollection<BsonDocument>("tail"); |
|||
var cursor = collection.FindAll().Sort("_id").Flags(QueryFlags.TailableCursor); |
|||
while (true) { |
|||
foreach (var doc in cursor) { |
|||
var id = doc["_id"]; |
|||
Console.WriteLine(id); |
|||
} |
|||
Thread.Sleep(TimeSpan.FromSeconds(1)); |
|||
} |
|||
#endif
|
|||
|
|||
#if false
|
|||
// test sending replSetInitiate to brand new replica set
|
|||
string connectionString1 = "mongodb://kilimanjaro:10002"; // arbitrarily chose 2nd member to send init command to
|
|||
var server = MongoServer.Create(connectionString1); |
|||
server.SlaveOk = true; |
|||
|
|||
var initCommand = new BsonDocument { |
|||
{ "replSetInitiate", new BsonDocument { |
|||
{ "_id" , "azure" }, |
|||
{ "members", new BsonArray { |
|||
new BsonDocument { |
|||
{ "_id", 1 }, |
|||
{ "host", "kilimanjaro:10001" } |
|||
}, |
|||
new BsonDocument { |
|||
{ "_id", 2 }, |
|||
{ "host", "kilimanjaro:10002" } |
|||
}} |
|||
}} |
|||
} |
|||
}; |
|||
var commandResult = server.RunAdminCommand(initCommand); // takes about 10 seconds to return
|
|||
|
|||
string connectionString2 = "mongodb://kilimanjaro:10001,kilimanjaro:10002"; |
|||
server = MongoServer.Create(connectionString2); |
|||
|
|||
while (true) { |
|||
try { |
|||
// this is going to throw exceptions until the replica set has finished electing a primary
|
|||
int count = server["foo"]["bar"].Count(); // arbitrary trivial operation
|
|||
break; |
|||
} catch (Exception ex) { |
|||
Console.WriteLine(ex); |
|||
Thread.Sleep(TimeSpan.FromSeconds(10)); |
|||
} |
|||
} |
|||
#endif
|
|||
} |
|||
} |
|||
} |
@ -1,51 +0,0 @@ |
|||
/* Copyright 2010 10gen Inc. |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
|
|||
using System.Reflection; |
|||
using System.Runtime.CompilerServices; |
|||
using System.Runtime.InteropServices; |
|||
|
|||
// General Information about an assembly is controlled through the following
|
|||
// set of attributes. Change these attribute values to modify the information
|
|||
// associated with an assembly.
|
|||
[assembly: AssemblyTitle("MongoDBClientTest")] |
|||
[assembly: AssemblyDescription("")] |
|||
[assembly: AssemblyConfiguration("")] |
|||
[assembly: AssemblyCompany("Microsoft")] |
|||
[assembly: AssemblyProduct("MongoDBClientTest")] |
|||
[assembly: AssemblyCopyright("Copyright © Microsoft 2010")] |
|||
[assembly: AssemblyTrademark("")] |
|||
[assembly: AssemblyCulture("")] |
|||
|
|||
// Setting ComVisible to false makes the types in this assembly not visible
|
|||
// to COM components. If you need to access a type in this assembly from
|
|||
// COM, set the ComVisible attribute to true on that type.
|
|||
[assembly: ComVisible(false)] |
|||
|
|||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
|||
[assembly: Guid("dfe2375a-0330-410d-8ad5-18c2ea2128ec")] |
|||
|
|||
// Version information for an assembly consists of the following four values:
|
|||
//
|
|||
// Major Version
|
|||
// Minor Version
|
|||
// Build Number
|
|||
// Revision
|
|||
//
|
|||
// You can specify all the values or you can default the Build and Revision Numbers
|
|||
// by using the '*' as shown below:
|
|||
// [assembly: AssemblyVersion("1.0.*")]
|
|||
[assembly: AssemblyVersion("1.0.0.0")] |
|||
[assembly: AssemblyFileVersion("1.0.0.0")] |
@ -1 +0,0 @@ |
|||
*.mp3 |
@ -1,3 +0,0 @@ |
|||
@echo off |
|||
bin\Debug\GridFSBenchmark.exe |
|||
pause |
@ -1,69 +0,0 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|||
<PropertyGroup> |
|||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
|||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> |
|||
<ProductVersion>9.0.30729</ProductVersion> |
|||
<SchemaVersion>2.0</SchemaVersion> |
|||
<ProjectGuid>{EFE0C8E1-4240-45D4-9E7D-FC9AD9A0A292}</ProjectGuid> |
|||
<OutputType>Exe</OutputType> |
|||
<AppDesignerFolder>Properties</AppDesignerFolder> |
|||
<RootNamespace>MongoDB.CSharpDriver.GridFSBenchmark</RootNamespace> |
|||
<AssemblyName>GridFSBenchmark</AssemblyName> |
|||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion> |
|||
<FileAlignment>512</FileAlignment> |
|||
</PropertyGroup> |
|||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> |
|||
<DebugSymbols>true</DebugSymbols> |
|||
<DebugType>full</DebugType> |
|||
<Optimize>false</Optimize> |
|||
<OutputPath>bin\Debug\</OutputPath> |
|||
<DefineConstants>DEBUG;TRACE</DefineConstants> |
|||
<ErrorReport>prompt</ErrorReport> |
|||
<WarningLevel>4</WarningLevel> |
|||
</PropertyGroup> |
|||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> |
|||
<DebugType>pdbonly</DebugType> |
|||
<Optimize>true</Optimize> |
|||
<OutputPath>bin\Release\</OutputPath> |
|||
<DefineConstants>TRACE</DefineConstants> |
|||
<ErrorReport>prompt</ErrorReport> |
|||
<WarningLevel>4</WarningLevel> |
|||
</PropertyGroup> |
|||
<ItemGroup> |
|||
<Reference Include="MongoDB.BsonLibrary, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> |
|||
<SpecificVersion>False</SpecificVersion> |
|||
<HintPath>..\..\csharp-bson\BsonLibrary\bin\Debug\MongoDB.BsonLibrary.dll</HintPath> |
|||
</Reference> |
|||
<Reference Include="System" /> |
|||
<Reference Include="System.Core"> |
|||
<RequiredTargetFramework>3.5</RequiredTargetFramework> |
|||
</Reference> |
|||
<Reference Include="System.Xml.Linq"> |
|||
<RequiredTargetFramework>3.5</RequiredTargetFramework> |
|||
</Reference> |
|||
<Reference Include="System.Data.DataSetExtensions"> |
|||
<RequiredTargetFramework>3.5</RequiredTargetFramework> |
|||
</Reference> |
|||
<Reference Include="System.Data" /> |
|||
<Reference Include="System.Xml" /> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<Compile Include="Program.cs" /> |
|||
<Compile Include="Properties\AssemblyInfo.cs" /> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<ProjectReference Include="..\CSharpDriver\CSharpDriver.csproj"> |
|||
<Project>{AE5166CD-76B0-4911-BD80-CED9521F37A1}</Project> |
|||
<Name>CSharpDriver</Name> |
|||
</ProjectReference> |
|||
</ItemGroup> |
|||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> |
|||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. |
|||
Other similar extension points exist, see Microsoft.Common.targets. |
|||
<Target Name="BeforeBuild"> |
|||
</Target> |
|||
<Target Name="AfterBuild"> |
|||
</Target> |
|||
--> |
|||
</Project> |
@ -1,73 +0,0 @@ |
|||
/* Copyright 2010 10gen Inc. |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading; |
|||
|
|||
using MongoDB.BsonLibrary; |
|||
using MongoDB.CSharpDriver; |
|||
|
|||
namespace MongoDBGridFSTest { |
|||
public static class Program { |
|||
private static MongoGridFS gridFS; |
|||
|
|||
public static void Main(string[] args) { |
|||
var connectionString = "mongodb://127.0.0.1"; |
|||
var server = MongoServer.Create(connectionString); |
|||
server.Connect(TimeSpan.FromMinutes(5)); // give time to debug
|
|||
var database = server.GetDatabase("gridfstest"); |
|||
gridFS = database.GridFS; |
|||
gridFS.Settings.Root = "uploads"; |
|||
gridFS.SafeMode = SafeMode.False; |
|||
|
|||
Thread.Sleep(TimeSpan.FromSeconds(1)); // give a chance to start other instances
|
|||
Console.WriteLine("Starting"); |
|||
|
|||
int iterations = 100; |
|||
DateTime start = DateTime.UtcNow; |
|||
for (int i = 0; i < iterations; i++) { |
|||
// gridFS.Delete("06 Headstrong.mp3");
|
|||
var fileInfo = gridFS.Upload("06 Headstrong.mp3"); |
|||
gridFS.DeleteById(fileInfo.Id); |
|||
} |
|||
DateTime end = DateTime.UtcNow; |
|||
TimeSpan duration = end - start; |
|||
double fps = iterations / duration.TotalSeconds; |
|||
Console.WriteLine("Uploaded {0} files per second", fps); |
|||
|
|||
//iterations = 100;
|
|||
//start = DateTime.UtcNow;
|
|||
//for (int i = 0; i < iterations; i++) {
|
|||
// gridFS.Download("06 Headstrong.mp3");
|
|||
//}
|
|||
//end = DateTime.UtcNow;
|
|||
//duration = end - start;
|
|||
//fps = iterations / duration.TotalSeconds;
|
|||
//Console.WriteLine("Downloaded {0} files per second", fps);
|
|||
|
|||
ListFiles(); |
|||
Console.ReadLine(); |
|||
} |
|||
|
|||
private static void ListFiles() { |
|||
foreach (var file in gridFS.Find()) { |
|||
Console.WriteLine(file.Name); |
|||
} |
|||
} |
|||
} |
|||
} |
@ -1,36 +0,0 @@ |
|||
using System.Reflection; |
|||
using System.Runtime.CompilerServices; |
|||
using System.Runtime.InteropServices; |
|||
|
|||
// General Information about an assembly is controlled through the following
|
|||
// set of attributes. Change these attribute values to modify the information
|
|||
// associated with an assembly.
|
|||
[assembly: AssemblyTitle("MongoDBGridFSTest")] |
|||
[assembly: AssemblyDescription("")] |
|||
[assembly: AssemblyConfiguration("")] |
|||
[assembly: AssemblyCompany("Microsoft")] |
|||
[assembly: AssemblyProduct("MongoDBGridFSTest")] |
|||
[assembly: AssemblyCopyright("Copyright © Microsoft 2010")] |
|||
[assembly: AssemblyTrademark("")] |
|||
[assembly: AssemblyCulture("")] |
|||
|
|||
// Setting ComVisible to false makes the types in this assembly not visible
|
|||
// to COM components. If you need to access a type in this assembly from
|
|||
// COM, set the ComVisible attribute to true on that type.
|
|||
[assembly: ComVisible(false)] |
|||
|
|||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
|||
[assembly: Guid("888ee1e3-c350-4c8b-84a4-ecfc0ce29fa8")] |
|||
|
|||
// Version information for an assembly consists of the following four values:
|
|||
//
|
|||
// Major Version
|
|||
// Minor Version
|
|||
// Build Number
|
|||
// Revision
|
|||
//
|
|||
// You can specify all the values or you can default the Build and Revision Numbers
|
|||
// by using the '*' as shown below:
|
|||
// [assembly: AssemblyVersion("1.0.*")]
|
|||
[assembly: AssemblyVersion("1.0.0.0")] |
|||
[assembly: AssemblyFileVersion("1.0.0.0")] |
Write
Preview
Loading…
Cancel
Save
Reference in new issue