Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
azabluda committed Oct 16, 2017
2 parents acddf60 + 051b00d commit dd358f8
Show file tree
Hide file tree
Showing 104 changed files with 1,252 additions and 183 deletions.
14 changes: 6 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@


### Description:
InfoCarrier.Core is a framework developed by [on/off it-solutions gmbh](http://www.onoff-it-solutions.info) for building multitier applications in .NET. This repository contains the key data access component of the framework which essentially is a non-relational provider for [Entity Framework Core](https://github.com/aspnet/EntityFramework) which can be deployed on the client-side of your 3-tier application allowing you to use the full power of EF.Core right in your client application (e.g. WPF, WinForms, etc). The main idea is that instead of querying the relational database the commands are translated into requests to your application server where they are executed against the real database.
InfoCarrier.Core is a framework developed by [on/off it-solutions gmbh](http://www.onoff-it-solutions.info) for building multitier applications in .NET. This repository contains the key data access component of the framework which essentially is a non-relational provider for [Entity Framework Core](https://github.com/aspnet/EntityFramework) which can be deployed on the client-side of your 3-tier application allowing you to use the full power of EF.Core right in your client application (e.g. WPF, WinForms, Xamarin, UWP, etc). The main idea is that instead of querying the relational database the commands are translated into requests to your application server where they are executed against the real database.

It is important to note that InfoCarrier.Core dictates neither the communication platform nor serialization framework. We had positive experience with [WCF](https://msdn.microsoft.com/en-us/library/ms731082.aspx) and [Json.NET](http://www.newtonsoft.com/json), but you are free to choose other frameworks and libraries. InfoCarrier.Core is only responsible for translating client commands into serializable objects, leaving it up to you how to deliver them to the server for actual execution. The same is valid for the execution results.

Expand All @@ -32,7 +32,7 @@ InfoCarrier.Core is bringing together the following open source projects

## Sample

The complete WCF sample is located in the [/sample](https://github.com/azabluda/InfoCarrier.Core/tree/develop/sample) folder.
The complete WCF sample is located in the [/sample](sample) folder.

### Entities and DbContext

Expand Down Expand Up @@ -62,18 +62,16 @@ public class BloggingContext : DbContext

Implement `IInfoCarrierBackend` interface, e.g. using Windows Communication Foundation
```C#
using IC = InfoCarrier.Core.Common;

public class WcfBackendImpl : IInfoCarrierBackend
{
private readonly ChannelFactory<IMyRemoteService> channelFactory
= new ChannelFactory<IMyRemoteService>(...);

// Service URL string (used for logging)
// Gets the remote server address. Used for logging.
public string ServerUrl
=> this.channelFactory.Endpoint.Address.ToString();

public IC.QueryDataResult QueryData(IC.QueryDataRequest request, DbContext dbContext)
public QueryDataResult QueryData(QueryDataRequest request, DbContext dbContext)
{
IMyRemoteService channel = this.channelFactory.CreateChannel();
using ((IDisposable)channel)
Expand All @@ -82,7 +80,7 @@ public class WcfBackendImpl : IInfoCarrierBackend
}
}

public IC.SaveChangesResult SaveChanges(IC.SaveChangesRequest request, IReadOnlyList<IUpdateEntry> entries)
public SaveChangesResult SaveChanges(SaveChangesRequest request, IReadOnlyList<IUpdateEntry> entries)
{
IMyRemoteService channel = this.channelFactory.CreateChannel();
using ((IDisposable)channel)
Expand All @@ -91,7 +89,7 @@ public class WcfBackendImpl : IInfoCarrierBackend
}
}

// Other methods of IInfoCarrierBackend may just throw NotImplementedException for now
// Let other methods of IInfoCarrierBackend just throw NotSupportedException for now.
...
}
```
Expand Down
17 changes: 1 addition & 16 deletions Style.ruleset
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,11 @@
<Rule Id="IDE1005" Action="Warning" />
</Rules>
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers">
<Rule Id="SA0001" Action="None" />
<Rule Id="SA1117" Action="Warning" />
<Rule Id="SA1118" Action="Info" />
<Rule Id="SA1202" Action="Info" />
<Rule Id="SA1204" Action="Info" />
<Rule Id="SA1214" Action="Info" />
<Rule Id="SA1215" Action="Info" />
<Rule Id="SA1600" Action="None" />
<Rule Id="SA1601" Action="None" />
<Rule Id="SA1602" Action="None" />
<Rule Id="SA1604" Action="None" />
<Rule Id="SA1606" Action="None" />
<Rule Id="SA1611" Action="None" />
<Rule Id="SA1614" Action="None" />
<Rule Id="SA1615" Action="None" />
<Rule Id="SA1616" Action="None" />
<Rule Id="SA1618" Action="None" />
<Rule Id="SA1619" Action="None" />
<Rule Id="SA1622" Action="None" />
<Rule Id="SA1633" Action="None" />
<Rule Id="SA1652" Action="None" />
</Rules>
</RuleSet>
</RuleSet>
8 changes: 8 additions & 0 deletions StyleNoDoc.ruleset
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<RuleSet Name="InfoCarrier.Core.NoDoc" Description=" " ToolsVersion="14.0">
<Include Path="style.ruleset" Action="Default" />
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers">
<Rule Id="SA0001" Action="None" />
<Rule Id="SA1600" Action="None" />
</Rules>
</RuleSet>
2 changes: 1 addition & 1 deletion license.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2017 Alexander Zabluda
Copyright (c) 2017 on/off it-solutions gmbh

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
19 changes: 12 additions & 7 deletions sample/WcfSample.Client/Program.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
namespace WcfSample
// Copyright (c) on/off it-solutions gmbh. All rights reserved.
// Licensed under the MIT license. See license.txt file in the project root for license information.

namespace WcfSample
{
using System;
using System.Collections.Generic;
using System.Linq;
using InfoCarrier.Core.Client;
using Microsoft.EntityFrameworkCore;
using System.Linq;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.Extensions.Logging;

class Program
internal class Program
{
static void Main(string[] args)
private static void Main(string[] args)
{
Console.WriteLine(@"Wait until the server is ready, then press any key to start.");
Console.ReadKey();
Expand All @@ -21,7 +24,9 @@ static void Main(string[] args)

// Activate console logging
using (var context = new BloggingContext(options))
context.GetService<ILoggerFactory>().AddConsole((_, __) => true);
{
context.GetService<ILoggerFactory>().AddConsole((msg, level) => true);
}

// Seed database
using (var context = new BloggingContext(options))
Expand All @@ -32,8 +37,8 @@ static void Main(string[] args)
Owner = new User { Name = "hi-its-me" },
Posts = new List<Post>
{
new Post { Title = "my-blog-post" }
}
new Post { Title = "my-blog-post" },
},
});

context.SaveChanges();
Expand Down
24 changes: 14 additions & 10 deletions sample/WcfSample.Client/WcfBackendImpl.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
namespace WcfSample
// Copyright (c) on/off it-solutions gmbh. All rights reserved.
// Licensed under the MIT license. See license.txt file in the project root for license information.

namespace WcfSample
{
using System;
using System.ServiceModel;
using System.Threading;
using System.Threading.Tasks;
using InfoCarrier.Core.Client;
using InfoCarrier.Core.Common;
Expand All @@ -14,7 +18,7 @@ private readonly ChannelFactory<IMyRemoteService> channelFactory
new BasicHttpBinding(),
new EndpointAddress(new Uri(WcfShared.UriString)));

// Service URL string (used for logging)
// Gets the remote server address. Used for logging.
public string ServerUrl
=> this.channelFactory.Endpoint.Address.ToString();

Expand All @@ -36,18 +40,18 @@ public SaveChangesResult SaveChanges(SaveChangesRequest request)
}
}

public Task<QueryDataResult> QueryDataAsync(QueryDataRequest request, DbContext dbContext)
=> throw new NotImplementedException();
public Task<QueryDataResult> QueryDataAsync(QueryDataRequest request, DbContext dbContext, CancellationToken cancellationToken)
=> throw new NotSupportedException();

public Task<SaveChangesResult> SaveChangesAsync(SaveChangesRequest request)
=> throw new NotImplementedException();
public Task<SaveChangesResult> SaveChangesAsync(SaveChangesRequest request, CancellationToken cancellationToken)
=> throw new NotSupportedException();

public void BeginTransaction() => throw new NotImplementedException();
public void BeginTransaction() => throw new NotSupportedException();

public Task BeginTransactionAsync() => throw new NotImplementedException();
public Task BeginTransactionAsync(CancellationToken cancellationToken) => throw new NotSupportedException();

public void CommitTransaction() => throw new NotImplementedException();
public void CommitTransaction() => throw new NotSupportedException();

public void RollbackTransaction() => throw new NotImplementedException();
public void RollbackTransaction() => throw new NotSupportedException();
}
}
10 changes: 10 additions & 0 deletions sample/WcfSample.Client/WcfSample.Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,21 @@
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.0</TargetFramework>
<RootNamespace>WcfSample</RootNamespace>
<CodeAnalysisRuleSet>..\..\StyleNoDoc.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>

