Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reorienting ShortBus to mediation semantics #22

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 13 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
ShortBus is an in-process mediator with low-friction API

### Command

public class DoSomething : ICommand { }

public class DoesSomething : ICommandHandler<DoSomething> {
public void Handle(DoSomething command) {
// does something
}
}
public class DoesSomething : ICommandHandler<DoSomething> {
public void Handle(DoSomething command) {
// does something
}
}

_mediator.Send(new DoSomething());

Expand All @@ -17,14 +18,14 @@ ShortBus is an in-process mediator with low-friction API
### Query
public class AskAQuestion : IQuery<Answer> { }

public class Answerer : IQueryHandler<AskAQuestion, Answer> {
public Answer Handle(AskAQuestion query) {
return answer;
}
}
public class Answerer : IQueryHandler<AskAQuestion, Answer> {
public Answer Handle(AskAQuestion query) {
return answer;
}
}

var answer = _mediator.Request(new AskAQuestion());
var answer = _mediator.Request(new AskAQuestion());
### StructureMap
ShortBus depends on StructureMap and it requires that you register
handlers:
Expand Down
15 changes: 8 additions & 7 deletions ShortBus.Autofac.nuspec
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?xml version="1.0"?>

<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<version>1.0.0</version>
<authors>ShortBus community</authors>
<authors>ShortBus community</authors>
<owners>mhinze</owners>
<licenseUrl>https://github.com/mhinze/ShortBus/blob/master/LICENSE.md</licenseUrl>
<projectUrl>https://github.com/mhinze/ShortBus</projectUrl>
Expand All @@ -12,13 +13,13 @@
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>ShortBus is an in-process mediator with low-friction API</description>
<summary>ShortBus is an in-process mediator with low-friction API</summary>
<copyright>Copyright Matt Hinze 2013</copyright>
<copyright>Copyright Matt Hinze 2014</copyright>
<dependencies>
<dependency id="ShortBus.Markers" version="3.0.0" />
<dependency id="ShortBus" version="3.0.0" />
<dependency id="ShortBus.Markers" version="3.0.0" />
<dependency id="ShortBus" version="3.0.0" />
</dependencies>
</metadata>
<files>
<file src="ShortBus.Autofac\bin\Release\ShortBus.Autofac.dll" target="lib"/>
</files>
<files>
<file src="ShortBus.Autofac\bin\Release\ShortBus.Autofac.dll" target="lib" />
</files>
</package>
8 changes: 7 additions & 1 deletion ShortBus.Autofac/AutofacDependencyResolver.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
namespace ShortBus.Autofac
{
using System;
using System.Collections.Generic;
using global::Autofac;

public class AutofacDependencyResolver : IDependencyResolver
{
readonly ILifetimeScope _container;
private readonly ILifetimeScope _container;

public AutofacDependencyResolver(ILifetimeScope container)
{
Expand All @@ -16,5 +17,10 @@ public object GetInstance(Type type)
{
return _container.Resolve(type);
}

public IEnumerable<T> GetInstances<T>()
{
return _container.Resolve<IEnumerable<T>>();
}
}
}
7 changes: 5 additions & 2 deletions ShortBus.Autofac/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.

[assembly: AssemblyTitle("ShortBus.Autofac")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
Expand All @@ -17,9 +17,11 @@
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.

[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM

[assembly: Guid("d043983c-3a10-4b36-8739-980f32c93401")]

// Version information for an assembly consists of the following four values:
Expand All @@ -32,5 +34,6 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]

[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
1 change: 1 addition & 0 deletions ShortBus.Autofac/packages.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>

<packages>
<package id="Autofac" version="3.1.5" targetFramework="net45" />
</packages>
9 changes: 5 additions & 4 deletions ShortBus.Markers.nuspec
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?xml version="1.0"?>

<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<version>1.0.0</version>
Expand All @@ -12,9 +13,9 @@
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>ShortBus is an in-process mediator with low-friction API</description>
<summary>ShortBus is an in-process mediator with low-friction API</summary>
<copyright>Copyright Matt Hinze 2013</copyright>
<copyright>Copyright Matt Hinze 2014</copyright>
</metadata>
<files>
<file src="ShortBus.Markers\bin\Release\ShortBus.Markers.dll" target="lib"/>
</files>
<files>
<file src="ShortBus.Markers\bin\Release\ShortBus.Markers.dll" target="lib" />
</files>
</package>
6 changes: 0 additions & 6 deletions ShortBus.Markers/IAsyncCommand.cs

This file was deleted.

4 changes: 0 additions & 4 deletions ShortBus.Markers/IAsyncQuery.cs

This file was deleted.

4 changes: 4 additions & 0 deletions ShortBus.Markers/IAsyncRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
namespace ShortBus
{
public interface IAsyncRequest<TResponseData> {}
}
6 changes: 0 additions & 6 deletions ShortBus.Markers/ICommand.cs

This file was deleted.

4 changes: 0 additions & 4 deletions ShortBus.Markers/IQuery.cs

This file was deleted.

4 changes: 4 additions & 0 deletions ShortBus.Markers/IRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
namespace ShortBus
{
public interface IRequest<TResponseData> {}
}
9 changes: 6 additions & 3 deletions ShortBus.Markers/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.

[assembly: AssemblyTitle("ShortBus.Markers")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ShortBus.Markers")]
[assembly: AssemblyCopyright("Copyright © 2012")]
[assembly: AssemblyCopyright("Copyright © 2014")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.

[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM

[assembly: Guid("a6579898-beb7-480d-89d9-a3515bee169f")]

// Version information for an assembly consists of the following four values:
Expand All @@ -32,5 +34,6 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]

[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
6 changes: 2 additions & 4 deletions ShortBus.Markers/ShortBus.Markers.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,8 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="IAsyncCommand.cs" />
<Compile Include="IAsyncQuery.cs" />
<Compile Include="ICommand.cs" />
<Compile Include="IQuery.cs" />
<Compile Include="IAsyncRequest.cs" />
<Compile Include="IRequest.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="UnitType.cs" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion ShortBus.Markers/UnitType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ public sealed class UnitType
{
public static readonly UnitType Default = new UnitType();

UnitType() { }
private UnitType() {}
}
}
15 changes: 8 additions & 7 deletions ShortBus.Ninject.nuspec
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?xml version="1.0"?>

<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<version>1.0.0</version>
<authors>ShortBus community</authors>
<authors>ShortBus community</authors>
<owners>mhinze</owners>
<licenseUrl>https://github.com/mhinze/ShortBus/blob/master/LICENSE.md</licenseUrl>
<projectUrl>https://github.com/mhinze/ShortBus</projectUrl>
Expand All @@ -12,13 +13,13 @@
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>ShortBus is an in-process mediator with low-friction API</description>
<summary>ShortBus is an in-process mediator with low-friction API</summary>
<copyright>Copyright Matt Hinze 2013</copyright>
<copyright>Copyright Matt Hinze 2014</copyright>
<dependencies>
<dependency id="ShortBus.Markers" version="3.0.0" />
<dependency id="ShortBus" version="3.0.0" />
<dependency id="ShortBus.Markers" version="3.0.0" />
<dependency id="ShortBus" version="3.0.0" />
</dependencies>
</metadata>
<files>
<file src="ShortBus.Ninject\bin\Release\ShortBus.Ninject.dll" target="lib"/>
</files>
<files>
<file src="ShortBus.Ninject\bin\Release\ShortBus.Ninject.dll" target="lib" />
</files>
</package>
8 changes: 7 additions & 1 deletion ShortBus.Ninject/NinjectDependencyResolver.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
namespace ShortBus.Ninject
{
using System;
using System.Collections.Generic;
using global::Ninject;

public class NinjectDependencyResolver : IDependencyResolver
{
readonly IKernel _container;
private readonly IKernel _container;

public NinjectDependencyResolver(IKernel container)
{
Expand All @@ -16,5 +17,10 @@ public object GetInstance(Type type)
{
return _container.Get(type);
}

public IEnumerable<T> GetInstances<T>()
{
return _container.GetAll<T>();
}
}
}
7 changes: 5 additions & 2 deletions ShortBus.Ninject/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.

[assembly: AssemblyTitle("ShortBus.Ninject")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
Expand All @@ -17,9 +17,11 @@
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.

[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM

[assembly: Guid("44900dbc-c446-453c-966a-d985b47cecb7")]

// Version information for an assembly consists of the following four values:
Expand All @@ -32,5 +34,6 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]

[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
1 change: 1 addition & 0 deletions ShortBus.Ninject/packages.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>

<packages>
<package id="Ninject" version="3.0.1.10" targetFramework="net45" />
</packages>
15 changes: 8 additions & 7 deletions ShortBus.StructureMap.nuspec
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?xml version="1.0"?>

<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<version>1.0.0</version>
<authors>ShortBus community</authors>
<authors>ShortBus community</authors>
<owners>mhinze</owners>
<licenseUrl>https://github.com/mhinze/ShortBus/blob/master/LICENSE.md</licenseUrl>
<projectUrl>https://github.com/mhinze/ShortBus</projectUrl>
Expand All @@ -12,13 +13,13 @@
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>ShortBus is an in-process mediator with low-friction API</description>
<summary>ShortBus is an in-process mediator with low-friction API</summary>
<copyright>Copyright Matt Hinze 2013</copyright>
<copyright>Copyright Matt Hinze 2014</copyright>
<dependencies>
<dependency id="ShortBus.Markers" version="3.0.0" />
<dependency id="ShortBus" version="3.0.0" />
<dependency id="ShortBus.Markers" version="3.0.0" />
<dependency id="ShortBus" version="3.0.0" />
</dependencies>
</metadata>
<files>
<file src="ShortBus.StructureMap\bin\Release\ShortBus.StructureMap.dll" target="lib"/>
</files>
<files>
<file src="ShortBus.StructureMap\bin\Release\ShortBus.StructureMap.dll" target="lib" />
</files>
</package>
Loading