Permalink
Browse files

Merge with samustypedcollection and fix csproj merge bug.

  • Loading branch information...
2 parents 7075e46 + 616c80c commit f3dffacf6acd34b30c21a4790325b852776862a0 @lanwin lanwin committed Mar 18, 2010
Showing with 2,609 additions and 1,159 deletions.
  1. +11 −3 .gitignore
  2. +43 −43 MongoDB.Driver.Benchmark/MongoDB.Driver.Benchmark.csproj
  3. +3 −2 MongoDB.GridFS.Tests/GridFileInfoTest.cs
  4. +24 −0 MongoDB.GridFS.Tests/GridFileStreamTest.cs
  5. +38 −39 MongoDB.GridFS.Tests/GridTestBase.cs
  6. +7 −11 MongoDB.GridFS.Tests/MongoDB.GridFS.Tests.csproj
  7. +3 −3 MongoDB.GridFS/GridFile.cs
  8. +13 −11 MongoDB.GridFS/GridFileInfo.cs
  9. +391 −389 MongoDB.GridFS/GridFileStream.cs
  10. +1 −3 MongoDB.GridFS/MongoDB.GridFS.csproj
  11. +1 −1 MongoDB.Linq.Tests/MongoDB.Linq.Tests.csproj
  12. +1 −1 MongoDB.Linq/MongoDB.Linq.csproj
  13. +68 −67 MongoDB.Net-Tests/Bson/TestBsonBinary.cs
  14. +132 −19 MongoDB.Net-Tests/Bson/TestBsonReader.cs
  15. +51 −1 MongoDB.Net-Tests/Bson/TestBsonWriter.cs
  16. +17 −0 MongoDB.Net-Tests/Bson/TestRoundTrips.cs
  17. +25 −0 MongoDB.Net-Tests/Configuration/TestConfigurationSection.cs
  18. +37 −13 MongoDB.Net-Tests/MongoDB.Driver.Tests.csproj
  19. +16 −4 MongoDB.Net-Tests/MongoDB.Driver.Tests.dll.config
  20. +61 −61 MongoDB.Net-Tests/MongoTestBase.cs
  21. +52 −0 MongoDB.Net-Tests/TestCollection.cs
  22. +76 −2 MongoDB.Net-Tests/TestOid.cs
  23. +3 −3 MongoDB.Net-Tests/TestOidGenerator.cs
  24. +18 −10 MongoDBDriver.sln
  25. +1 −0 MongoDBDriver/.gitignore
  26. +6 −0 MongoDBDriver/Bson/BsonInfo.cs
  27. +223 −136 MongoDBDriver/Bson/BsonReader.cs
  28. +16 −13 MongoDBDriver/Bson/BsonWriter.cs
  29. +336 −0 MongoDBDriver/Collection.cs
  30. +70 −0 MongoDBDriver/Configuration/ConnectionCollection.cs
  31. +21 −0 MongoDBDriver/Configuration/ConnectionElement.cs
  32. +20 −0 MongoDBDriver/Configuration/MongoConfiguration.cs
  33. +152 −152 MongoDBDriver/Connections/Connection.cs
  34. +69 −59 MongoDBDriver/Document.cs
  35. +27 −21 MongoDBDriver/MongoDB.Driver.csproj
  36. +71 −21 MongoDBDriver/Oid.cs
  37. +12 −0 MongoDBDriver/Protocol/IRequestMessage.cs
  38. +81 −14 MongoDBDriver/Protocol/InsertMessage.cs
  39. +3 −1 MongoDBDriver/Protocol/MessageBase.cs
  40. +7 −5 MongoDBDriver/Protocol/RequestMessageBase.cs
  41. +33 −0 MongoDBDriver/Protocol/RequestMessageBase.cs.BASE.cs
  42. +32 −0 MongoDBDriver/Protocol/RequestMessageBase.cs.LOCAL.cs
  43. +35 −0 MongoDBDriver/Protocol/RequestMessageBase.cs.REMOTE.cs
  44. +67 −0 MongoDBDriver/Serialization/ReflectionBuilder.cs
  45. +8 −1 README.rst
  46. +50 −50 examples/Simple/Simple.csproj
  47. +93 −0 examples/SimpleVB/Application.vb
  48. +25 −0 examples/SimpleVB/AssemblyInfo.vb
  49. +6 −0 examples/SimpleVB/SimpleVB.exe.config
  50. +53 −0 examples/SimpleVB/SimpleVB.vbproj