<ItemGroup>
<AdditionalFiles Include="..\..\stylecop.json">
<Link>stylecop.json</Link>
</AdditionalFiles>
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="2.0.0" />
<PackageReference Include="System.ServiceModel.Http" Version="4.4.0" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.0-beta004">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
Expand Down
7 changes: 5 additions & 2 deletions sample/WcfSample.Server/MyRemoteService.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
namespace WcfSample
// Copyright (c) on/off it-solutions gmbh. All rights reserved.
// Licensed under the MIT license. See license.txt file in the project root for license information.

namespace WcfSample
{
using System;
using System.Data.SqlClient;
Expand Down Expand Up @@ -53,7 +56,7 @@ public static DbContext CreateDbContext()
var optionsBuilder = new DbContextOptionsBuilder();
optionsBuilder.UseSqlServer(connectionString);
var context = new BloggingContext(optionsBuilder.Options);
context.GetService<ILoggerFactory>().AddConsole((_, __) => true);
context.GetService<ILoggerFactory>().AddConsole((msg, level) => true);
return context;
}

Expand Down
11 changes: 7 additions & 4 deletions sample/WcfSample.Server/Program.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
namespace WcfSample
// Copyright (c) on/off it-solutions gmbh. All rights reserved.
// Licensed under the MIT license. See license.txt file in the project root for license information.

