├── source
├── .nuget
│ ├── NuGet.exe
│ └── NuGet.Config
├── ServiceProxy.Zmq_old
│ ├── libzmq.dll
│ ├── packages.config
│ ├── README.md
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── Extensions.cs
│ ├── ZmqResponse.cs
│ └── ZmqRequest.cs
├── ServiceProxy.Zmq_old.Tests
│ ├── libzmq.dll
│ ├── packages.config
│ └── Properties
│ │ └── AssemblyInfo.cs
├── ServiceProxy.Redis.Tests
│ ├── redis-server.lnk
│ ├── App.config
│ ├── packages.config
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ └── ServiceProxy.Redis.Tests.csproj
├── ServiceProxy.Zmq
│ ├── packages.config
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── README.md
│ ├── ZmqResponse.cs
│ ├── ZmqRequest.cs
│ ├── Extensions.cs
│ └── ServiceProxy.Zmq.csproj
├── ServiceProxy
│ ├── packages.config
│ ├── IDependencyResolver.cs
│ ├── IService.cs
│ ├── IClient.cs
│ ├── IServiceClientFactory.cs
│ ├── IServiceFactory.cs
│ ├── RequestData.cs
│ ├── ResponseData.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── ServiceFactory.cs
│ ├── Internal
│ │ ├── TimeoutClient.cs
│ │ ├── Service.cs
│ │ ├── ServiceClientInterceptor.cs
│ │ └── OperationInvokers.cs
│ ├── ServiceClientFactory.cs
│ ├── ServiceProxy.csproj
│ └── README.md
├── ServiceProxy.Redis
│ ├── packages.config
│ ├── RedisConnection.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── Extensions.cs
│ ├── README.md
│ ├── RedisResponse.cs
│ ├── RedisRequest.cs
│ ├── RedisServer.cs
│ ├── ServiceProxy.Redis.csproj
│ └── RedisClient.cs
├── ServiceProxy.Tests
│ ├── packages.config
│ ├── Stubs
│ │ ├── DependencyResolver.cs
│ │ └── SimpleClient.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── ClientAndServerTests.cs
│ ├── ClientTests.cs
│ ├── ServiceTests.cs
│ └── ServiceProxy.Tests.csproj
└── ServiceProxy.Zmq.Tests
│ ├── packages.config
│ └── Properties
│ └── AssemblyInfo.cs
├── examples
├── MyApp
│ ├── .nuget
│ │ ├── NuGet.exe
│ │ └── NuGet.Config
│ ├── MyApp.WebAPI
│ │ ├── favicon.ico
│ │ ├── Global.asax
│ │ ├── SwaggerUI
│ │ │ ├── lib
│ │ │ │ ├── .DS_Store
│ │ │ │ ├── jquery.slideto.min.js
│ │ │ │ ├── jquery.wiggle.min.js
│ │ │ │ └── jquery.ba-bbq.min.js
│ │ │ ├── images
│ │ │ │ ├── wordnik_api.png
│ │ │ │ └── pet_store_api.png
│ │ │ └── index.html
│ │ ├── App_Start
│ │ │ ├── FilterConfig.cs
│ │ │ ├── RouteConfig.cs
│ │ │ ├── ServiceProxyAutofacModule.cs
│ │ │ ├── AutofacConfig.cs
│ │ │ ├── WebApiConfig.cs
│ │ │ └── SwaggerNet.cs
│ │ ├── Global.asax.cs
│ │ ├── Controllers
│ │ │ ├── CatalogController.cs
│ │ │ ├── AsyncCatalogController.cs
│ │ │ └── FooController.cs
│ │ ├── Web.Debug.config
│ │ ├── Web.Release.config
│ │ ├── Properties
│ │ │ └── AssemblyInfo.cs
│ │ ├── packages.config
│ │ └── Web.config
│ ├── MyApp.Broker
│ │ ├── App.config
│ │ ├── packages.config
│ │ ├── Program.cs
│ │ └── Properties
│ │ │ └── AssemblyInfo.cs
│ ├── MyApp.Worker
│ │ ├── App.config
│ │ ├── packages.config
│ │ ├── LogInterceptor.cs
│ │ ├── Properties
│ │ │ └── AssemblyInfo.cs
│ │ └── Program.cs
│ ├── MyApp.Services
│ │ ├── IFooService.cs
│ │ ├── ICatalogService.cs
│ │ ├── Properties
│ │ │ └── AssemblyInfo.cs
│ │ ├── Model.cs
│ │ └── MyApp.Services.csproj
│ ├── MyApp.Services.InMemory
│ │ ├── Properties
│ │ │ └── AssemblyInfo.cs
│ │ ├── FooService.cs
│ │ ├── MyApp.Services.InMemory.csproj
│ │ └── CatalogService.cs
│ └── MyApp.sln
└── Redis
│ ├── .nuget
│ ├── NuGet.exe
│ └── NuGet.Config
│ ├── Client
│ ├── App.config
│ ├── packages.config
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── Program.cs
│ └── Client.csproj
│ ├── Server
│ ├── App.config
│ ├── packages.config
│ ├── Program.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── FooService.cs
│ └── Server.csproj
│ ├── ServiceContracts
│ ├── Foo.cs
│ ├── IFooService.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ └── ServiceContracts.csproj
│ └── RedisSamples.sln
├── nuget
├── ServiceProxy
│ ├── pack.cmd
│ └── ServiceProxy.nuspec
├── ServiceProxy.Zmq
│ ├── pack.cmd
│ └── ServiceProxy.Zmq.nuspec
├── ServiceProxy.Redis
│ ├── pack.cmd
│ └── ServiceProxy.Redis.nuspec
├── ServiceProxy.Zmq_old
│ ├── pack.cmd
│ └── ServiceProxy.Zmq.nuspec
└── pack.cmd
├── CHANGELOG.md
├── LICENSE
├── .gitignore
├── .gitattributes
└── README.md
/source/.nuget/NuGet.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mfelicio/ServiceProxy/HEAD/source/.nuget/NuGet.exe
--------------------------------------------------------------------------------
/examples/MyApp/.nuget/NuGet.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mfelicio/ServiceProxy/HEAD/examples/MyApp/.nuget/NuGet.exe
--------------------------------------------------------------------------------
/examples/Redis/.nuget/NuGet.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mfelicio/ServiceProxy/HEAD/examples/Redis/.nuget/NuGet.exe
--------------------------------------------------------------------------------
/source/ServiceProxy.Zmq_old/libzmq.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mfelicio/ServiceProxy/HEAD/source/ServiceProxy.Zmq_old/libzmq.dll
--------------------------------------------------------------------------------
/examples/MyApp/MyApp.WebAPI/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mfelicio/ServiceProxy/HEAD/examples/MyApp/MyApp.WebAPI/favicon.ico
--------------------------------------------------------------------------------
/examples/MyApp/MyApp.WebAPI/Global.asax:
--------------------------------------------------------------------------------
1 | <%@ Application Codebehind="Global.asax.cs" Inherits="MyApp.WebAPI.WebApiApplication" Language="C#" %>
2 |
--------------------------------------------------------------------------------
/source/ServiceProxy.Zmq_old.Tests/libzmq.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mfelicio/ServiceProxy/HEAD/source/ServiceProxy.Zmq_old.Tests/libzmq.dll
--------------------------------------------------------------------------------
/source/ServiceProxy.Redis.Tests/redis-server.lnk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mfelicio/ServiceProxy/HEAD/source/ServiceProxy.Redis.Tests/redis-server.lnk
--------------------------------------------------------------------------------
/examples/MyApp/MyApp.WebAPI/SwaggerUI/lib/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mfelicio/ServiceProxy/HEAD/examples/MyApp/MyApp.WebAPI/SwaggerUI/lib/.DS_Store
--------------------------------------------------------------------------------
/source/ServiceProxy.Redis.Tests/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/examples/MyApp/MyApp.WebAPI/SwaggerUI/images/wordnik_api.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mfelicio/ServiceProxy/HEAD/examples/MyApp/MyApp.WebAPI/SwaggerUI/images/wordnik_api.png
--------------------------------------------------------------------------------
/examples/MyApp/MyApp.WebAPI/SwaggerUI/images/pet_store_api.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mfelicio/ServiceProxy/HEAD/examples/MyApp/MyApp.WebAPI/SwaggerUI/images/pet_store_api.png
--------------------------------------------------------------------------------
/nuget/ServiceProxy/pack.cmd:
--------------------------------------------------------------------------------
1 | xcopy ..\..\source\ServiceProxy\bin\Release\ServiceProxy.dll lib\net45\ /y
2 |
3 | NuGet.exe pack ServiceProxy.nuspec -exclude *.cmd -OutputDirectory ..\
--------------------------------------------------------------------------------
/source/ServiceProxy.Zmq/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/source/ServiceProxy/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/source/ServiceProxy.Zmq_old/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/nuget/ServiceProxy.Zmq/pack.cmd:
--------------------------------------------------------------------------------
1 | xcopy ..\..\source\ServiceProxy.Zmq\bin\Release\ServiceProxy.Zmq.dll lib\net45\ /y
2 |
3 | NuGet.exe pack ServiceProxy.Zmq.nuspec -exclude *.cmd -OutputDirectory ..\
--------------------------------------------------------------------------------
/source/ServiceProxy.Redis/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/nuget/ServiceProxy.Redis/pack.cmd:
--------------------------------------------------------------------------------
1 | xcopy ..\..\source\ServiceProxy.Redis\bin\Release\ServiceProxy.Redis.dll lib\net45\ /y
2 |
3 | NuGet.exe pack ServiceProxy.Redis.nuspec -exclude *.cmd -OutputDirectory ..\
--------------------------------------------------------------------------------
/nuget/ServiceProxy.Zmq_old/pack.cmd:
--------------------------------------------------------------------------------
1 | xcopy ..\..\source\ServiceProxy.Zmq_old\bin\Release\ServiceProxy.Zmq.dll lib\net45\ /y
2 |
3 | NuGet.exe pack ServiceProxy.Zmq.nuspec -exclude *.cmd -OutputDirectory ..\
--------------------------------------------------------------------------------
/source/.nuget/NuGet.Config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/examples/MyApp/.nuget/NuGet.Config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/examples/Redis/.nuget/NuGet.Config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/examples/Redis/Client/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/examples/Redis/Server/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/examples/MyApp/MyApp.Broker/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/examples/MyApp/MyApp.Worker/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/nuget/pack.cmd:
--------------------------------------------------------------------------------
1 | cd ServiceProxy
2 | call pack.cmd
3 |
4 | cd ..
5 | cd ServiceProxy.Redis
6 | call pack.cmd
7 |
8 | cd..
9 | cd ServiceProxy.Zmq
10 | call pack.cmd
11 |
12 | cd..
13 | cd ServiceProxy.Zmq_old
14 | call pack.cmd
--------------------------------------------------------------------------------
/source/ServiceProxy.Tests/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/source/ServiceProxy.Redis.Tests/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | Release notes
2 | ============
3 |
4 | ## 1.0.1
5 |
6 | * Added support for timeouts on client requests.
7 |
8 | ## 1.0.0
9 |
10 | * First public release.
11 | * Added ServiceProxy.Zmq and ServiceProxy.Redis as implementations of the IClient interface.
--------------------------------------------------------------------------------
/source/ServiceProxy.Zmq.Tests/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/source/ServiceProxy.Zmq_old.Tests/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/source/ServiceProxy/IDependencyResolver.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace ServiceProxy
8 | {
9 | public interface IDependencyResolver
10 | {
11 | object Resolve(Type type);
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/source/ServiceProxy/IService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace ServiceProxy
8 | {
9 | public interface IService
10 | {
11 | Task Process(RequestData requestData);
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/examples/MyApp/MyApp.WebAPI/App_Start/FilterConfig.cs:
--------------------------------------------------------------------------------
1 | using System.Web;
2 | using System.Web.Mvc;
3 |
4 | namespace MyApp.WebAPI
5 | {
6 | public class FilterConfig
7 | {
8 | public static void RegisterGlobalFilters(GlobalFilterCollection filters)
9 | {
10 | filters.Add(new HandleErrorAttribute());
11 | }
12 | }
13 | }
--------------------------------------------------------------------------------
/examples/Redis/ServiceContracts/Foo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace ServiceContracts
8 | {
9 | [Serializable]
10 | public class Foo
11 | {
12 | public int Id { get; set; }
13 | public string Name { get; set; }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/source/ServiceProxy/IClient.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading;
6 | using System.Threading.Tasks;
7 |
8 | namespace ServiceProxy
9 | {
10 | public interface IClient
11 | {
12 | Task Request(RequestData request, CancellationToken token);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/examples/MyApp/MyApp.Broker/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/examples/Redis/Client/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/examples/Redis/Server/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/examples/MyApp/MyApp.WebAPI/SwaggerUI/lib/jquery.slideto.min.js:
--------------------------------------------------------------------------------
1 | (function(b){b.fn.slideto=function(a){a=b.extend({slide_duration:"slow",highlight_duration:3E3,highlight:true,highlight_color:"#FFFF99"},a);return this.each(function(){obj=b(this);b("body").animate({scrollTop:obj.offset().top},a.slide_duration,function(){a.highlight&&b.ui.version&&obj.effect("highlight",{color:a.highlight_color},a.highlight_duration)})})}})(jQuery);
2 |
--------------------------------------------------------------------------------
/source/ServiceProxy/IServiceClientFactory.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace ServiceProxy
8 | {
9 | public interface IServiceClientFactory
10 | {
11 | TService CreateServiceClient(int? timeout = null) where TService : class;
12 | object CreateServiceClient(Type serviceType, int? timeout = null);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/source/ServiceProxy/IServiceFactory.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace ServiceProxy
8 | {
9 | public interface IServiceFactory
10 | {
11 | IService CreateService() where TService : class;
12 |
13 | IService CreateService(string serviceName);
14 |
15 | IService CreateService(Type serviceType);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/examples/Redis/ServiceContracts/IFooService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace ServiceContracts
8 | {
9 | public interface IFooService
10 | {
11 | Foo GetFoo(int id);
12 | Task GetFooAsync(int id);
13 |
14 | IEnumerable ListFoos();
15 | Task> ListFoosAsync();
16 |
17 | void UpdateFoo(Foo foo);
18 | Task UpdateFooAsync(Foo foo);
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/examples/MyApp/MyApp.Worker/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/source/ServiceProxy.Zmq_old/README.md:
--------------------------------------------------------------------------------
1 | ServiceProxy.Zmq_old
2 | ============
3 |
4 | ServiceProxy.Zmq_old is a scalable request/reply messaging framework built with ZeroMQ that supports service contracts using ServiceProxy.
5 |
6 | This version is as functional as the new [ServiceProxy.Zmq][serviceproxy.zmq-github] version. However it uses an old version of [clrzmq][clrzmq-github] with libzmq 2.2
7 |
8 | For reference use the new
9 |
10 | [serviceproxy.zmq-github]: https://github.com/mfelicio/ServiceProxy/tree/master/source/ServiceProxy.Zmq
11 | [clrzmq-github]: https://github.com/zeromq/clrzmq
12 |
--------------------------------------------------------------------------------
/examples/MyApp/MyApp.Services/IFooService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace MyApp.Services
8 | {
9 | public interface IFooService
10 | {
11 | void DoNothing();
12 |
13 | Task AsyncOperationThatTakesTimeAndMayFail(int operationTime, bool fail);
14 |
15 | IAsyncResult BeginSum(int arg1, int arg2, AsyncCallback asyncCallback, object asyncState);
16 | int EndSum(IAsyncResult asyncResult);
17 |
18 | Catalog GetRandomCatalog();
19 |
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/source/ServiceProxy.Tests/Stubs/DependencyResolver.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace ServiceProxy.Tests.Stubs
8 | {
9 | public class DependencyResolver : IDependencyResolver
10 | {
11 | public object Resolve(Type type)
12 | {
13 | if (type == typeof(ITestService) || type == typeof(ITestService2))
14 | {
15 | return new TestService();
16 | }
17 |
18 | return Activator.CreateInstance(type);
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/examples/MyApp/MyApp.Services/ICatalogService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace MyApp.Services
8 | {
9 | public interface ICatalogService
10 | {
11 | IEnumerable GetCatalogNames();
12 | Task> GetCatalogNamesAsync();
13 |
14 | Catalog GetCatalog(string name);
15 | Task GetCatalogAsync(string name);
16 |
17 | ItemDetails GetItemDetails(string code);
18 | Task GetItemDetailsAsync(string code);
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/examples/MyApp/MyApp.Worker/LogInterceptor.cs:
--------------------------------------------------------------------------------
1 | using Castle.DynamicProxy;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace MyApp.Worker
9 | {
10 | public class LogInterceptor : IInterceptor
11 | {
12 | public void Intercept(IInvocation invocation)
13 | {
14 | Console.WriteLine("Calling method {0} with parameters {1}... ",
15 | invocation.Method.Name,
16 | string.Join(", ", invocation.Arguments.Select(a => (a ?? "").ToString()).ToArray()));
17 |
18 | invocation.Proceed();
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/source/ServiceProxy/RequestData.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace ServiceProxy
8 | {
9 | [Serializable]
10 | public class RequestData
11 | {
12 | public RequestData(string service, string operation, object[] arguments)
13 | {
14 | this.Service = service;
15 | this.Operation = operation;
16 | this.Arguments = arguments;
17 | }
18 |
19 | public string Service { get; private set; }
20 | public string Operation { get; private set; }
21 | public object[] Arguments { get; private set; }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/examples/MyApp/MyApp.WebAPI/App_Start/RouteConfig.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Web;
5 | using System.Web.Mvc;
6 | using System.Web.Routing;
7 |
8 | namespace MyApp.WebAPI
9 | {
10 | public class RouteConfig
11 | {
12 | public static void RegisterRoutes(RouteCollection routes)
13 | {
14 | routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
15 |
16 | routes.MapRoute(
17 | name: "Default",
18 | url: "{controller}/{action}/{id}",
19 | defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
20 | );
21 | }
22 | }
23 | }
--------------------------------------------------------------------------------
/source/ServiceProxy/ResponseData.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace ServiceProxy
8 | {
9 | [Serializable]
10 | public class ResponseData
11 | {
12 | public ResponseData(object data)
13 | {
14 | this.Data = data;
15 | this.Exception = null;
16 | }
17 |
18 | public ResponseData(Exception error)
19 | {
20 | this.Data = null;
21 | this.Exception = error;
22 | }
23 |
24 | public object Data { get; private set; }
25 | public Exception Exception { get; private set; }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/examples/MyApp/MyApp.WebAPI/SwaggerUI/lib/jquery.wiggle.min.js:
--------------------------------------------------------------------------------
1 | /*
2 | jQuery Wiggle
3 | Author: WonderGroup, Jordan Thomas
4 | URL: http://labs.wondergroup.com/demos/mini-ui/index.html
5 | License: MIT (http://en.wikipedia.org/wiki/MIT_License)
6 | */
7 | jQuery.fn.wiggle=function(o){var d={speed:50,wiggles:3,travel:5,callback:null};var o=jQuery.extend(d,o);return this.each(function(){var cache=this;var wrap=jQuery(this).wrap('').css("position","relative");var calls=0;for(i=1;i<=o.wiggles;i++){jQuery(this).animate({left:"-="+o.travel},o.speed).animate({left:"+="+o.travel*2},o.speed*2).animate({left:"-="+o.travel},o.speed,function(){calls++;if(jQuery(cache).parent().hasClass('wiggle-wrap')){jQuery(cache).parent().replaceWith(cache);}
8 | if(calls==o.wiggles&&jQuery.isFunction(o.callback)){o.callback();}});}});};
--------------------------------------------------------------------------------
/source/ServiceProxy.Tests/Stubs/SimpleClient.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading;
6 | using System.Threading.Tasks;
7 |
8 | namespace ServiceProxy.Tests.Stubs
9 | {
10 | class SimpleClient : IClient
11 | {
12 | private readonly IServiceFactory serviceFactory;
13 |
14 | public SimpleClient(IServiceFactory serviceFactory)
15 | {
16 | this.serviceFactory = serviceFactory;
17 | }
18 |
19 | public Task Request(RequestData request, CancellationToken token)
20 | {
21 | var svc = this.serviceFactory.CreateService(request.Service);
22 | var responseTask = svc.Process(request);
23 |
24 | return responseTask;
25 | }
26 | }
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/nuget/ServiceProxy/ServiceProxy.nuspec:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | ServiceProxy
5 | 1.0.1
6 | ServiceProxy
7 | Manuel Felicio
8 | Manuel Felicio
9 | http://opensource.org/licenses/mit-license.php
10 | http://github.com/mfelicio/ServiceProxy
11 | false
12 | ServiceProxy is a lightweight asynchronous service proxy that allows you to use service contracts in a request/reply manner with your favorite messaging framework.
13 | Copyright 2014 Manuel Felício
14 | messaging services proxy interceptor request reply async asynchronous
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/examples/MyApp/MyApp.WebAPI/Global.asax.cs:
--------------------------------------------------------------------------------
1 | using Autofac;
2 | using Autofac.Integration.WebApi;
3 | using MyApp.Services;
4 | using ServiceProxy;
5 | using ServiceProxy.Zmq;
6 | using System;
7 | using System.Collections.Generic;
8 | using System.Linq;
9 | using System.Web;
10 | using System.Web.Http;
11 | using System.Web.Mvc;
12 | using System.Web.Optimization;
13 | using System.Web.Routing;
14 |
15 | namespace MyApp.WebAPI
16 | {
17 | // Note: For instructions on enabling IIS6 or IIS7 classic mode,
18 | // visit http://go.microsoft.com/?LinkId=9394801
19 |
20 | public class WebApiApplication : System.Web.HttpApplication
21 | {
22 | protected void Application_Start()
23 | {
24 | AreaRegistration.RegisterAllAreas();
25 |
26 | WebApiConfig.Register(GlobalConfiguration.Configuration);
27 | FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
28 | RouteConfig.RegisterRoutes(RouteTable.Routes);
29 |
30 | }
31 | }
32 | }
--------------------------------------------------------------------------------
/nuget/ServiceProxy.Zmq_old/ServiceProxy.Zmq.nuspec:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | ServiceProxy.Zmq
5 | 1.0.1
6 | ServiceProxy.Zmq
7 | Manuel Felicio
8 | Manuel Felicio
9 | http://opensource.org/licenses/mit-license.php
10 | http://github.com/mfelicio/ServiceProxy
11 | false
12 | ServiceProxy.Zmq is a scalable request/reply messaging framework built with ZeroMQ that supports service contracts using ServiceProxy.
13 | Copyright 2014 Manuel Felício
14 | zmq zeromq 0mq messaging services request reply proxy async asynchronous
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/nuget/ServiceProxy.Zmq/ServiceProxy.Zmq.nuspec:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | ServiceProxy.Zmq
5 | 1.1.0-beta
6 | ServiceProxy.Zmq
7 | Manuel Felicio
8 | Manuel Felicio
9 | http://opensource.org/licenses/mit-license.php
10 | http://github.com/mfelicio/ServiceProxy
11 | false
12 | ServiceProxy.Zmq is a scalable request/reply messaging framework built with ZeroMQ that supports service contracts using ServiceProxy.
13 | Copyright 2014 Manuel Felício
14 | zmq zeromq 0mq messaging services request reply proxy async asynchronous
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/examples/Redis/Server/Program.cs:
--------------------------------------------------------------------------------
1 | using ServiceProxy.Redis;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace Server
9 | {
10 | class Program
11 | {
12 | static void Main(string[] args)
13 | {
14 | var serviceFactory = new ServiceProxy.ServiceFactory(new SimpleDependencyResolver());
15 |
16 | using (var server = new RedisServer(new RedisConnection("localhost"), "ThisIsTheServiceQueue", serviceFactory))
17 | {
18 | server.Listen();
19 |
20 | Console.WriteLine("Press ENTER to close");
21 | Console.ReadLine();
22 | }
23 | }
24 | }
25 |
26 | //This should be an adapter for an IoC container
27 | class SimpleDependencyResolver : ServiceProxy.IDependencyResolver
28 | {
29 | public object Resolve(Type type)
30 | {
31 | return new FooService();
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/examples/MyApp/MyApp.WebAPI/App_Start/ServiceProxyAutofacModule.cs:
--------------------------------------------------------------------------------
1 | using Autofac;
2 | using MyApp.Services;
3 | using ServiceProxy;
4 | using ServiceProxy.Zmq;
5 | using System;
6 | using System.Collections.Generic;
7 | using System.Linq;
8 | using System.Web;
9 |
10 | namespace MyApp.WebAPI
11 | {
12 | public class ServiceProxyAutofacModule : Module
13 | {
14 | protected override void Load(Autofac.ContainerBuilder builder)
15 | {
16 | builder.RegisterType().As().SingleInstance();
17 |
18 | builder.RegisterInstance(new ZmqClient(new ZMQ.Context(), "tcp://localhost:8001", "tcp://localhost:8002"))
19 | .As().SingleInstance();
20 |
21 | builder.Register(ctx => ctx.Resolve().CreateServiceClient(15000));
22 | builder.Register(ctx => ctx.Resolve().CreateServiceClient(15000));
23 | }
24 | }
25 | }
--------------------------------------------------------------------------------
/nuget/ServiceProxy.Redis/ServiceProxy.Redis.nuspec:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | ServiceProxy.Redis
5 | 1.1.0
6 | ServiceProxy.Redis
7 | Manuel Felicio
8 | Manuel Felicio
9 | http://opensource.org/licenses/mit-license.php
10 | http://github.com/mfelicio/ServiceProxy
11 | false
12 | ServiceProxy.Redis is a simple request/reply messaging framework built on Redis queues that support service contracts using ServiceProxy and the StackExchange.Redis library.
13 | Copyright 2014 Manuel Felício
14 | redis messaging services request reply proxy async asynchronous
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/examples/MyApp/MyApp.WebAPI/Controllers/CatalogController.cs:
--------------------------------------------------------------------------------
1 | using MyApp.Services;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Net;
6 | using System.Net.Http;
7 | using System.Threading.Tasks;
8 | using System.Web.Http;
9 |
10 | namespace MyApp.WebAPI.Controllers
11 | {
12 | public class CatalogController : ApiController
13 | {
14 | private readonly ICatalogService catalogService;
15 |
16 | public CatalogController(ICatalogService catalogService)
17 | {
18 | this.catalogService = catalogService;
19 | }
20 |
21 | public IEnumerable GetCatalogNames()
22 | {
23 | return this.catalogService.GetCatalogNames();
24 | }
25 |
26 | public Catalog GetCatalogs(string name)
27 | {
28 | return this.catalogService.GetCatalog(name);
29 | }
30 |
31 | public ItemDetails GetDetails(string code)
32 | {
33 | return this.catalogService.GetItemDetails(code);
34 | }
35 |
36 | }
37 | }
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2014 Manuel Felicio
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
--------------------------------------------------------------------------------
/examples/MyApp/MyApp.WebAPI/Controllers/AsyncCatalogController.cs:
--------------------------------------------------------------------------------
1 | using MyApp.Services;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Net;
6 | using System.Net.Http;
7 | using System.Threading.Tasks;
8 | using System.Web.Http;
9 |
10 | namespace MyApp.WebAPI.Controllers
11 | {
12 | public class AsyncCatalogController : ApiController
13 | {
14 | private readonly ICatalogService catalogService;
15 |
16 | public AsyncCatalogController(ICatalogService catalogService)
17 | {
18 | this.catalogService = catalogService;
19 | }
20 |
21 | public async Task> GetCatalogNamesAsync()
22 | {
23 | return await this.catalogService.GetCatalogNamesAsync();
24 | }
25 |
26 | public async Task GetCatalogAsync(string name)
27 | {
28 | return await this.catalogService.GetCatalogAsync(name);
29 | }
30 |
31 | public async Task GetDetailsAsync(string code)
32 | {
33 | return await this.catalogService.GetItemDetailsAsync(code);
34 | }
35 |
36 | }
37 | }
--------------------------------------------------------------------------------
/examples/MyApp/MyApp.WebAPI/App_Start/AutofacConfig.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Web;
4 | using System.Web.Http;
5 | using System.Web.Http.Description;
6 | using System.Web.Http.Dispatcher;
7 | using System.Web.Routing;
8 | using Swagger.Net;
9 | using Autofac;
10 | using Autofac.Integration.WebApi;
11 |
12 | [assembly: WebActivator.PreApplicationStartMethod(typeof(MyApp.WebAPI.AutofacConfig), "PreStart")]
13 | [assembly: WebActivator.PostApplicationStartMethod(typeof(MyApp.WebAPI.AutofacConfig), "PostStart")]
14 |
15 | namespace MyApp.WebAPI
16 | {
17 | public static class AutofacConfig
18 | {
19 | public static void PreStart()
20 | {
21 | }
22 |
23 | public static void PostStart()
24 | {
25 | var builder = new ContainerBuilder();
26 |
27 | builder.RegisterApiControllers(typeof(WebApiApplication).Assembly);
28 |
29 | builder.RegisterModule(new ServiceProxyAutofacModule());
30 |
31 | var container = builder.Build();
32 |
33 | GlobalConfiguration.Configuration.DependencyResolver = new AutofacWebApiDependencyResolver(container);
34 | }
35 | }
36 | }
--------------------------------------------------------------------------------
/source/ServiceProxy.Redis/RedisConnection.cs:
--------------------------------------------------------------------------------
1 | using StackExchange.Redis;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace ServiceProxy.Redis
9 | {
10 | public class RedisConnection
11 | {
12 | private readonly ConnectionMultiplexer connectionManager;
13 |
14 | public RedisConnection(string host, int port = 6379, string password = null)
15 | {
16 | var options = new ConfigurationOptions();
17 | options.Password = password;
18 | options.EndPoints.Add(host, port);
19 | options.AbortOnConnectFail = false;
20 |
21 | this.connectionManager = ConnectionMultiplexer.Connect(options);
22 | }
23 |
24 | public RedisConnection(ConnectionMultiplexer connectionMultiplexer)
25 | {
26 | this.connectionManager = connectionMultiplexer;
27 | }
28 |
29 | public IDatabase GetClient()
30 | {
31 | return this.connectionManager.GetDatabase();
32 | }
33 |
34 | public ISubscriber GetSubscriber()
35 | {
36 | return this.connectionManager.GetSubscriber();
37 | }
38 |
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/examples/MyApp/MyApp.Broker/Program.cs:
--------------------------------------------------------------------------------
1 | using ServiceProxy.Zmq;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace MyApp.Broker
9 | {
10 | class Program
11 | {
12 | static void Main(string[] args)
13 | {
14 | //Note: 0MQ tcp sockets only accept IPv4 addresses, wild card or interface-name for the Bind operation.
15 | var clientInboundAddr = "tcp://*:8001";
16 | var clientOutboundAddr = "tcp://*:8002";
17 | var serverInboundAddr = "tcp://*:8003";
18 | var serverOutboundAddr = "tcp://*:8004";
19 |
20 | ZmqBroker broker = null;
21 |
22 | try
23 | {
24 | broker = new ZmqBroker(new ZMQ.Context(), clientInboundAddr, clientOutboundAddr, serverInboundAddr, serverOutboundAddr);
25 | broker.Listen();
26 |
27 | Console.WriteLine("Press enter to quit");
28 | Console.ReadLine();
29 | }
30 | finally
31 | {
32 | if (broker != null)
33 | {
34 | broker.Dispose();
35 | }
36 | }
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/examples/MyApp/MyApp.WebAPI/Web.Debug.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
17 |
18 |
29 |
30 |
--------------------------------------------------------------------------------
/examples/MyApp/MyApp.WebAPI/Web.Release.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
17 |
18 |
19 |
30 |
31 |
--------------------------------------------------------------------------------
/examples/MyApp/MyApp.WebAPI/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("MyApp.WebAPI")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("MyApp.WebAPI")]
13 | [assembly: AssemblyCopyright("Copyright © 2014")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("83ca4f48-8fe8-450b-b363-78ef4fd8161b")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Revision and Build Numbers
33 | // by using the '*' as shown below:
34 | [assembly: AssemblyVersion("1.0.0.0")]
35 | [assembly: AssemblyFileVersion("1.0.0.0")]
36 |
--------------------------------------------------------------------------------
/examples/Redis/Client/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("Client")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("Client")]
13 | [assembly: AssemblyCopyright("Copyright © 2014")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("56e8fd63-0803-48c2-972f-cf7094f783c3")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/examples/Redis/Server/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("Server")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("Server")]
13 | [assembly: AssemblyCopyright("Copyright © 2014")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("63f9d189-6b84-419b-89b3-5c94e1deb822")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/source/ServiceProxy/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("ServiceProxy")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("ServiceProxy")]
13 | [assembly: AssemblyCopyright("Copyright © 2014")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("c9b2f8e2-ff3a-4ff7-ae04-9929341271cc")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/examples/MyApp/MyApp.Broker/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("MyApp.Broker")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("MyApp.Broker")]
13 | [assembly: AssemblyCopyright("Copyright © 2014")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("705fc4da-53df-45c5-a6da-c78bb3125e2f")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/examples/MyApp/MyApp.Worker/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("MyApp.Worker")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("MyApp.Worker")]
13 | [assembly: AssemblyCopyright("Copyright © 2014")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("03fedb7f-8264-45e2-abf4-cc1780d7aab4")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/examples/MyApp/MyApp.Services/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("MyApp.Services")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("MyApp.Services")]
13 | [assembly: AssemblyCopyright("Copyright © 2014")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("9a43bd0e-9ef4-4d16-b7ce-e7f405338ee0")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/source/ServiceProxy.Zmq/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("ServiceProxy.Zmq")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("ServiceProxy.Zmq")]
13 | [assembly: AssemblyCopyright("Copyright © 2014")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("305937fe-d692-4286-b26a-9ab71e832a59")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/examples/Redis/ServiceContracts/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("ServiceContracts")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("ServiceContracts")]
13 | [assembly: AssemblyCopyright("Copyright © 2014")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("951b290e-613c-4182-a174-1a17a7721eae")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/source/ServiceProxy.Redis/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("ServiceProxy.Redis")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("ServiceProxy.Redis")]
13 | [assembly: AssemblyCopyright("Copyright © 2014")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("0f571330-451b-49ee-a2ca-1c8e98cf6813")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/source/ServiceProxy.Tests/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("ServiceProxy.Tests")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("ServiceProxy.Tests")]
13 | [assembly: AssemblyCopyright("Copyright © 2014")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("d4a72aa0-89fe-4afd-9efc-71b5decc3470")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/source/ServiceProxy.Zmq_old/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("ServiceProxy.Zmq")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("ServiceProxy.Zmq")]
13 | [assembly: AssemblyCopyright("Copyright © 2014")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("a4a134b9-369d-4852-8df3-7d18d58f78a1")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/source/ServiceProxy.Zmq.Tests/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("ServiceProxy.Zmq.Tests")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("ServiceProxy.Zmq.Tests")]
13 | [assembly: AssemblyCopyright("Copyright © 2014")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("2e5711dc-19ff-4837-b70d-b199f9f4c7a6")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/source/ServiceProxy.Zmq_old.Tests/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("ServiceProxy.Zmq.Tests")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("ServiceProxy.Zmq.Tests")]
13 | [assembly: AssemblyCopyright("Copyright © 2014")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("a1f31be4-f94b-4b2d-8641-76619deaae6e")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/examples/MyApp/MyApp.WebAPI/App_Start/WebApiConfig.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Web.Http;
5 |
6 | namespace MyApp.WebAPI
7 | {
8 | public static class WebApiConfig
9 | {
10 | public static void Register(HttpConfiguration config)
11 | {
12 | config.Routes.MapHttpRoute(
13 | name: "DefaultApi",
14 | routeTemplate: "api/swagger/{id}",
15 | defaults: new { id = RouteParameter.Optional, controller = "swagger" }
16 | );
17 |
18 | config.Routes.MapHttpRoute(
19 | name: "Default2Api",
20 | routeTemplate: "api/{controller}/{action}/{id}",
21 | defaults: new { id = RouteParameter.Optional }
22 | );
23 |
24 | // Uncomment the following line of code to enable query support for actions with an IQueryable or IQueryable return type.
25 | // To avoid processing unexpected or malicious queries, use the validation settings on QueryableAttribute to validate incoming queries.
26 | // For more information, visit http://go.microsoft.com/fwlink/?LinkId=279712.
27 | //config.EnableQuerySupport();
28 |
29 | // To disable tracing in your application, please comment out or remove the following line of code
30 | // For more information, refer to: http://www.asp.net/web-api
31 | config.EnableSystemDiagnosticsTracing();
32 |
33 | config.Formatters.Remove(config.Formatters.XmlFormatter);
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/source/ServiceProxy.Redis.Tests/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("ServiceProxy.Redis.Tests")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("ServiceProxy.Redis.Tests")]
13 | [assembly: AssemblyCopyright("Copyright © 2014")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("bf5ebdac-5aa8-4ee1-9871-dd76fc852961")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/examples/MyApp/MyApp.Services.InMemory/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("MyApp.Services.InMemory")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("MyApp.Services.InMemory")]
13 | [assembly: AssemblyCopyright("Copyright © 2014")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("9de742f5-57a0-4d0b-9781-f42da90ce9c4")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/examples/MyApp/MyApp.WebAPI/App_Start/SwaggerNet.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Web;
4 | using System.Web.Http;
5 | using System.Web.Http.Description;
6 | using System.Web.Http.Dispatcher;
7 | using System.Web.Routing;
8 | using Swagger.Net;
9 |
10 | [assembly: WebActivator.PreApplicationStartMethod(typeof(MyApp.WebAPI.SwaggerNet), "PreStart")]
11 | [assembly: WebActivator.PostApplicationStartMethod(typeof(MyApp.WebAPI.SwaggerNet), "PostStart")]
12 |
13 | namespace MyApp.WebAPI
14 | {
15 | public static class SwaggerNet
16 | {
17 | public static void PreStart()
18 | {
19 | RouteTable.Routes.MapHttpRoute(
20 | name: "SwaggerApi",
21 | routeTemplate: "api/docs/{controller}",
22 | defaults: new { swagger = true }
23 | );
24 | }
25 |
26 | public static void PostStart()
27 | {
28 | var config = GlobalConfiguration.Configuration;
29 |
30 | config.Filters.Add(new SwaggerActionFilter());
31 |
32 | try
33 | {
34 | config.Services.Replace(typeof(IDocumentationProvider),
35 | new XmlCommentDocumentationProvider(HttpContext.Current.Server.MapPath("~/bin/MyApp.WebAPI.XML")));
36 | }
37 | catch (FileNotFoundException)
38 | {
39 | throw new Exception("Please enable \"XML documentation file\" in project properties with default (bin\\MyApp.WebAPI.XML) value or edit value in App_Start\\SwaggerNet.cs");
40 | }
41 | }
42 | }
43 | }
--------------------------------------------------------------------------------
/source/ServiceProxy.Zmq_old/Extensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Runtime.Serialization.Formatters.Binary;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 |
9 | namespace ServiceProxy.Zmq
10 | {
11 | static class ArrayExtensions
12 | {
13 | public static T[] Slice(this T[] data, int index, int length)
14 | {
15 | T[] slice = new T[length];
16 | Array.Copy(data, index, slice, 0, length);
17 | return slice;
18 | }
19 |
20 | public static byte[] ToBinary(T obj)
21 | {
22 | var formatter = new BinaryFormatter();
23 |
24 | using (var stream = new MemoryStream())
25 | {
26 | formatter.Serialize(stream, obj);
27 | return stream.GetBuffer();
28 | }
29 |
30 | }
31 |
32 | public static T ToObject(byte[] objBytes)
33 | {
34 | var formatter = new BinaryFormatter();
35 |
36 | using (var stream = new MemoryStream(objBytes))
37 | {
38 | return (T)formatter.Deserialize(stream);
39 | }
40 | }
41 | }
42 |
43 | static class ZmqContextExtensions
44 | {
45 | public static Guid NewIdentity(this ZMQ.Context context)
46 | {
47 | Guid identity;
48 | while (true)
49 | {
50 | identity = Guid.NewGuid();
51 | if (identity.ToByteArray()[0] != 0)
52 | {
53 | return identity;
54 | }
55 | }
56 | }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/source/ServiceProxy.Redis/Extensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Runtime.Serialization.Formatters.Binary;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 |
9 | namespace ServiceProxy.Redis
10 | {
11 | static class ArrayExtensions
12 | {
13 | public static T[] Slice(this T[] data, int index, int length)
14 | {
15 | T[] slice = new T[length];
16 | Array.Copy(data, index, slice, 0, length);
17 | return slice;
18 | }
19 |
20 | public static byte[] ToBinary(T obj)
21 | {
22 | var formatter = new BinaryFormatter();
23 |
24 | using (var stream = new MemoryStream())
25 | {
26 | formatter.Serialize(stream, obj);
27 | return stream.GetBuffer();
28 | }
29 |
30 | }
31 |
32 | public static T ToObject(byte[] objBytes)
33 | {
34 | var formatter = new BinaryFormatter();
35 |
36 | using (var stream = new MemoryStream(objBytes))
37 | {
38 | return (T)formatter.Deserialize(stream);
39 | }
40 | }
41 | }
42 |
43 | static class TaskExtensions
44 | {
45 | public static async Task IgnoreException(this Task task, params Type[] exceptionTypes)
46 | {
47 | try
48 | {
49 | return await task;
50 | }
51 | catch (Exception ex)
52 | {
53 | if (exceptionTypes.Any(type => type.IsAssignableFrom(ex.GetType())))
54 | {
55 | return default(T);
56 | }
57 |
58 | throw;
59 | }
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/examples/MyApp/MyApp.Services.InMemory/FooService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace MyApp.Services.InMemory
8 | {
9 | public class FooService : IFooService
10 | {
11 | private readonly ICatalogService catalogService;
12 |
13 | public FooService(ICatalogService catalogService)
14 | {
15 | this.catalogService = catalogService;
16 | }
17 |
18 | public void DoNothing()
19 | {
20 | //like nothing
21 | }
22 |
23 | public async Task AsyncOperationThatTakesTimeAndMayFail(int operationTime, bool fail)
24 | {
25 | await Task.Delay(operationTime);
26 |
27 | if (fail)
28 | {
29 | throw new ApplicationException("You asked for it!");
30 | }
31 | }
32 |
33 | public IAsyncResult BeginSum(int arg1, int arg2, AsyncCallback asyncCallback, object asyncState)
34 | {
35 | var t = Task.Factory.StartNew((s) => arg1 + arg2, asyncState);
36 |
37 | //introducing some delay on purpose and signaling completion when the sum and the delay are done
38 | Task.Factory.ContinueWhenAll(new Task[] { t, Task.Delay(50)}, ts => asyncCallback(t));
39 |
40 | return t;
41 | }
42 |
43 | public int EndSum(IAsyncResult asyncResult)
44 | {
45 | var t = asyncResult as Task;
46 | return t.Result;
47 | }
48 |
49 | public Catalog GetRandomCatalog()
50 | {
51 | var random = new Random();
52 | var names = this.catalogService.GetCatalogNames().ToArray();
53 |
54 | var catalogName = names[random.Next(names.Length)];
55 |
56 | return this.catalogService.GetCatalog(catalogName);
57 | }
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/source/ServiceProxy.Zmq/README.md:
--------------------------------------------------------------------------------
1 | ServiceProxy.Zmq
2 | ============
3 |
4 | ServiceProxy.Zmq is a scalable request/reply messaging framework built with ZeroMQ that supports service contracts using ServiceProxy.
5 |
6 | ## Getting started
7 |
8 | The quickest way to get started is to use the [Nuget package][serviceproxy.zmq-nuget].
9 |
10 | ### Example from a unit test in ServiceProxy.Zmq.Tests
11 |
12 | ```c#
13 | public async void TestSendAndReceive()
14 | {
15 | var resolver = new DependencyResolver();
16 |
17 | using (var broker = new ZmqBroker(this.zmqContext, ClientInboundAddress, ClientOutboundAddress, ServerInboundAddress, ServerOutboundAddress))
18 | {
19 | broker.Listen();
20 |
21 | using (var server = new ZmqServer(this.zmqContext, ServerInboundAddress, ServerOutboundAddress, new ServiceFactory(resolver)))
22 | {
23 | server.Listen();
24 |
25 | using (var client = new ZmqClient(this.zmqContext, ClientInboundAddress, ClientOutboundAddress))
26 | {
27 | var clientFactory = new ServiceClientFactory(client);
28 |
29 | var serviceClient = clientFactory.CreateServiceClient();
30 |
31 | Assert.That(serviceClient.GetPerson(1), Is.Not.Null);
32 |
33 | var persons = await serviceClient.ListPersonsAsync(5);
34 | Assert.That(persons, Is.Not.Null);
35 | Assert.AreEqual(5, persons.Count());
36 | }
37 | }
38 | }
39 | }
40 | ```
41 |
42 | The ZmqClient, ZmqBroker and ZmqServer instances should be created in different processes/machines. It supports load balancing by having multiple ZmqServer instances connected to the ZmqBroker.
43 |
44 | ## Dependencies
45 |
46 | ServiceProxy.Zmq uses the [clrzmq][clrzmq-github] ZeroMQ binding for .NET. This version uses libzmq 3.2.2-rc2.
47 |
48 | [serviceproxy.zmq-nuget]: http://www.nuget.org/packages/ServiceProxy.Zmq
49 | [clrzmq-github]: https://github.com/zeromq/clrzmq
50 |
51 |
--------------------------------------------------------------------------------
/source/ServiceProxy.Redis/README.md:
--------------------------------------------------------------------------------
1 | ServiceProxy.Redis
2 | ============
3 |
4 | ServiceProxy.Redis is a simple request/reply messaging framework built on Redis queues that supports service contracts using ServiceProxy.
5 |
6 | ## Getting started
7 |
8 | The quickest way to get started is to use the [Nuget package][serviceproxy.redis-nuget].
9 |
10 | ### Example from a unit test in ServiceProxy.Redis.Tests
11 |
12 | ```c#
13 | public async void TestSendAndReceive()
14 | {
15 | var resolver = new DependencyResolver();
16 |
17 | using (var server = new RedisServer(new RedisConnection(RedisHost, RedisPort, RedisPassword), ServerQueue, new ServiceFactory(resolver)))
18 | {
19 | server.Listen();
20 |
21 | using (var client = new RedisClient(new RedisConnection(RedisHost, RedisPort, RedisPassword), ClientQueue, ServerQueue))
22 | {
23 | var clientFactory = new ServiceProxy.ServiceClientFactory(client);
24 |
25 | var serviceClient = clientFactory.CreateServiceClient();
26 |
27 | Assert.That(serviceClient.GetPerson(1), Is.Not.Null);
28 |
29 | var persons = await serviceClient.ListPersonsAsync(5);
30 | Assert.That(persons, Is.Not.Null);
31 | Assert.AreEqual(5, persons.Count());
32 | }
33 | }
34 | }
35 | ```
36 |
37 | The client and server should be created in different processes/machines, using Redis as a middleware and ServiceProxy to support service contracts.
38 |
39 | It supports load balancing by having multiple servers listening on the same Redis queue.
40 |
41 | ## Dependencies
42 |
43 | ServiceProxy.Redis now uses the [StackExchange.Redis][stackexchange.redis-github] client library, the successor of the [Booksleeve][booksleeve-home] Redis client library.
44 |
45 | [serviceproxy.redis-nuget]: http://www.nuget.org/packages/ServiceProxy.Redis
46 | [booksleeve-home]: https://code.google.com/p/booksleeve/
47 | [stackexchange.redis-github]: https://github.com/StackExchange/StackExchange.Redis
48 |
--------------------------------------------------------------------------------
/examples/MyApp/MyApp.WebAPI/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/source/ServiceProxy/ServiceFactory.cs:
--------------------------------------------------------------------------------
1 | using ServiceProxy.Internal;
2 | using System;
3 | using System.Collections.Concurrent;
4 | using System.Collections.Generic;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Threading;
8 | using System.Threading.Tasks;
9 |
10 | namespace ServiceProxy
11 | {
12 | public class ServiceFactory : IServiceFactory
13 | {
14 | private readonly IDependencyResolver resolver;
15 | //using Lazy with ConcurrentDictionary ensures that the CreateNewService method will only be invoked once per serviceType
16 | private readonly ConcurrentDictionary> services;
17 |
18 | private readonly ConcurrentDictionary serviceNamesMap;
19 |
20 | public ServiceFactory(IDependencyResolver resolver)
21 | {
22 | this.resolver = resolver;
23 | this.services = new ConcurrentDictionary>();
24 | this.serviceNamesMap = new ConcurrentDictionary();
25 | }
26 |
27 | public IService CreateService()
28 | where TService : class
29 | {
30 | return this.CreateService(typeof(TService));
31 | }
32 |
33 | public IService CreateService(string serviceName)
34 | {
35 | var serviceType = this.serviceNamesMap.GetOrAdd(serviceName, name => Type.GetType(name));
36 |
37 | return this.CreateService(serviceType);
38 | }
39 |
40 | public IService CreateService(Type serviceType)
41 | {
42 | var service = this.services.GetOrAdd(serviceType,
43 | type => new Lazy(() => this.CreateNewService(type), LazyThreadSafetyMode.ExecutionAndPublication));
44 | return service.Value;
45 | }
46 |
47 | private IService CreateNewService(Type serviceType)
48 | {
49 | return new Service(serviceType, this.resolver.Resolve(serviceType));
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/examples/Redis/Server/FooService.cs:
--------------------------------------------------------------------------------
1 | using ServiceContracts;
2 | using System;
3 | using System.Collections.Concurrent;
4 | using System.Collections.Generic;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 |
9 | namespace Server
10 | {
11 | public class FooService : IFooService
12 | {
13 | public Foo GetFoo(int id)
14 | {
15 | return FooDb.Get(id);
16 | }
17 |
18 | public IEnumerable ListFoos()
19 | {
20 | return FooDb.All();
21 | }
22 |
23 | public void UpdateFoo(Foo foo)
24 | {
25 | FooDb.Update(foo);
26 | }
27 |
28 | public Task GetFooAsync(int id)
29 | {
30 | return Task.FromResult(this.GetFoo(id));
31 | }
32 |
33 | public Task> ListFoosAsync()
34 | {
35 | return Task.FromResult(this.ListFoos());
36 | }
37 |
38 | public async Task UpdateFooAsync(Foo foo)
39 | {
40 | await Task.Delay(100); //lets introduce some latency
41 |
42 | this.UpdateFoo(foo);
43 | }
44 | }
45 |
46 | static class FooDb
47 | {
48 | static readonly ConcurrentDictionary foos;
49 |
50 | static FooDb()
51 | {
52 | var data = Enumerable.Range(1, 10)
53 | .Select(i => new Foo { Id = i, Name = string.Format("Foo {0}", i) });
54 |
55 | foos = new ConcurrentDictionary(data.ToDictionary(f => f.Id, f => f));
56 | }
57 |
58 | public static Foo Get(int id)
59 | {
60 | Foo foo;
61 | foos.TryGetValue(id, out foo);
62 | return foo;
63 | }
64 |
65 | public static void Update(Foo foo)
66 | {
67 | foos.AddOrUpdate(foo.Id, foo, (id, old) => foo);
68 | }
69 |
70 | public static IEnumerable All()
71 | {
72 | return foos.Values.ToArray();
73 | }
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/examples/MyApp/MyApp.Services/Model.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Runtime.Serialization;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace MyApp.Services
9 | {
10 | //The Serializable attributes are only necessary because the serializer being used by ServiceProxy.Zmq is the BinaryFormatter
11 | //This will be removed when/if support is added for different serializers
12 | //Note: ServiceProxy itself has no dependencies or notions of serialization
13 |
14 | [Serializable]
15 | [DataContract]
16 | public class Catalog
17 | {
18 | [DataMember]
19 | public string Name { get; set; }
20 |
21 | [DataMember]
22 | public IEnumerable- Items { get; set; }
23 | }
24 |
25 | [Serializable]
26 | [DataContract]
27 | public class Item
28 | {
29 | [DataMember]
30 | public string Code { get; set; }
31 |
32 | [DataMember]
33 | public string Description { get; set; }
34 |
35 | [DataMember]
36 | public decimal Price { get; set; }
37 | }
38 |
39 | [Serializable]
40 | [DataContract]
41 | public class ItemDetails
42 | {
43 | [DataMember]
44 | public Item Item { get; set; }
45 |
46 | [DataMember]
47 | public DateTime DateTimeField { get; set; }
48 | [DataMember]
49 | public int IntField { get; set; }
50 | [DataMember]
51 | public long LongField { get; set; }
52 | [DataMember]
53 | public double? NullableDoubleField { get; set; }
54 | [DataMember]
55 | public Guid GuidField { get; set; }
56 | [DataMember]
57 | public IEnumerable RandomTypeField { get; set; }
58 | }
59 |
60 | [Serializable]
61 | [DataContract]
62 | public class RandomType
63 | {
64 | [DataMember]
65 | public int[] IntArrayField { get; set; }
66 | [DataMember]
67 | public char CharField { get; set; }
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/source/ServiceProxy/Internal/TimeoutClient.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading;
6 | using System.Threading.Tasks;
7 |
8 | namespace ServiceProxy.Internal
9 | {
10 | public class TimeoutClient : IClient
11 | {
12 | private readonly IClient client;
13 | private readonly TimeSpan timeout;
14 |
15 | private readonly ResponseData timeoutResponse;
16 |
17 | public TimeoutClient(IClient client, TimeSpan timeout)
18 | {
19 | this.client = client;
20 | this.timeout = timeout;
21 | this.timeoutResponse = new ResponseData(new TimeoutException());
22 | }
23 |
24 | public Task Request(RequestData request, CancellationToken _)
25 | {
26 | var cancellation = new CancellationTokenSource(this.timeout);
27 |
28 | var responseTask = this.client.Request(request, cancellation.Token);
29 |
30 | var completion = new TaskCompletionSource();
31 |
32 | //when the token reaches timeout, tries to set the timeoutResponse as the result
33 | //if the responseTask already completed, this is ignored
34 | cancellation.Token.Register(() => completion.TrySetResult(this.timeoutResponse));
35 |
36 | //when the responseTask completes, tries to apply its exception/result properties as long as the timeout isn't reached
37 | responseTask.ContinueWith(t =>
38 | {
39 | if (!cancellation.IsCancellationRequested)
40 | {
41 | if (responseTask.Exception != null)
42 | {
43 | completion.TrySetException(responseTask.Exception.InnerException);
44 | }
45 | else
46 | {
47 | completion.TrySetResult(responseTask.Result);
48 | }
49 | }
50 | });
51 |
52 | return completion.Task;
53 | }
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Build Folders (you can keep bin if you'd like, to store dlls and pdbs)
2 | [Bb]in/
3 | [Oo]bj/
4 |
5 | # mstest test results
6 | TestResults
7 |
8 | ## Ignore Visual Studio temporary files, build results, and
9 | ## files generated by popular Visual Studio add-ons.
10 |
11 | # User-specific files
12 | *.suo
13 | *.user
14 | *.sln.docstates
15 |
16 | # Build results
17 | [Dd]ebug/
18 | [Rr]elease/
19 | x64/
20 | *_i.c
21 | *_p.c
22 | *.ilk
23 | *.meta
24 | *.obj
25 | *.dll
26 | *.dll.config
27 | *.pch
28 | *.pdb
29 | *.pgc
30 | *.pgd
31 | *.rsp
32 | *.sbr
33 | *.tlb
34 | *.tli
35 | *.tlh
36 | *.tmp
37 | *.log
38 | *.vspscc
39 | *.vssscc
40 | .builds
41 |
42 | # Visual C++ cache files
43 | ipch/
44 | *.aps
45 | *.ncb
46 | *.opensdf
47 | *.sdf
48 |
49 | # Visual Studio profiler
50 | *.psess
51 | *.vsp
52 | *.vspx
53 |
54 | # Guidance Automation Toolkit
55 | *.gpState
56 |
57 | # ReSharper is a .NET coding add-in
58 | _ReSharper*
59 |
60 | # NCrunch
61 | *.ncrunch*
62 | .*crunch*.local.xml
63 |
64 | # Installshield output folder
65 | [Ee]xpress
66 |
67 | # DocProject is a documentation generator add-in
68 | DocProject/buildhelp/
69 | DocProject/Help/*.HxT
70 | DocProject/Help/*.HxC
71 | DocProject/Help/*.hhc
72 | DocProject/Help/*.hhk
73 | DocProject/Help/*.hhp
74 | DocProject/Help/Html2
75 | DocProject/Help/html
76 |
77 | # Click-Once directory
78 | publish
79 |
80 | # Publish Web Output
81 | *.Publish.xml
82 |
83 | # NuGet Packages Directory
84 | packages
85 | *.nupkg
86 |
87 | # Windows Azure Build Output
88 | csx
89 | *.build.csdef
90 |
91 | # Windows Store app package directory
92 | AppPackages/
93 |
94 | # Others
95 | [Bb]in
96 | [Oo]bj
97 | sql
98 | TestResults
99 | [Tt]est[Rr]esult*
100 | *.Cache
101 | ClientBin
102 | [Ss]tyle[Cc]op.*
103 | ~$*
104 | *.dbmdl
105 | Generated_Code #added for RIA/Silverlight projects
106 |
107 | # Backup & report files from converting an old project file to a newer
108 | # Visual Studio version. Backup files are not needed, because we have git ;-)
109 | _UpgradeReport_Files/
110 | Backup*/
111 | UpgradeLog*.XML
112 |
--------------------------------------------------------------------------------
/examples/MyApp/MyApp.WebAPI/Controllers/FooController.cs:
--------------------------------------------------------------------------------
1 | using MyApp.Services;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Threading.Tasks;
6 | using System.Web;
7 | using System.Web.Http;
8 |
9 | namespace MyApp.WebAPI.Controllers
10 | {
11 | public class FooController : ApiController
12 | {
13 | private readonly IFooService fooService;
14 |
15 | public FooController(IFooService fooService)
16 | {
17 | this.fooService = fooService;
18 | }
19 |
20 | ///
21 | /// Invokes fooService.DoNothing
22 | ///
23 | public void DoNothing()
24 | {
25 | this.fooService.DoNothing();
26 | }
27 |
28 | ///
29 | /// Invokes fooService.AsyncOperationThatTakesTimeAndMayFail
30 | ///
31 | /// The time the operation will take to complete
32 | /// If true, the operation will complete with an exception
33 | ///
34 | public async Task AsyncOperationThatTakesTimeAndMayFail(int operationTime, bool fail)
35 | {
36 | await this.fooService.AsyncOperationThatTakesTimeAndMayFail(operationTime, fail);
37 | }
38 |
39 | ///
40 | /// Invokes fooService.BeginSum/EndSum to get the sum of two arguments
41 | ///
42 | ///
43 | ///
44 | ///
45 | public async Task Sum(int arg1, int arg2)
46 | {
47 | var sumResult = await Task.Factory.FromAsync(this.fooService.BeginSum, this.fooService.EndSum, arg1, arg2, null);
48 | return sumResult;
49 | }
50 |
51 | ///
52 | /// Invokes fooService.GetRandomCatalog to get a random catalog
53 | ///
54 | ///
55 | public Catalog GetRandomCatalog()
56 | {
57 | return this.fooService.GetRandomCatalog();
58 | }
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/source/ServiceProxy.Zmq/ZmqResponse.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace ServiceProxy.Zmq
8 | {
9 | ///
10 | /// Raw format: HeaderSize + Header + Data
11 | /// Header format: RequestId
12 | /// Data: Result
13 | ///
14 | class ZmqResponse
15 | {
16 | public ZmqResponse(string requestId, ResponseData response)
17 | {
18 | this.RequestId = requestId;
19 | this.Response = response;
20 | }
21 |
22 | public string RequestId { get; private set; }
23 | public ResponseData Response { get; private set; }
24 |
25 | public byte[] ToBinary()
26 | {
27 | var requestIdBytes = Encoding.UTF8.GetBytes(this.RequestId);
28 | var requestIdSizeBytes = BitConverter.GetBytes(requestIdBytes.Length);
29 |
30 | var responseBytes = ArrayExtensions.ToBinary(this.Response);
31 |
32 | var zmqResponseBytes = new byte[requestIdSizeBytes.Length + requestIdBytes.Length + responseBytes.Length];
33 |
34 | //Copy header size
35 | Array.Copy(requestIdSizeBytes, 0, zmqResponseBytes, 0, requestIdSizeBytes.Length);
36 |
37 | //Copy header
38 | Array.Copy(requestIdBytes, 0, zmqResponseBytes, requestIdSizeBytes.Length, requestIdBytes.Length);
39 |
40 | //Copy result
41 | Array.Copy(responseBytes, 0, zmqResponseBytes, requestIdSizeBytes.Length + requestIdBytes.Length, responseBytes.Length);
42 |
43 | return zmqResponseBytes;
44 |
45 | }
46 |
47 | public static ZmqResponse FromBinary(byte[] zmqResponseBytes)
48 | {
49 | var requestIdSize = BitConverter.ToInt32(zmqResponseBytes.Slice(0, 4), 0);
50 | var requestId = Encoding.UTF8.GetString(zmqResponseBytes.Slice(4, requestIdSize));
51 |
52 | var responseBytes = zmqResponseBytes.Slice(4 + requestIdSize, zmqResponseBytes.Length - (4 + requestIdSize));
53 | var response = ArrayExtensions.ToObject(responseBytes);
54 |
55 | return new ZmqResponse(requestId, response);
56 | }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/source/ServiceProxy.Zmq_old/ZmqResponse.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace ServiceProxy.Zmq
8 | {
9 | ///
10 | /// Raw format: HeaderSize + Header + Data
11 | /// Header format: RequestId
12 | /// Data: Result
13 | ///
14 | class ZmqResponse
15 | {
16 | public ZmqResponse(string requestId, ResponseData response)
17 | {
18 | this.RequestId = requestId;
19 | this.Response = response;
20 | }
21 |
22 | public string RequestId { get; private set; }
23 | public ResponseData Response { get; private set; }
24 |
25 | public byte[] ToBinary()
26 | {
27 | var requestIdBytes = Encoding.UTF8.GetBytes(this.RequestId);
28 | var requestIdSizeBytes = BitConverter.GetBytes(requestIdBytes.Length);
29 |
30 | var responseBytes = ArrayExtensions.ToBinary(this.Response);
31 |
32 | var zmqResponseBytes = new byte[requestIdSizeBytes.Length + requestIdBytes.Length + responseBytes.Length];
33 |
34 | //Copy header size
35 | Array.Copy(requestIdSizeBytes, 0, zmqResponseBytes, 0, requestIdSizeBytes.Length);
36 |
37 | //Copy header
38 | Array.Copy(requestIdBytes, 0, zmqResponseBytes, requestIdSizeBytes.Length, requestIdBytes.Length);
39 |
40 | //Copy result
41 | Array.Copy(responseBytes, 0, zmqResponseBytes, requestIdSizeBytes.Length + requestIdBytes.Length, responseBytes.Length);
42 |
43 | return zmqResponseBytes;
44 |
45 | }
46 |
47 | public static ZmqResponse FromBinary(byte[] zmqResponseBytes)
48 | {
49 | var requestIdSize = BitConverter.ToInt32(zmqResponseBytes.Slice(0, 4), 0);
50 | var requestId = Encoding.UTF8.GetString(zmqResponseBytes.Slice(4, requestIdSize));
51 |
52 | var responseBytes = zmqResponseBytes.Slice(4 + requestIdSize, zmqResponseBytes.Length - (4 + requestIdSize));
53 | var response = ArrayExtensions.ToObject(responseBytes);
54 |
55 | return new ZmqResponse(requestId, response);
56 | }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/source/ServiceProxy/ServiceClientFactory.cs:
--------------------------------------------------------------------------------
1 | using Castle.DynamicProxy;
2 | using ServiceProxy.Internal;
3 | using System;
4 | using System.Collections.Concurrent;
5 | using System.Collections.Generic;
6 | using System.Linq;
7 | using System.Reflection;
8 | using System.Text;
9 | using System.Threading;
10 | using System.Threading.Tasks;
11 |
12 | namespace ServiceProxy
13 | {
14 | public class ServiceClientFactory : IServiceClientFactory
15 | {
16 | private readonly ProxyGenerator proxyGenerator;
17 | //using Lazy with ConcurrentDictionary ensures that the GenerateClientProxy method will only be invoked once per serviceType
18 | private readonly ConcurrentDictionary> clients;
19 |
20 | private readonly IClient client;
21 |
22 | public ServiceClientFactory(IClient client)
23 | {
24 | this.proxyGenerator = new ProxyGenerator();
25 | this.clients = new ConcurrentDictionary>();
26 |
27 | this.client = client;
28 | }
29 |
30 | public TService CreateServiceClient(int? timeout = null)
31 | where TService : class
32 | {
33 | var serviceClient = (TService)this.CreateServiceClient(typeof(TService), timeout);
34 | return serviceClient;
35 | }
36 |
37 | public object CreateServiceClient(Type serviceType, int? timeout = null)
38 | {
39 | var client = this.clients.GetOrAdd(serviceType,
40 | type => new Lazy