View
@@ -1,3 +1,4 @@
+
*~
*.dll
*.*~
@@ -16,10 +17,17 @@
*.cache
*.ReSharper
-bin/
-obj/
-test-results/
+*/bin/*
+*/obj/*
+*/test-results/*
+/test-results/
+
+/examples/*/bin/*
+/examples/*/test-results/*
+/examples/*/obj/*
/_UpgradeReport_Files/*
/redist/*.zip
+
+*_ReSharper.*/**
@@ -1,44 +1,44 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProductVersion>9.0.21022</ProductVersion>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{5ACD68A0-0F2E-452A-90E3-3D1CB82C055B}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <RootNamespace>MongoDB.Driver.Benchmark</RootNamespace>
- <AssemblyName>MongoDB.Driver.Benchmark</AssemblyName>
- <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- <DebugSymbols>true</DebugSymbols>
- <DebugType>full</DebugType>
- <Optimize>false</Optimize>
- <OutputPath>bin\Debug</OutputPath>
- <DefineConstants>DEBUG</DefineConstants>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- <DebugType>none</DebugType>
- <Optimize>false</Optimize>
- <OutputPath>bin\Release</OutputPath>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- </PropertyGroup>
- <ItemGroup>
- <Reference Include="System" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="Main.cs" />
- <Compile Include="AssemblyInfo.cs" />
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="..\MongoDBDriver\MongoDB.Driver.csproj">
- <Project>{B125BBA6-BFFD-44FA-9254-9B1754CD8AF3}</Project>
- <Name>MongoDB.Driver</Name>
- </ProjectReference>
- </ItemGroup>
- <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>9.0.21022</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{5ACD68A0-0F2E-452A-90E3-3D1CB82C055B}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <RootNamespace>MongoDB.Driver.Benchmark</RootNamespace>
+ <AssemblyName>MongoDB.Driver.Benchmark</AssemblyName>
+ <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug</OutputPath>
+ <DefineConstants>DEBUG</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>none</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Release</OutputPath>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Main.cs" />
+ <Compile Include="AssemblyInfo.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\MongoDBDriver\MongoDB.Driver.csproj">
+ <Project>{B125BBA6-BFFD-44FA-9254-9B1754CD8AF3}</Project>
+ <Name>MongoDB.Driver</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
</Project>
@@ -1,4 +1,5 @@
using System;
+using System.Collections.Generic;
using System.IO;
using NUnit.Framework;
@@ -144,11 +145,11 @@ public class GridFileInfoTest : GridTestBase
tw.WriteLine("test");
tw.Close();
}
- gfi.Aliases = new String[]{"file1"};
+ gfi.Aliases = new List<String>(){"file1"};
GridFileInfo gfi2 = new GridFileInfo(DB,fs, filename);
Assert.IsTrue(gfi2.Exists, "Couldn't find " + filename);
Assert.AreEqual("text/sam", gfi2.ContentType);
- Assert.AreNotEqual(gfi2.Aliases, gfi.Aliases);
+ Assert.AreNotEqual(gfi2.Aliases, gfi.Aliases, "Aliases shouldn't have been updated in the DB yet.");
gfi.UpdateInfo();
gfi2.Refresh();
Assert.AreEqual(gfi2.Aliases, gfi.Aliases);
@@ -236,6 +236,30 @@ public class GridFileStreamTest : GridTestBase
expected++;
}
}
+
+ [Test]
+ public void TestReadFrom3Chunks(){
+ string filename = "read3chunks.txt";
+ int chunks = 3;
+ int chunkSize = 256 * 1024;
+ int size = (256 * 1024 * chunks) - 5000;
+
+
+ Object id = CreateDummyFile(filename,size,chunkSize,0);
+
+
+ using(GridFileStream gfs = fs.OpenRead(filename)){
+ int buffsize = 10240;
+ Byte[] buff = new Byte[buffsize];
+ int read = 0;
+ int totalRead = 0;
+ while((read = gfs.Read(buff,0,buffsize)) != 0){
+ totalRead += read;
+ }
+ Assert.AreEqual(size,totalRead,"Not all bytes read back");
+ }
+
+ }
[Test]
public void TestSetLengthBigger(){
View
@@ -1,39 +1,38 @@
-using System;
-using System.Configuration;
-using System.Text;
-
-using NUnit.Framework;
-
-using MongoDB.Driver;
-
-namespace MongoDB.GridFS
-{
- public abstract class GridTestBase : MongoTestBase
- {
- /// <summary>
- /// Comma separated list of collections to clean at startup.
- /// </summary>
- public abstract string TestFileSystems{get;}
-
- /// <summary>
- /// Turns the TestFileSystems string into a comma delimited set of collections
- /// </summary>
- public override string TestCollections {
- get {
- StringBuilder sb = new StringBuilder();
- foreach(string fs in this.TestFileSystems.Split(',')){
- sb.Append(fs + ".files,");
- sb.Append(fs + ".chunks,");
- }
- sb.Remove(sb.Length - 1,1); //remove last ,
- Console.WriteLine(sb.ToString());
- return sb.ToString();
- }
- }
-
- public long CountChunks(string filesystem, Object fileid){
- return DB[filesystem + ".chunks"].Count(new Document().Append("files_id", fileid));
- }
-
- }
-}
+using System;
+using System.Configuration;
+using System.Text;
+
+using NUnit.Framework;
+
+using MongoDB.Driver;
+
+namespace MongoDB.GridFS
+{
+ public abstract class GridTestBase : MongoTestBase
+ {
+ /// <summary>
+ /// Comma separated list of collections to clean at startup.
+ /// </summary>
+ public abstract string TestFileSystems{get;}
+
+ /// <summary>
+ /// Turns the TestFileSystems string into a comma delimited set of collections
+ /// </summary>
+ public override string TestCollections {
+ get {
+ StringBuilder sb = new StringBuilder();
+ foreach(string fs in this.TestFileSystems.Split(',')){
+ sb.Append(fs + ".files,");
+ sb.Append(fs + ".chunks,");
+ }
+ sb.Remove(sb.Length - 1,1); //remove last ,
+ return sb.ToString();
+ }
+ }
+
+ public long CountChunks(string filesystem, Object fileid){
+ return DB[filesystem + ".chunks"].Count(new Document().Append("files_id", fileid));
+ }
+
+ }
+}
@@ -8,7 +8,7 @@
<ProjectGuid>{0C293FE9-F670-4FEF-A60F-20F8C978B1CD}</ProjectGuid>
<OutputType>Library</OutputType>
<AssemblyName>MongoDB.GridFS.Tests</AssemblyName>
- <TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<RootNamespace>MongoDB.GridFS.Tests</RootNamespace>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
@@ -42,8 +42,13 @@
<Compile Include="GridFileStreamTest.cs" />
<Compile Include="GridFileTest.cs" />
<Compile Include="GridTestBase.cs" />
+ <None Include="MongoDB.GridFS.Tests.csproj" />
</ItemGroup>
<ItemGroup>
+ <ProjectReference Include="..\MongoDB.Net-Tests\MongoDB.Driver.Tests.csproj">
+ <Project>{C8BC95AB-25C6-4133-BC9F-8B6BB782CA02}</Project>
+ <Name>MongoDB.Driver.Tests</Name>
+ </ProjectReference>
<ProjectReference Include="..\MongoDBDriver\MongoDB.Driver.csproj">
<Project>{B125BBA6-BFFD-44FA-9254-9B1754CD8AF3}</Project>
<Name>MongoDB.Driver</Name>
@@ -52,15 +57,6 @@
<Project>{B42DBBF9-0A1F-4749-9787-013BF8D8F435}</Project>
<Name>MongoDB.GridFS</Name>
</ProjectReference>
- <ProjectReference Include="..\MongoDB.Net-Tests\MongoDB.Driver.Tests.csproj">
- <Project>{C8BC95AB-25C6-4133-BC9F-8B6BB782CA02}</Project>
- <Name>MongoDB.Driver.Tests</Name>
- </ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
- <ItemGroup>
- <None Include="MongoDB.GridFS.Tests.dll.config">
- <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
- </None>
- </ItemGroup>
-</Project>
+</Project>
@@ -6,7 +6,7 @@ namespace MongoDB.GridFS
{
public class GridFile{
- private MongoDatabase db;
+ private IMongoDatabase db;
private string name;
public string Name {
@@ -25,9 +25,9 @@ public IMongoCollection<Document> Chunks
get { return this.chunks; }
}
- public GridFile(MongoDatabase db):this(db,"fs"){}
+ public GridFile(IMongoDatabase db):this(db,"fs"){}
- public GridFile(MongoDatabase db, string bucket){
+ public GridFile(IMongoDatabase db, string bucket){
this.db = db;
this.files = db[bucket + ".files"];
this.chunks = db[bucket + ".chunks"];
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.IO;
+
using MongoDB.Driver;
namespace MongoDB.GridFS
@@ -17,7 +18,7 @@ public class GridFileInfo
private const string DEFAULT_CONTENT_TYPE = "text/plain";
private GridFile gridFile;
- private MongoDatabase db;
+ private IMongoDatabase db;
private string bucket;
@@ -49,15 +50,16 @@ public string FileName
set { filedata["length"] = value; }
}
- public string[] Aliases{
- get
- {
- var aliases = filedata["aliases"];
-
- if(aliases is List<string>)
- filedata["aliases"] = aliases = ((List<string>)aliases).ToArray();
-
- return (String[])aliases;
+ public IList<String> Aliases{
+ get {
+ if(filedata.Contains("aliases") == false || filedata["aliases"] == null){
+ return null;
+ }
+ if(filedata["aliases"] is IList<String>){
+ return (List<String>)filedata["aliases"];
+ }else{
+ return new List<String>();
+ }
}
set { filedata["aliases"] = value; }
}
@@ -82,7 +84,7 @@ public string FileName
}
#endregion
- public GridFileInfo(MongoDatabase db, string bucket, string filename){
+ public GridFileInfo(IMongoDatabase db, string bucket, string filename){
this.db = db;
this.bucket = bucket;
this.gridFile = new GridFile(db,bucket);
Oops, something went wrong.

0 comments on commit f3dffac

Please sign in to comment.