Skip to content

Commit

Permalink
Merge pull request #13 from mocoding-software/split
Browse files Browse the repository at this point in the history
Extracted file storage to target NetStandard 1.0
  • Loading branch information
offbeatful committed Jan 11, 2017
2 parents 453a48b + fbccfc1 commit 2d17c51
Show file tree
Hide file tree
Showing 20 changed files with 231 additions and 80 deletions.
23 changes: 23 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (console)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceRoot}/examples/ConsoleApp/bin/Debug/netcoreapp1.0/ConsoleApp.dll",
"args": [],
"cwd": "${workspaceRoot}",
"externalConsole": false,
"stopAtEntry": false,
"internalConsoleOptions": "openOnSessionStart"
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command.pickProcess}"
}
]
}
16 changes: 16 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"version": "0.1.0",
"command": "dotnet",
"isShellCommand": true,
"args": [],
"tasks": [
{
"taskName": "build",
"args": [
"${workspaceRoot}/examples/ConsoleApp/project.json"
],
"isBuildCommand": true,
"problemMatcher": "$msCompile"
}
]
}
36 changes: 24 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Easy-Doc-Db

![Build Status]
(https://mocoding.visualstudio.com/_apis/public/build/definitions/6a316467-5a7a-41a0-98fb-959a5b880ab1/21/badge)
![Build Status](https://mocoding.visualstudio.com/_apis/public/build/definitions/da7703d4-fb22-4933-b869-83f4264b7b84/29/badge)
[![NuGet version](https://badge.fury.io/nu/Mocoding.EasyDocDb.svg)](https://www.nuget.org/packages/Mocoding.EasyDocDb)

easy-doc-db - is a simple yet extendable .NET Core library that allows one to have embedded document storage. The lib allows working with documents in two modes: single document and collection of documents. It is best suited for small or medium-sized projects with limited or predictably small amount of data.
easy-doc-db - embedded nosql document storage database for .NET. It is best suited for small or medium-sized projects with limited or predictably small amount of data. All data are kept in memmory while changes are constantly persisted to specified storage as json, xml or yaml formatted documents.

Key benefits:
- Read optimized
Expand All @@ -14,7 +14,7 @@ Key benefits:
Demo:

```cs
IRepository repository = new Repository(new JsonSerializer();
IRepository repository = new Repository(new JsonSerializer(),new EmbeddedStorage());
var users = await repository.InitCollection<User>("../data/users");

// read all
Expand All @@ -30,7 +30,6 @@ await newUser.Save();
//...
//delete
await newUser.Delete();

```

"../data/users" – path for storing a collection of documents.
Expand All @@ -42,10 +41,12 @@ Please see more demo in the examples folder.

We support next platforms:

- .NET 4.5.1
- .NET Core 1.0
- .NET Standard 1.0 for Core Library and JSON/XML/YAML Serialializers
- .NET Standard 1.3 for FileSystem Repsitory

Supporting .NET Standard 1.0 is essential since it is supported by widest range of target platforms including Xamarin, .NET Core and native .NET Framework.

## Documentation
## Usage Details

IRepository supports working with a single document or collection of documents.

Expand All @@ -57,8 +58,8 @@ Task<IDocument<T>> Init<T>(string conn) where T : class, new();
```cs
Task<IDocumentCollection<T>> InitCollection<T>(string conn) where T : class, new();
```
- will create a new folder at the location specified by the input parameter. All files will go there using the following format: {guid}.{format}.

- will create a new folder at the location specified by the input parameter.
All files will go there using the following format: {guid}.{format}.

IDocumentCollection provides access to all documents and allows creating a new one.

Expand Down Expand Up @@ -100,8 +101,9 @@ public interface IDocumentSerializer

### Storage

By default, documents are embedded and stored to one of your local folders. The default behavior could be overridden by a custom implementation of IDocumentStorage interface.
Below, we will show you methods for reading, writing, deleting and other operations with document.
Mocoding.EasyDocDb.FileSystem provides default implementation that stores documents to one of your local folders.
The default behavior could be overridden by a custom implementation of IDocumentStorage interface.
Below, we will show ysou methods for reading, writing, deleting and other operations with document.

```cs
public interface IDocumentStorage
Expand All @@ -114,3 +116,13 @@ public interface IDocumentStorage
}
```

## Contributions

All source code is located in ```src``` folder. Tests are in ```test``` folder. You will need Visual Studio 2015 Update 3.
You may use examples to play with and/or improve existing code base.

## Contact Us

Our website: [http://mocoding.com](http://mocoding.com)

Email: [social@mocoding.com](mailto:social@mocoding.com)
7 changes: 7 additions & 0 deletions easy-doc-db.sln
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{08BCCC57-3
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Mocoding.EasyDocDb.Tests", "test\Mocoding.EasyDocDb.Tests\Mocoding.EasyDocDb.Tests.xproj", "{8545C6C3-4033-42BF-A673-2826953DB7B7}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Mocoding.EasyDocDb.FileSystem", "src\Mocoding.EasyDocDb.FileSystem\Mocoding.EasyDocDb.FileSystem.xproj", "{F818ECAF-CBC8-4A48-A8A3-F54025000BE2}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -63,6 +65,10 @@ Global
{8545C6C3-4033-42BF-A673-2826953DB7B7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8545C6C3-4033-42BF-A673-2826953DB7B7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8545C6C3-4033-42BF-A673-2826953DB7B7}.Release|Any CPU.Build.0 = Release|Any CPU
{F818ECAF-CBC8-4A48-A8A3-F54025000BE2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F818ECAF-CBC8-4A48-A8A3-F54025000BE2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F818ECAF-CBC8-4A48-A8A3-F54025000BE2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F818ECAF-CBC8-4A48-A8A3-F54025000BE2}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -75,5 +81,6 @@ Global
{AD43118E-4CBE-4FF7-BEE3-6E134F1292EE} = {DCC49379-7DBF-4519-A71D-42611C3578CD}
{19DB5C14-B404-4736-AD3C-CE8352142D4E} = {DCC49379-7DBF-4519-A71D-42611C3578CD}
{8545C6C3-4033-42BF-A673-2826953DB7B7} = {08BCCC57-3049-4921-AE52-B9CE671E1F82}
{F818ECAF-CBC8-4A48-A8A3-F54025000BE2} = {926E5B6B-7208-4093-B1BD-3D38BA3135BB}
EndGlobalSection
EndGlobal
3 changes: 2 additions & 1 deletion examples/ConsoleApp/Program.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Threading.Tasks;
using Mocoding.EasyDocDb.FileSystem;
using Mocoding.EasyDocDb.Json;

namespace Mocoding.EasyDocDb.ConsoleApp
Expand All @@ -8,7 +9,7 @@ public class Program
{
public static void Main(string[] args)
{
IRepository repository = new Repository(new JsonSerializer());
IRepository repository = new EmbeddedRepository(new JsonSerializer());
var task = repository.Init<User>("UserData.Json");
task.Wait();
var doc = task.Result;
Expand Down
3 changes: 3 additions & 0 deletions examples/ConsoleApp/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
"Mocoding.EasyDocDb": {
"target": "project"
},
"Mocoding.EasyDocDb.FileSystem": {
"target": "project"
},
"Mocoding.EasyDocDb.Json": {
"target": "project"
},
Expand Down
3 changes: 2 additions & 1 deletion examples/WebApp/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Mocoding.EasyDocDb;
using Mocoding.EasyDocDb.FileSystem;
using Mocoding.EasyDocDb.Json;

namespace EasyDocDb.WebApplication
Expand Down Expand Up @@ -34,7 +35,7 @@ public Startup(IHostingEnvironment env)
public void ConfigureServices(IServiceCollection services)
{
// Add framework services.
IRepository repository = new Repository(new JsonSerializer());
IRepository repository = new EmbeddedRepository(new JsonSerializer());
var users = repository.InitCollection<User>("UsersData");
users.Wait();
services.AddSingleton(users.Result);
Expand Down
3 changes: 3 additions & 0 deletions examples/WebApp/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
"Mocoding.EasyDocDb": {
"target": "project"
},
"Mocoding.EasyDocDb.FileSystem": {
"target": "project"
},
"Mocoding.EasyDocDb.Json": {
"target": "project"
},
Expand Down
15 changes: 15 additions & 0 deletions src/Mocoding.EasyDocDb.FileSystem/EmbeddedRepository.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
namespace Mocoding.EasyDocDb.FileSystem
{
public class EmbeddedRepository : Repository
{
public EmbeddedRepository(IDocumentSerializer serializer)
: base(serializer, new EmbeddedStorage())
{
}

public EmbeddedRepository(IDocumentSerializer serializer, IDocumentStorage storage)
: base(serializer, storage)
{
}
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;

namespace Mocoding.EasyDocDb.Core
[assembly: InternalsVisibleTo("Mocoding.EasyDocDb.Tests")]
namespace Mocoding.EasyDocDb.FileSystem
{
internal class EmbeddedStorage : IDocumentStorage
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<ProjectGuid>f818ecaf-cbc8-4a48-a8a3-f54025000be2</ProjectGuid>
<RootNamespace>Mocoding.EasyDocDb.FileSystem</RootNamespace>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
</PropertyGroup>
<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>
31 changes: 31 additions & 0 deletions src/Mocoding.EasyDocDb.FileSystem/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"version": "2.0.0",
"description": "Embedded storage for EasyDocDb - stores documents as files on a local drive.",
"packOptions": {
"summary": "Implementation of IRepository for EasyDocDb that stores document files locally.",
"tags": [ "netcore", "embedded", "database", "document db", "nosql", "docdb", "json", "serializer" ],
"owners": [ "MOCODING, LLC" ],
"releaseNotes": "Extracted from Core library. Added support for .NetStandard 1.3",
"projectUrl": "https://github.com/mocoding-software/easy-doc-db",
"iconUrl": "https://mocoding.blob.core.windows.net/resources/easy-doc-db/nugetIcon.png",
"licenseUrl": "https://raw.githubusercontent.com/mocoding-software/easy-doc-db/master/LICENSE",
"requireLicenseAcceptance": false,
"repository": {
"type": "git",
"url": "https://github.com/mocoding-software/easy-doc-db"
}
},
"buildOptions": {
"additionalArguments": [ "/ruleset:../../_stylecop/StyleCop.ruleset" ]
},
"frameworks": {
"netstandard1.3": { }
},
"dependencies": {
"System.IO.FileSystem": "4.3.0",
"Mocoding.EasyDocDb": {
"target": "project"
},
"StyleCop.Analyzers": "1.0.0"
}
}
25 changes: 15 additions & 10 deletions src/Mocoding.EasyDocDb.Json/project.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
{
"version": "1.3.1",
"version": "2.0.0",
"description": "Json Serializer for EasyDocDb - simple and easy to use embedded document database for .NET Core applications.",
"packOptions": {
"summary": "Json serializer for embedded document database for .NET applications. Serializes documents to json files.",
"tags": [ "netcore", "embedded", "database", "document db", "nosql", "docdb", "json", "serializer" ],
"owners": [ "Mocoding" ],
"releaseNotes": "Dropping support for WinRT. Adding support for portable library.",
"tags": [
"net core",
"netstandard",
"embedded",
"database",
"document db",
"storage",
"nosql",
"docdb",
"json"
],
"owners": [ "MOCODING, LLC" ],
"releaseNotes": "Added support for .NetStandard 1.0",
"projectUrl": "https://github.com/mocoding-software/easy-doc-db",
"iconUrl": "https://mocoding.blob.core.windows.net/resources/easy-doc-db/nugetIcon.png",
"licenseUrl": "https://raw.githubusercontent.com/mocoding-software/easy-doc-db/master/LICENSE",
Expand All @@ -19,12 +29,7 @@
"additionalArguments": [ "/ruleset:../../_stylecop/StyleCop.ruleset" ]
},
"frameworks": {
"netstandard1.3": {
"imports": [
"dotnet5.6",
"portable-net45+win8+wpa81"
]
}
"netstandard1.0": { }
},
"dependencies": {
"Newtonsoft.Json": "9.0.1",
Expand Down
29 changes: 16 additions & 13 deletions src/Mocoding.EasyDocDb.Xml/project.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
{
"version": "1.3.1",
"version": "2.0.0",
"description": "Xml Serializer for EasyDocDb - simple and easy to use embedded document database for .NET Core applications.",
"packOptions": {
"summary": "Xml serializer for embedded document database for .NET applications. Serializes documents to xml files.",
"tags": [ "netcore", "embedded", "database", "document db", "nosql", "docdb", "xml", "serializer" ],
"owners": [ "Mocoding" ],
"releaseNotes": "Dropping support for WinRT. Adding support for portable library.",
"tags": [
"net core",
"netstandard",
"embedded",
"database",
"document db",
"storage",
"nosql",
"docdb",
"json"
],
"owners": [ "MOCODING, LLC" ],
"releaseNotes": "Added support for .NetStandard 1.0",
"projectUrl": "https://github.com/mocoding-software/easy-doc-db",
"iconUrl": "https://mocoding.blob.core.windows.net/resources/easy-doc-db/nugetIcon.png",
"licenseUrl": "https://raw.githubusercontent.com/mocoding-software/easy-doc-db/master/LICENSE",
Expand All @@ -16,20 +26,13 @@
}
},
"frameworks": {
"netstandard1.3": {
"imports": [
"dotnet5.6",
"portable-net45+win8+wpa81"
],
"dependencies": {
"System.Xml.XmlSerializer": "4.3.0"
}
}
"netstandard1.0": { }
},
"buildOptions": {
"additionalArguments": [ "/ruleset:../../_stylecop/StyleCop.ruleset" ]
},
"dependencies": {
"System.Xml.XmlSerializer": "4.3.0",
"Mocoding.EasyDocDb": {
"target": "project"
},
Expand Down
Loading

0 comments on commit 2d17c51

Please sign in to comment.