Skip to content

Commit

Permalink
init UWPDDD project!
Browse files Browse the repository at this point in the history
this project is used to test DDD and MVVM in UWP
  • Loading branch information
durow committed Oct 26, 2015
1 parent 1082fc8 commit 50ea2bd
Show file tree
Hide file tree
Showing 34 changed files with 1,321 additions and 0 deletions.
129 changes: 129 additions & 0 deletions UWPDDD/Domain/Domain.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.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>{545D7BB0-4512-4EF4-A9CC-0A868714A7CD}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Domain</RootNamespace>
<AssemblyName>Domain</AssemblyName>
<DefaultLanguage>zh-CN</DefaultLanguage>
<TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>
<TargetPlatformVersion>10.0.10240.0</TargetPlatformVersion>
<TargetPlatformMinVersion>10.0.10240.0</TargetPlatformMinVersion>
<MinimumVisualStudioVersion>14</MinimumVisualStudioVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM'">
<PlatformTarget>ARM</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\ARM\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<NoWarn>;2008</NoWarn>
<DebugType>full</DebugType>
<PlatformTarget>ARM</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|ARM'">
<PlatformTarget>ARM</PlatformTarget>
<OutputPath>bin\ARM\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<Optimize>true</Optimize>
<NoWarn>;2008</NoWarn>
<DebugType>pdbonly</DebugType>
<PlatformTarget>ARM</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<PlatformTarget>x64</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<NoWarn>;2008</NoWarn>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<PlatformTarget>x64</PlatformTarget>
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<Optimize>true</Optimize>
<NoWarn>;2008</NoWarn>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<NoWarn>;2008</NoWarn>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<PlatformTarget>x86</PlatformTarget>
<OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<Optimize>true</Optimize>
<NoWarn>;2008</NoWarn>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<ItemGroup>
<!-- A reference to the entire .Net Framework and Windows SDK are automatically included -->
<None Include="project.json" />
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Content Include="Properties\Domain.rd.xml" />
</ItemGroup>
<ItemGroup>
<Folder Include="Model\" />
<Folder Include="Repository\Common\" />
<Folder Include="Service\" />
</ItemGroup>
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '14.0' ">
<VisualStudioVersion>14.0</VisualStudioVersion>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.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>
29 changes: 29 additions & 0 deletions UWPDDD/Domain/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
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("Domain")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Domain")]
[assembly: AssemblyCopyright("Copyright © 2015")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// 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")]
[assembly: ComVisible(false)]
33 changes: 33 additions & 0 deletions UWPDDD/Domain/Properties/Domain.rd.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
This file contains Runtime Directives, specifications about types your application accesses
through reflection and other dynamic code patterns. Runtime Directives are used to control the
.NET Native optimizer and ensure that it does not remove code accessed by your library. If your
library does not do any reflection, then you generally do not need to edit this file. However,
if your library reflects over types, especially types passed to it or derived from its types,
then you should write Runtime Directives.
The most common use of reflection in libraries is to discover information about types passed
to the library. Runtime Directives have three ways to express requirements on types passed to
your library.
1. Parameter, GenericParameter, TypeParameter, TypeEnumerableParameter
Use these directives to reflect over types passed as a parameter.
2. SubTypes
Use a SubTypes directive to reflect over types derived from another type.
3. AttributeImplies
Use an AttributeImplies directive to indicate that your library needs to reflect over
types or methods decorated with an attribute.
For more information on writing Runtime Directives for libraries, please visit
http://go.microsoft.com/fwlink/?LinkID=391919
-->
<Directives xmlns="http://schemas.microsoft.com/netfx/2013/01/metadata">
<Library Name="Domain">

<!-- add directives for your library here -->

</Library>
</Directives>
16 changes: 16 additions & 0 deletions UWPDDD/Domain/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"dependencies": {
"Microsoft.NETCore.UniversalWindowsPlatform": "5.0.0"
},
"frameworks": {
"uap10.0": {}
},
"runtimes": {
"win10-arm": {},
"win10-arm-aot": {},
"win10-x86": {},
"win10-x86-aot": {},
"win10-x64": {},
"win10-x64-aot": {}
}
}
64 changes: 64 additions & 0 deletions UWPDDD/Infrastructure/Database/ACategoryData.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
using SQLitePCL;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Infrastructure.Database
{
public sealed class ACategoryData
{
ISQLiteConnection con;

public void Delete(int id)
{
const string DELETE_SQL = @"DELETE FROM ACategory WHERE ID=?";
using (var statement = con.Prepare(DELETE_SQL))
{
statement.Bind(1, id);
statement.Step();
}
}

public IEnumerable<Dictionary<string,object>> GetAll()
{
const string GETALL_SQL = @"SELECT ID,Category
FROM ACategory";
using (var statement = con.Prepare(GETALL_SQL))
{
while (statement.Step() == SQLiteResult.ROW)
{
var dict = new Dictionary<string, object>();
for (int i = 0; i < statement.ColumnCount; i++)
{
dict.Add(statement.ColumnName(i), statement[i]);
}
yield return dict;
}
}
}

public void Insert(string category)
{
const string INSERT_SQL = @"INSERT INTO ACategory(Category) VALUES(?)";
using (var statement = con.Prepare(INSERT_SQL))
{
statement.Bind(1, category);
statement.Step();
}
}

public void Update(int id,string category)
{
const string UPDATE_SQL = @"UPDATE ACategory
SET Category=?
WHERE ID=?";
using (var statement = con.Prepare(UPDATE_SQL))
{
statement.Bind(1, id);
statement.Bind(2, category);
}
}
}
}
85 changes: 85 additions & 0 deletions UWPDDD/Infrastructure/Database/ANoteData.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
using SQLitePCL;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Infrastructure.Database
{
public sealed class ANoteData
{
ISQLiteConnection con;

public ANoteData(ISQLiteConnection connection)
{
con = connection;
}

public void DeleteRowByID(int id)
{
const string DELETE_SQL = @"DELETE FROM ANote WHERE ID=?";
using (var statement = con.Prepare(DELETE_SQL))
{
statement.Bind(1, id);
statement.Step();
}
}

public IEnumerable<Dictionary<string,object>> GetAll()
{
const string GETALL_SQL = @"SELECT ID,AddDateTime,EditDateTime,Title,Content, Category
FROM ANote,ACategory
WHERE Anote.CategoryID=Acategory.ID";
using (var statement = con.Prepare(GETALL_SQL))
{
while (statement.Step() == SQLiteResult.ROW)
{
var dict = new Dictionary<string, object>();
for (int i = 0; i < statement.ColumnCount; i++)
{
dict.Add(statement.ColumnName(i), statement[i]);
}
yield return dict;
}
}
}

public void Insert(string addDateTime,
string editDateTime,
string title,
string content,
int categoryID)
{
const string INSERT_SQL = @"INSERT INTO ANote(AddDateTime,EditDateTime,Title,Content,CategoryID) VALUES(?,?,?,?,?)";
using (var statement = con.Prepare(INSERT_SQL))
{
statement.Bind(1, addDateTime);
statement.Bind(2, editDateTime);
statement.Bind(3, title);
statement.Bind(4, content);
statement.Bind(5, categoryID);
statement.Step();
}
}

public void Update(int id,
string editDateTime,
string title,
string content,
int categoryID)
{
const string UPDATE_SQL = @"UPDATE ANote
SET EditDateTime=?,Title=?,Content=?,CategoryID=?
WHERE ID=?";
using (var statement = con.Prepare(UPDATE_SQL))
{
statement.Bind(1, editDateTime);
statement.Bind(2, title);
statement.Bind(3, content);
statement.Bind(4, categoryID);
statement.Bind(5, id);
}
}
}
}
Loading

0 comments on commit 50ea2bd

Please sign in to comment.