瀏覽代碼

测试使用mongodb的json bson序列化

tanghai 12 年之前
父節點
當前提交
23720c5c6a

+ 36 - 36
CSharp/App/BossBase/Properties/AssemblyInfo.cs

@@ -1,36 +1,36 @@
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-// 有关程序集的常规信息通过以下
-// 特性集控制。更改这些特性值可修改
-// 与程序集关联的信息。
-[assembly: AssemblyTitle("Events")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("Events")]
-[assembly: AssemblyCopyright("Copyright ©  2013")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// 将 ComVisible 设置为 false 使此程序集中的类型
-// 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型,
-// 则将该类型上的 ComVisible 特性设置为 true。
-[assembly: ComVisible(false)]
-
-// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
-[assembly: Guid("288940c7-28fd-45cd-a5f7-87eaeef4740d")]
-
-// 程序集的版本信息由下面四个值组成:
-//
-//      主版本
-//      次版本 
-//      生成号
-//      修订号
-//
-// 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
-// 方法是按如下所示使用“*”:
-// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// 有关程序集的常规信息通过以下
+// 特性集控制。更改这些特性值可修改
+// 与程序集关联的信息。
+[assembly: AssemblyTitle("Events")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("Events")]
+[assembly: AssemblyCopyright("Copyright ©  2013")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// 将 ComVisible 设置为 false 使此程序集中的类型
+// 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型,
+// 则将该类型上的 ComVisible 特性设置为 true。
+[assembly: ComVisible(false)]
+
+// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
+[assembly: Guid("288940c7-28fd-45cd-a5f7-87eaeef4740d")]
+
+// 程序集的版本信息由下面四个值组成:
+//
+//      主版本
+//      次版本 
+//      生成号
+//      修订号
+//
+// 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
+// 方法是按如下所示使用“*”:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

+ 32 - 0
CSharp/CSharp.sln

@@ -68,6 +68,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RealmClient", "Client\Realm
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BossMonit", "App\BossMonit\BossMonit.csproj", "{E8C290C1-D4FE-44A5-81A2-507706CF7DF2}"
 EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Game", "Game", "{D0CC1FF4-2747-4278-A51F-BE9AA959175B}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Component", "Game\Component\Component.csproj", "{CBEDBE33-A883-4BFA-AE0A-8B3573F09BD0}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ComponentTest", "Game\ComponentTest\ComponentTest.csproj", "{F2BEB8B2-0D9B-4CD9-A4BD-AE8E00903A67}"
+EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Any CPU = Debug|Any CPU
@@ -324,6 +330,30 @@ Global
 		{E8C290C1-D4FE-44A5-81A2-507706CF7DF2}.Release|Mixed Platforms.Build.0 = Release|Any CPU
 		{E8C290C1-D4FE-44A5-81A2-507706CF7DF2}.Release|Win32.ActiveCfg = Release|Any CPU
 		{E8C290C1-D4FE-44A5-81A2-507706CF7DF2}.Release|x86.ActiveCfg = Release|Any CPU
+		{CBEDBE33-A883-4BFA-AE0A-8B3573F09BD0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{CBEDBE33-A883-4BFA-AE0A-8B3573F09BD0}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{CBEDBE33-A883-4BFA-AE0A-8B3573F09BD0}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+		{CBEDBE33-A883-4BFA-AE0A-8B3573F09BD0}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+		{CBEDBE33-A883-4BFA-AE0A-8B3573F09BD0}.Debug|Win32.ActiveCfg = Debug|Any CPU
+		{CBEDBE33-A883-4BFA-AE0A-8B3573F09BD0}.Debug|x86.ActiveCfg = Debug|Any CPU
+		{CBEDBE33-A883-4BFA-AE0A-8B3573F09BD0}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{CBEDBE33-A883-4BFA-AE0A-8B3573F09BD0}.Release|Any CPU.Build.0 = Release|Any CPU
+		{CBEDBE33-A883-4BFA-AE0A-8B3573F09BD0}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+		{CBEDBE33-A883-4BFA-AE0A-8B3573F09BD0}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+		{CBEDBE33-A883-4BFA-AE0A-8B3573F09BD0}.Release|Win32.ActiveCfg = Release|Any CPU
+		{CBEDBE33-A883-4BFA-AE0A-8B3573F09BD0}.Release|x86.ActiveCfg = Release|Any CPU
+		{F2BEB8B2-0D9B-4CD9-A4BD-AE8E00903A67}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{F2BEB8B2-0D9B-4CD9-A4BD-AE8E00903A67}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{F2BEB8B2-0D9B-4CD9-A4BD-AE8E00903A67}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+		{F2BEB8B2-0D9B-4CD9-A4BD-AE8E00903A67}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+		{F2BEB8B2-0D9B-4CD9-A4BD-AE8E00903A67}.Debug|Win32.ActiveCfg = Debug|Any CPU
+		{F2BEB8B2-0D9B-4CD9-A4BD-AE8E00903A67}.Debug|x86.ActiveCfg = Debug|Any CPU
+		{F2BEB8B2-0D9B-4CD9-A4BD-AE8E00903A67}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{F2BEB8B2-0D9B-4CD9-A4BD-AE8E00903A67}.Release|Any CPU.Build.0 = Release|Any CPU
+		{F2BEB8B2-0D9B-4CD9-A4BD-AE8E00903A67}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+		{F2BEB8B2-0D9B-4CD9-A4BD-AE8E00903A67}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+		{F2BEB8B2-0D9B-4CD9-A4BD-AE8E00903A67}.Release|Win32.ActiveCfg = Release|Any CPU
+		{F2BEB8B2-0D9B-4CD9-A4BD-AE8E00903A67}.Release|x86.ActiveCfg = Release|Any CPU
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE
@@ -350,5 +380,7 @@ Global
 		{15B3E0D2-6217-493A-A690-158C497F5318} = {4FF1FBF3-F552-4D3D-AD97-E29385069206}
 		{E62B0633-1767-44A0-9479-C8E9D19DA4B8} = {01501C44-C95B-45B7-A898-76B4A7AC4EE8}
 		{3EF3AE01-5EF3-4C5C-AB49-87BB9D06C007} = {5CE37ED4-1D86-4407-9471-DA41975FDA53}
+		{CBEDBE33-A883-4BFA-AE0A-8B3573F09BD0} = {D0CC1FF4-2747-4278-A51F-BE9AA959175B}
+		{F2BEB8B2-0D9B-4CD9-A4BD-AE8E00903A67} = {D0CC1FF4-2747-4278-A51F-BE9AA959175B}
 	EndGlobalSection
 EndGlobal

+ 64 - 0
CSharp/Game/Component/Component.csproj

@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{CBEDBE33-A883-4BFA-AE0A-8B3573F09BD0}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>Component</RootNamespace>
+    <AssemblyName>Component</AssemblyName>
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <RestorePackages>true</RestorePackages>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>..\..\Bin\</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="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\..\packages\Newtonsoft.Json.5.0.6\lib\net45\Newtonsoft.Json.dll</HintPath>
+    </Reference>
+    <Reference Include="System" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Runtime.Serialization" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Entity.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="Packages.config" />
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.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>

+ 43 - 0
CSharp/Game/Component/Entity.cs

@@ -0,0 +1,43 @@
+using System.Collections.Generic;
+using Newtonsoft.Json;
+
+namespace Component
+{
+	public class Entity
+	{
+		public int Id { get; set; }
+
+		public Dictionary<string, object> Values { get; private set; }
+
+		public Entity()
+		{
+			this.Values = new Dictionary<string, object>();
+		}
+
+		public object this[string key]
+		{
+			set
+			{
+				this.Values[key] = value;	
+			}
+			get
+			{
+				return this.Values[key];
+			}
+		}
+
+		public T Get<T>(string key)
+		{
+			if (!this.Values.ContainsKey(key))
+			{
+				throw new KeyNotFoundException(string.Format("not found key: {0}", key));
+			}
+			return (T)this.Values[key];
+		}
+
+		public bool Contain(string key)
+		{
+			return this.Values.ContainsKey(key);
+		}
+	}
+}

+ 4 - 0
CSharp/Game/Component/Packages.config

@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+  <package id="Newtonsoft.Json" version="5.0.6" targetFramework="net45" />
+</packages>

+ 36 - 0
CSharp/Game/Component/Properties/AssemblyInfo.cs

@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// 有关程序集的常规信息通过以下
+// 特性集控制。更改这些特性值可修改
+// 与程序集关联的信息。
+[assembly: AssemblyTitle("Component")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("Component")]
+[assembly: AssemblyCopyright("Copyright ©  2013")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// 将 ComVisible 设置为 false 使此程序集中的类型
+// 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型,
+// 则将该类型上的 ComVisible 特性设置为 true。
+[assembly: ComVisible(false)]
+
+// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
+[assembly: Guid("55cc5b17-d8c8-4c34-922c-47afac13d174")]
+
+// 程序集的版本信息由下面四个值组成:
+//
+//      主版本
+//      次版本 
+//      生成号
+//      修订号
+//
+// 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
+// 方法是按如下所示使用“*”:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

+ 97 - 0
CSharp/Game/ComponentTest/ComponentTest.csproj

@@ -0,0 +1,97 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{F2BEB8B2-0D9B-4CD9-A4BD-AE8E00903A67}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>ComponentTest</RootNamespace>
+    <AssemblyName>ComponentTest</AssemblyName>
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
+    <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
+    <IsCodedUITest>False</IsCodedUITest>
+    <TestProjectType>UnitTest</TestProjectType>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>..\..\Bin\</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="System" />
+  </ItemGroup>
+  <Choose>
+    <When Condition="('$(VisualStudioVersion)' == '10.0' or '$(VisualStudioVersion)' == '') and '$(TargetFrameworkVersion)' == 'v3.5'">
+      <ItemGroup>
+        <Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
+      </ItemGroup>
+    </When>
+    <Otherwise>
+      <ItemGroup>
+        <Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework" />
+      </ItemGroup>
+    </Otherwise>
+  </Choose>
+  <ItemGroup>
+    <Compile Include="EntityTest.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\..\Platform\Helper\Helper.csproj">
+      <Project>{24233cd5-a5df-484b-a482-b79cb7a0d9cb}</Project>
+      <Name>Helper</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\..\Platform\Log\Log.csproj">
+      <Project>{72e16572-fc1f-4a9e-bc96-035417239298}</Project>
+      <Name>Log</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\Component\Component.csproj">
+      <Project>{CBEDBE33-A883-4BFA-AE0A-8B3573F09BD0}</Project>
+      <Name>Component</Name>
+    </ProjectReference>
+  </ItemGroup>
+  <Choose>
+    <When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">
+      <ItemGroup>
+        <Reference Include="Microsoft.VisualStudio.QualityTools.CodedUITestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
+          <Private>False</Private>
+        </Reference>
+        <Reference Include="Microsoft.VisualStudio.TestTools.UITest.Common, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
+          <Private>False</Private>
+        </Reference>
+        <Reference Include="Microsoft.VisualStudio.TestTools.UITest.Extension, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
+          <Private>False</Private>
+        </Reference>
+        <Reference Include="Microsoft.VisualStudio.TestTools.UITesting, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
+          <Private>False</Private>
+        </Reference>
+      </ItemGroup>
+    </When>
+  </Choose>
+  <Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
+  <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>

+ 21 - 0
CSharp/Game/ComponentTest/EntityTest.cs

@@ -0,0 +1,21 @@
+using Component;
+using Helper;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace ComponentTest
+{
+	[TestClass]
+	public class EntityTest
+	{
+		[TestMethod]
+		public void TestSerialize()
+		{
+			var entity = new Entity();
+			entity["health"] = 10L;
+			string entityString = MongoHelper.ToJson(entity);
+
+			var entity2 = MongoHelper.FromJson<Entity>(entityString);
+			Assert.AreEqual(10, entity2.Get<long>("health"));
+		}
+	}
+}

+ 36 - 0
CSharp/Game/ComponentTest/Properties/AssemblyInfo.cs

@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// 有关程序集的常规信息通过以下特性集 
+// 控制。更改这些特性值可修改
+// 与程序集关联的信息。
+[assembly: AssemblyTitle("ComponentTest")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("ComponentTest")]
+[assembly: AssemblyCopyright("Copyright ©  2013")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// 将 ComVisible 设置为 false 会使此程序集中的类型 
+// 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型,
+// 请将该类型上的 ComVisible 特性设置为 true。
+[assembly: ComVisible(false)]
+
+// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
+[assembly: Guid("fb379d23-be2c-4b0f-a754-59a4a8d39c3a")]
+
+// 程序集的版本信息由以下四个值组成:
+//
+//      主版本
+//      次版本
+//      生成号
+//      修订号
+//
+// 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
+// 方法是按如下所示使用“*”:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

+ 9 - 0
CSharp/Platform/Helper/Helper.csproj

@@ -32,6 +32,14 @@
     <WarningLevel>4</WarningLevel>
   </PropertyGroup>
   <ItemGroup>
+    <Reference Include="MongoDB.Bson, Version=1.8.2.34, Culture=neutral, PublicKeyToken=f686731cfb9cc103, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\..\packages\mongocsharpdriver.1.8.2\lib\net35\MongoDB.Bson.dll</HintPath>
+    </Reference>
+    <Reference Include="MongoDB.Driver, Version=1.8.2.34, Culture=neutral, PublicKeyToken=f686731cfb9cc103, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\..\packages\mongocsharpdriver.1.8.2\lib\net35\MongoDB.Driver.dll</HintPath>
+    </Reference>
     <Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
       <SpecificVersion>False</SpecificVersion>
       <HintPath>..\..\packages\Newtonsoft.Json.5.0.6\lib\net45\Newtonsoft.Json.dll</HintPath>
@@ -57,6 +65,7 @@
     <Compile Include="TimeHelper.cs" />
     <Compile Include="XmlHelper.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="MongoHelper.cs" />
   </ItemGroup>
   <ItemGroup>
     <None Include="Packages.config" />

+ 28 - 0
CSharp/Platform/Helper/MongoHelper.cs

@@ -0,0 +1,28 @@
+using MongoDB.Bson;
+using MongoDB.Bson.Serialization;
+
+namespace Helper
+{
+	public static class MongoHelper
+	{
+		public static string ToJson(object obj)
+		{
+			return obj.ToJson();
+		}
+
+		public static T FromJson<T>(string str)
+		{
+			return BsonSerializer.Deserialize<T>(str);
+		}
+
+		public static byte[] ToBson(object obj)
+		{
+			return obj.ToBson();
+		}
+
+		public static T FromBson<T>(byte[] bytes)
+		{
+			return BsonSerializer.Deserialize<T>(bytes);
+		}
+	}
+}

+ 1 - 0
CSharp/Platform/Helper/Packages.config

@@ -1,5 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <packages>
+  <package id="mongocsharpdriver" version="1.8.2" targetFramework="net45" />
   <package id="Newtonsoft.Json" version="5.0.6" targetFramework="net45" />
   <package id="protobuf-net" version="2.0.0.640" targetFramework="net45" />
 </packages>