-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TaskyPro] split into separate 'shared-code' examples: Portable, Link…
…ed, Cloned
- Loading branch information
1 parent
8965253
commit 1e9b4d6
Showing
223 changed files
with
14,284 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+532 KB
TaskyProCloned/Dependencies/Community.CsharpSqlite/Community.CsharpSqlite.WP7.dll
Binary file not shown.
Binary file added
BIN
+1.07 MB
TaskyProCloned/Dependencies/Community.CsharpSqlite/Community.CsharpSqlite.WP7.pdb
Binary file not shown.
Binary file added
BIN
+458 KB
...Cloned/Dependencies/Microsoft.Phone.Controls.Toolkit/Microsoft.Phone.Controls.Toolkit.dll
Binary file not shown.
Binary file added
BIN
+716 KB
...Cloned/Dependencies/Microsoft.Phone.Controls.Toolkit/Microsoft.Phone.Controls.Toolkit.pdb
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
The Tasky.Core library is the reusable portion of the Tasky application. It contains the Business | ||
Layer (BL), Data Access Layer (DAL), and Data Layer (DL). All of the Tasky.Core code is shared between | ||
the iOS and Android versions of the application without modification. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
Business Layer (BL) | ||
=================== | ||
Sometimes also called the Business Logic Layer (BLL), the BL contains entitiy definitions and | ||
business logic. | ||
|
||
Business Entities | ||
----------------- | ||
Business entites are classes that represent real-world objects. They're the core of | ||
Object-Oriented-Programming (OOP). | ||
|
||
Manager Classes | ||
--------------- | ||
In this particular architecture, we're using the façade pattern (like we did with the DAL) | ||
which is represented by static Manager classes. The manager classes are an abstraction on | ||
the DAL and SAL layers and perform any business logic. |
20 changes: 20 additions & 0 deletions
20
TaskyProCloned/Tasky.Core.Cloned/BL/Contracts/BusinessEntityBase.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using System; | ||
using Tasky.DL.SQLite; | ||
|
||
namespace Tasky.BL.Contracts { | ||
/// <summary> | ||
/// Business entity base class. Provides the ID property. | ||
/// </summary> | ||
public abstract class BusinessEntityBase : IBusinessEntity { | ||
public BusinessEntityBase () | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Gets or sets the Database ID. | ||
/// </summary> | ||
[PrimaryKey, AutoIncrement] | ||
public int ID { get; set; } | ||
} | ||
} | ||
|
8 changes: 8 additions & 0 deletions
8
TaskyProCloned/Tasky.Core.Cloned/BL/Contracts/IBusinessEntity.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
using System; | ||
|
||
namespace Tasky.BL.Contracts { | ||
public interface IBusinessEntity { | ||
int ID { get; set; } | ||
} | ||
} | ||
|
34 changes: 34 additions & 0 deletions
34
TaskyProCloned/Tasky.Core.Cloned/BL/Managers/TaskManager.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using Tasky.BL; | ||
|
||
namespace Tasky.BL.Managers | ||
{ | ||
public static class TaskManager | ||
{ | ||
static TaskManager () | ||
{ | ||
} | ||
|
||
public static Task GetTask(int id) | ||
{ | ||
return DAL.TaskRepository.GetTask(id); | ||
} | ||
|
||
public static IList<Task> GetTasks () | ||
{ | ||
return new List<Task>(DAL.TaskRepository.GetTasks()); | ||
} | ||
|
||
public static int SaveTask (Task item) | ||
{ | ||
return DAL.TaskRepository.SaveTask(item); | ||
} | ||
|
||
public static int DeleteTask(int id) | ||
{ | ||
return DAL.TaskRepository.DeleteTask(id); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using System; | ||
using Tasky.BL.Contracts; | ||
using Tasky.DL.SQLite; | ||
|
||
namespace Tasky.BL | ||
{ | ||
/// <summary> | ||
/// Represents a Task. | ||
/// </summary> | ||
public class Task : IBusinessEntity | ||
{ | ||
public Task () | ||
{ | ||
} | ||
|
||
[PrimaryKey, AutoIncrement] | ||
public int ID { get; set; } | ||
public string Name { get; set; } | ||
public string Notes { get; set; } | ||
// new property | ||
public bool Done { get; set; } | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Data Access Layer (DAL) | ||
======================= | ||
The data access layer is responsible for providing an abstraction to the data layer. It makes | ||
sure that no matter what technology(ies) are used for data persistance, a single entry point | ||
that is technology agnostic exists. | ||
|
||
Often, the façade pattern is used, and many times the underlying data persistence technology is | ||
actually more than one. for example, you might have some data store in xml, other data stored in | ||
a SQL database, etc. The DAL makes sure that any complexity associated with accessing and aggregating | ||
these technologies is isolated from the rest of the application. | ||
|
||
The DAL is also considered a sibling to the Service Access Layer (SAL), which is responsible for | ||
access to cloud services, and other network related resources. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using Tasky.BL; | ||
|
||
namespace Tasky.DAL { | ||
public class TaskRepository { | ||
DL.TaskDatabase db = null; | ||
protected static string dbLocation; | ||
protected static TaskRepository me; | ||
|
||
static TaskRepository () | ||
{ | ||
me = new TaskRepository(); | ||
} | ||
|
||
protected TaskRepository() | ||
{ | ||
// set the db location | ||
dbLocation = DatabaseFilePath; | ||
|
||
// instantiate the database | ||
db = new Tasky.DL.TaskDatabase(dbLocation); | ||
} | ||
|
||
public static string DatabaseFilePath { | ||
get { | ||
var sqliteFilename = "TaskDB.db3"; | ||
#if SILVERLIGHT | ||
// Windows Phone expects a local path, not absolute | ||
var path = sqliteFilename; | ||
#else | ||
|
||
#if __ANDROID__ | ||
// Just use whatever directory SpecialFolder.Personal returns | ||
string libraryPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal); ; | ||
#else | ||
// we need to put in /Library/ on iOS5.1 to meet Apple's iCloud terms | ||
// (they don't want non-user-generated data in Documents) | ||
string documentsPath = Environment.GetFolderPath (Environment.SpecialFolder.Personal); // Documents folder | ||
string libraryPath = Path.Combine (documentsPath, "../Library/"); // Library folder | ||
#endif | ||
var path = Path.Combine (libraryPath, sqliteFilename); | ||
#endif | ||
return path; | ||
} | ||
} | ||
|
||
public static Task GetTask(int id) | ||
{ | ||
return me.db.GetItem<Task>(id); | ||
} | ||
|
||
public static IEnumerable<Task> GetTasks () | ||
{ | ||
return me.db.GetItems<Task>(); | ||
} | ||
|
||
public static int SaveTask (Task item) | ||
{ | ||
return me.db.SaveItem<Task>(item); | ||
} | ||
|
||
public static int DeleteTask(int id) | ||
{ | ||
return me.db.DeleteItem<Task>(id); | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Data Layer: | ||
=========== | ||
The data layer is typically the lowest level layer of an application. Typically it consists | ||
of data persistence/retreival code. In this particular application, it contains two classes: | ||
- SQLite.cs | ||
- TaskDatabase.cs | ||
|
||
SQLite | ||
------ | ||
This is the SQLite.NET library, created by Frank Krueger. It's a lightweight Object Relational | ||
Model (ORM) that allows you to define your database schema via classes and automatically | ||
handles the nitty gritty of data persistance and retrieval into/from SQLite as well as actual | ||
database creation. It also has limited support for LINQ queries. | ||
|
||
TaskDatabase | ||
------------ | ||
TaskDatabase builds on SQLite.Net and represents a specific database, in our case, the Task DB. | ||
It contains methods for retreival and persistance as well as db creation, all based on the | ||
underlying ORM. |
Oops, something went wrong.