Skip to content

Commit

Permalink
Added Rx extension library with tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Kralizek committed Sep 17, 2015
1 parent 874398e commit c591488
Show file tree
Hide file tree
Showing 13 changed files with 572 additions and 1 deletion.
14 changes: 14 additions & 0 deletions Nybus.sln
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".solution", ".solution", "{
README.md = README.md
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Rx", "src\Rx\Rx.csproj", "{06E735A3-A79C-4043-AB04-8449A2FBC1D2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests.Rx", "tests\Tests.Rx\Tests.Rx.csproj", "{5D7603F7-3F8F-429A-9258-91F8ED86447D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -83,6 +87,14 @@ Global
{72E3B663-AA36-4251-B9B6-E1172FC79FF7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{72E3B663-AA36-4251-B9B6-E1172FC79FF7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{72E3B663-AA36-4251-B9B6-E1172FC79FF7}.Release|Any CPU.Build.0 = Release|Any CPU
{06E735A3-A79C-4043-AB04-8449A2FBC1D2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{06E735A3-A79C-4043-AB04-8449A2FBC1D2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{06E735A3-A79C-4043-AB04-8449A2FBC1D2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{06E735A3-A79C-4043-AB04-8449A2FBC1D2}.Release|Any CPU.Build.0 = Release|Any CPU
{5D7603F7-3F8F-429A-9258-91F8ED86447D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5D7603F7-3F8F-429A-9258-91F8ED86447D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5D7603F7-3F8F-429A-9258-91F8ED86447D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5D7603F7-3F8F-429A-9258-91F8ED86447D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -98,5 +110,7 @@ Global
{0FE5606F-F8FE-42C6-B0C1-B91AECB53035} = {31BCDC74-9C21-495F-837D-FC1977CD9F8B}
{CF58265C-4A09-49CE-B250-5273171839A9} = {31BCDC74-9C21-495F-837D-FC1977CD9F8B}
{72E3B663-AA36-4251-B9B6-E1172FC79FF7} = {31BCDC74-9C21-495F-837D-FC1977CD9F8B}
{06E735A3-A79C-4043-AB04-8449A2FBC1D2} = {24B882E0-FB4F-476A-8844-06824472BEB0}
{5D7603F7-3F8F-429A-9258-91F8ED86447D} = {31BCDC74-9C21-495F-837D-FC1977CD9F8B}
EndGlobalSection
EndGlobal
1 change: 0 additions & 1 deletion src/Core/Configuration/IBusBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Threading.Tasks;
using Nybus.Container;

namespace Nybus.Configuration
{
Expand Down
36 changes: 36 additions & 0 deletions src/Rx/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
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("Rx")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Rx")]
[assembly: AssemblyCopyright("Copyright © 2015")]
[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("06e735a3-a79c-4043-ab04-8449a2fbc1d2")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// 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")]
54 changes: 54 additions & 0 deletions src/Rx/ReactiveExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reactive.Linq;
using System.Reactive.Subjects;
using System.Text;
using System.Threading.Tasks;
using Nybus.Configuration;

namespace Nybus
{
public static class ReactiveExtensions
{
public static IObservable<CommandContext<TCommand>> ObserveCommand<TCommand>(this IBusBuilder builder)
where TCommand : class, ICommand
{
ISubject<CommandContext<TCommand>> subject = new Subject<CommandContext<TCommand>>();

builder.SubscribeToCommand<TCommand>(msg =>
{
subject.OnNext(msg);
return Task.CompletedTask;
});

return subject;
}

public static IObservable<TCommand> Command<TCommand>(this IObservable<CommandContext<TCommand>> observable)
where TCommand : class, ICommand
{
return observable.Select(msg => msg.Message);
}

public static IObservable<EventContext<TEvent>> ObserveEvent<TEvent>(this IBusBuilder builder)
where TEvent : class, IEvent
{
ISubject<EventContext<TEvent>> subject = new Subject<EventContext<TEvent>>();

builder.SubscribeToEvent<TEvent>(msg =>
{
subject.OnNext(msg);
return Task.CompletedTask;
});

return subject;
}

public static IObservable<TEvent> Event<TEvent>(this IObservable<EventContext<TEvent>> observable)
where TEvent : class, IEvent
{
return observable.Select(msg => msg.Message);
}
}
}
80 changes: 80 additions & 0 deletions src/Rx/Rx.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{06E735A3-A79C-4043-AB04-8449A2FBC1D2}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Nybus</RootNamespace>
<AssemblyName>Nybus.Rx</AssemblyName>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Reactive.Core, Version=2.2.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\Packages\Rx-Core.2.2.5\lib\net45\System.Reactive.Core.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Reactive.Interfaces, Version=2.2.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\Packages\Rx-Interfaces.2.2.5\lib\net45\System.Reactive.Interfaces.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Reactive.Linq, Version=2.2.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\Packages\Rx-Linq.2.2.5\lib\net45\System.Reactive.Linq.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ReactiveExtensions.cs" />
</ItemGroup>
<ItemGroup>
<None Include="Rx.nuspec" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Core\Core.csproj">
<Project>{fe8fb759-5499-4731-a279-623c8ef6ee1d}</Project>
<Name>Core</Name>
</ProjectReference>
<ProjectReference Include="..\Interfaces\Interfaces.csproj">
<Project>{c858bab7-00f9-4629-9aa1-a2ddefad5543}</Project>
<Name>Interfaces</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
22 changes: 22 additions & 0 deletions src/Rx/Rx.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>Nybus.Rx</id>
<version>$version$</version>
<title>Nybus Rx</title>
<authors>Renato Golia</authors>
<owners>Renato Golia</owners>
<licenseUrl>https://github.com/Nybus-project/Nybus/blob/master/LICENSE</licenseUrl>
<projectUrl>https://github.com/Nybus-project/Nybus</projectUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Rx support for Nybus.</description>
<language>en-US</language>
<dependencies>
<dependency id="Rx-Linq" version="2.2.5" />
</dependencies>
<frameworkAssemblies>
<frameworkAssembly assemblyName="System.Runtime" />
<frameworkAssembly assemblyName="System.Threading.Tasks" />
</frameworkAssemblies>
</metadata>
</package>
6 changes: 6 additions & 0 deletions src/Rx/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Rx-Core" version="2.2.5" targetFramework="net46" />
<package id="Rx-Interfaces" version="2.2.5" targetFramework="net46" />
<package id="Rx-Linq" version="2.2.5" targetFramework="net46" />
</packages>
36 changes: 36 additions & 0 deletions tests/Tests.Rx/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
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("Tests.Rx")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Tests.Rx")]
[assembly: AssemblyCopyright("Copyright © 2015")]
[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("5d7603f7-3f8f-429a-9258-91f8ed86447d")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// 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")]
Loading

0 comments on commit c591488

Please sign in to comment.