namespace WcfSample
{
using System;
using System.ServiceModel;

class Program
internal class Program
{
static void Main(string[] args)
private static void Main(string[] args)
{
Console.WriteLine(@"Preparing the database...");
MyRemoteService.RecreateDatabase();

// Start self-hosted WCF server
using (var host = new ServiceHost(new MyRemoteService(), new Uri(WcfShared.UriString)))
{
{
host.AddDefaultEndpoints();
host.Open();
foreach (Uri addr in host.BaseAddresses)
Expand Down
10 changes: 10 additions & 0 deletions sample/WcfSample.Server/WcfSample.Server.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,21 @@
<OutputType>Exe</OutputType>
<TargetFramework>net461</TargetFramework>
<RootNamespace>WcfSample</RootNamespace>
<CodeAnalysisRuleSet>..\..\StyleNoDoc.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>

<ItemGroup>
<AdditionalFiles Include="..\..\stylecop.json">
<Link>stylecop.json</Link>
</AdditionalFiles>
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="2.0.0" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.0-beta004">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
Expand Down
12 changes: 8 additions & 4 deletions sample/WcfSample.Shared/Datamodel.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
using System;
// Copyright (c) on/off it-solutions gmbh. All rights reserved.
// Licensed under the MIT license. See license.txt file in the project root for license information.

#pragma warning disable SA1402
#pragma warning disable SA1649

namespace WcfSample
{
using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore;

Expand Down Expand Up @@ -29,20 +34,19 @@ public class Post
public Blog Blog { get; set; }
}


public class User
{
public decimal Id { get; set; }

public string Name { get; set; }
}


public class BloggingContext : DbContext
{
public BloggingContext(DbContextOptions options)
: base(options)
{ }
{
}

public DbSet<Blog> Blogs { get; set; }

Expand Down
5 changes: 4 additions & 1 deletion sample/WcfSample.Shared/IMyRemoteService.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
namespace WcfSample
// Copyright (c) on/off it-solutions gmbh. All rights reserved.
// Licensed under the MIT license. See license.txt file in the project root for license information.

namespace WcfSample
{
using System.ServiceModel;
using InfoCarrier.Core.Common;
Expand Down
10 changes: 10 additions & 0 deletions sample/WcfSample.Shared/WcfSample.Shared.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,21 @@
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<RootNamespace>WcfSample</RootNamespace>
<CodeAnalysisRuleSet>..\..\StyleNoDoc.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>

<ItemGroup>
<AdditionalFiles Include="..\..\stylecop.json">
<Link>stylecop.json</Link>
</AdditionalFiles>
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.0.0" />
<PackageReference Include="System.ServiceModel.Primitives" Version="4.4.0" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.0-beta004">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
Expand Down
5 changes: 4 additions & 1 deletion sample/WcfSample.Shared/WcfShared.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
namespace WcfSample
// Copyright (c) on/off it-solutions gmbh. All rights reserved.
// Licensed under the MIT license. See license.txt file in the project root for license information.

namespace WcfSample
{
using System;

Expand Down
Loading

0 comments on commit dd358f8

Please sign in to comment.