Skip to content

Commit

Permalink
some changes from today will put in gitignore tonight I hope
Browse files Browse the repository at this point in the history
  • Loading branch information
unknown committed Nov 24, 2010
1 parent 0f54fd4 commit 77902c8
Show file tree
Hide file tree
Showing 42 changed files with 495 additions and 385 deletions.
92 changes: 90 additions & 2 deletions EventHandler.5.1.ReSharper.user
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,70 @@
</boolean>
</SettingsComponent>
<RecentFiles>
<RecentFiles />
<RecentEdits />
<RecentFiles>
<File id="A852309C-564E-47DC-B046-A7183F295D25/f:ProjectionHost.cs" caret="0" fromTop="0" />
<File id="A852309C-564E-47DC-B046-A7183F295D25/f:TypeFinder.cs" caret="540" fromTop="16" />
<File id="B4EBBFC1-A4B7-4F90-86CF-B73E1E6674B1/f:IQueue.cs" caret="0" fromTop="0" />
<File id="B4EBBFC1-A4B7-4F90-86CF-B73E1E6674B1/f:InMemQueue.cs" caret="0" fromTop="0" />
<File id="B4EBBFC1-A4B7-4F90-86CF-B73E1E6674B1/f:Extensions.cs" caret="513" fromTop="18" />
<File id="B4EBBFC1-A4B7-4F90-86CF-B73E1E6674B1/f:EventAggregator.cs" caret="0" fromTop="0" />
<File id="B4EBBFC1-A4B7-4F90-86CF-B73E1E6674B1/f:CriticalSection.cs" caret="0" fromTop="0" />
<File id="B4EBBFC1-A4B7-4F90-86CF-B73E1E6674B1/f:ActionWrappingConsumer.cs" caret="0" fromTop="0" />
<File id="B4EBBFC1-A4B7-4F90-86CF-B73E1E6674B1/f:ByTypeDispatcher.cs" caret="0" fromTop="0" />
<File id="B4EBBFC1-A4B7-4F90-86CF-B73E1E6674B1/f:Consumes.cs" caret="0" fromTop="0" />
<File id="B4EBBFC1-A4B7-4F90-86CF-B73E1E6674B1/f:Combiner.cs" caret="0" fromTop="0" />
<File id="B4EBBFC1-A4B7-4F90-86CF-B73E1E6674B1/f:NarrowingConsumer.cs" caret="0" fromTop="0" />
<File id="B4EBBFC1-A4B7-4F90-86CF-B73E1E6674B1/f:PipeAdapter.cs" caret="167" fromTop="5" />
<File id="B4EBBFC1-A4B7-4F90-86CF-B73E1E6674B1/f:QueueReader.cs" caret="0" fromTop="0" />
<File id="B4EBBFC1-A4B7-4F90-86CF-B73E1E6674B1/f:QueueWriter.cs" caret="0" fromTop="0" />
<File id="B4EBBFC1-A4B7-4F90-86CF-B73E1E6674B1/f:ThreadBoundary.cs" caret="566" fromTop="21" />
<File id="B4EBBFC1-A4B7-4F90-86CF-B73E1E6674B1/f:UnableToAcquireLockException.cs" caret="0" fromTop="0" />
<File id="B4EBBFC1-A4B7-4F90-86CF-B73E1E6674B1/f:WideningConsumer.cs" caret="0" fromTop="0" />
<File id="B4EBBFC1-A4B7-4F90-86CF-B73E1E6674B1/f:BufferMessages.cs" caret="807" fromTop="37" />
<File id="B4EBBFC1-A4B7-4F90-86CF-B73E1E6674B1/f:Multiplexor.cs" caret="0" fromTop="0" />
<File id="B4EBBFC1-A4B7-4F90-86CF-B73E1E6674B1/f:Message.cs" caret="40" fromTop="2" />
<File id="0452212F-EB0E-43AB-80EA-48AF7656B7B4/d:Messages/f:OtherMessage.cs" caret="80" fromTop="9" />
<File id="0452212F-EB0E-43AB-80EA-48AF7656B7B4/d:Messages/f:TestMessage.cs" caret="32" fromTop="2" />
<File id="0452212F-EB0E-43AB-80EA-48AF7656B7B4/f:ByTypeDispatcherTests.cs" caret="93" fromTop="6" />
<File id="0452212F-EB0E-43AB-80EA-48AF7656B7B4/f:ConsumerFixture.cs" caret="432" fromTop="17" />
<File id="0452212F-EB0E-43AB-80EA-48AF7656B7B4/f:MultiplexorTests.cs" caret="39" fromTop="1" />
<File id="0452212F-EB0E-43AB-80EA-48AF7656B7B4/f:TestConsumer.cs" caret="0" fromTop="0" />
<File id="0452212F-EB0E-43AB-80EA-48AF7656B7B4/f:TestConsumerTests.cs" caret="2070" fromTop="94" />
<File id="0452212F-EB0E-43AB-80EA-48AF7656B7B4/f:WindeningConsumerTests.cs" caret="39" fromTop="1" />
<File id="A852309C-564E-47DC-B046-A7183F295D25/f:ActivatorProjectionCreator.cs" caret="13" fromTop="0" />
</RecentFiles>
<RecentEdits>
<File id="A852309C-564E-47DC-B046-A7183F295D25/f:IEventLog.cs" caret="69" fromTop="3" />
<File id="A852309C-564E-47DC-B046-A7183F295D25/f:IChecksumStorage.cs" caret="11" fromTop="0" />
<File id="A852309C-564E-47DC-B046-A7183F295D25/f:IProjectionCreator.cs" caret="29" fromTop="2" />
<File id="A852309C-564E-47DC-B046-A7183F295D25/f:TypeFinder.cs" caret="87" fromTop="4" />
<File id="B4EBBFC1-A4B7-4F90-86CF-B73E1E6674B1/f:BufferMessages.cs" caret="33" fromTop="0" />
<File id="B4EBBFC1-A4B7-4F90-86CF-B73E1E6674B1/f:BufferMessages.cs" caret="88" fromTop="4" />
<File id="B4EBBFC1-A4B7-4F90-86CF-B73E1E6674B1/f:Message.cs" caret="40" fromTop="2" />
<File id="0452212F-EB0E-43AB-80EA-48AF7656B7B4/f:ConsumerFixture.cs" caret="578" fromTop="15" />
<File id="0452212F-EB0E-43AB-80EA-48AF7656B7B4/f:ConsumerFixture.cs" caret="578" fromTop="54" />
<File id="0452212F-EB0E-43AB-80EA-48AF7656B7B4/f:TestConsumer.cs" caret="803" fromTop="63" />
<File id="0452212F-EB0E-43AB-80EA-48AF7656B7B4/f:ByTypeDispatcherTests.cs" caret="1283" fromTop="72" />
<File id="0452212F-EB0E-43AB-80EA-48AF7656B7B4/f:MultiplexorTests.cs" caret="2774" fromTop="128" />
<File id="0452212F-EB0E-43AB-80EA-48AF7656B7B4/f:MultiplexorTests.cs" caret="476" fromTop="17" />
<File id="0452212F-EB0E-43AB-80EA-48AF7656B7B4/f:ConsumerFixture.cs" caret="0" fromTop="0" />
<File id="0452212F-EB0E-43AB-80EA-48AF7656B7B4/f:TestConsumer.cs" caret="308" fromTop="13" />
<File id="0452212F-EB0E-43AB-80EA-48AF7656B7B4/f:TestConsumer.cs" caret="0" fromTop="0" />
<File id="0452212F-EB0E-43AB-80EA-48AF7656B7B4/f:TestConsumerTests.cs" caret="0" fromTop="0" />
<File id="0452212F-EB0E-43AB-80EA-48AF7656B7B4/f:WindeningConsumerTests.cs" caret="0" fromTop="0" />
<File id="0452212F-EB0E-43AB-80EA-48AF7656B7B4/f:WindeningConsumerTests.cs" caret="257" fromTop="7" />
<File id="0452212F-EB0E-43AB-80EA-48AF7656B7B4/d:Messages/f:OtherMessage.cs" caret="69" fromTop="4" />
<File id="0452212F-EB0E-43AB-80EA-48AF7656B7B4/d:Messages/f:OtherMessage.cs" caret="83" fromTop="9" />
<File id="0452212F-EB0E-43AB-80EA-48AF7656B7B4/d:Messages/f:TestMessage.cs" caret="224" fromTop="10" />
<File id="0452212F-EB0E-43AB-80EA-48AF7656B7B4/d:Messages/f:TestMessage.cs" caret="32" fromTop="2" />
<File id="0452212F-EB0E-43AB-80EA-48AF7656B7B4/f:ByTypeDispatcherTests.cs" caret="280" fromTop="11" />
<File id="0452212F-EB0E-43AB-80EA-48AF7656B7B4/f:ByTypeDispatcherTests.cs" caret="590" fromTop="19" />
<File id="0452212F-EB0E-43AB-80EA-48AF7656B7B4/f:ByTypeDispatcherTests.cs" caret="41" fromTop="2" />
<File id="0452212F-EB0E-43AB-80EA-48AF7656B7B4/f:TestConsumerTests.cs" caret="2070" fromTop="94" />
<File id="0452212F-EB0E-43AB-80EA-48AF7656B7B4/f:MultiplexorTests.cs" caret="39" fromTop="1" />
<File id="0452212F-EB0E-43AB-80EA-48AF7656B7B4/f:WindeningConsumerTests.cs" caret="85" fromTop="4" />
<File id="A852309C-564E-47DC-B046-A7183F295D25/f:ActivatorProjectionCreator.cs" caret="13" fromTop="0" />
</RecentEdits>
</RecentFiles>
<NAntValidationSettings>
<NAntPath value="" />
Expand All @@ -20,4 +82,30 @@
<NUnitInstallDir>C:\Program Files (x86)\NUnit 2.5.3\bin\net-2.0\</NUnitInstallDir>
<UseAddins>Never</UseAddins>
</UnitTestRunnerNUnit>
<CompletionStatisticsManager>
<ItemStatistics item="Default">
<Item value="public" priority="1" />
<Item value="static" priority="1" />
<Item value="Action`0" priority="0" />
<Item value="ThreadBoundary" priority="1" />
<Item value="this" priority="1" />
<Item value="Consumes" priority="4" />
<Item value="T`0" priority="0" />
<Item value="where" priority="1" />
<Item value="Message`0" priority="1" />
<Item value="return" priority="3" />
<Item value="new" priority="0" />
<Item value="Multiplexor" priority="0" />
<Item value="var" priority="0" />
<Item value="produces" priority="1" />
<Item value="multi" priority="0" />
<Item value="TBase`0" priority="0" />
</ItemStatistics>
<ItemStatistics item="Qualified:pvc.Core.Consumes`1">
<Item value="Handle`0" priority="1" />
</ItemStatistics>
<ItemStatistics item="Qualified:pvc.Core.Produces`1">
<Item value="AttachConsumer`0" priority="0" />
</ItemStatistics>
</CompletionStatisticsManager>
</Configuration>
Binary file modified EventHandler.suo
Binary file not shown.
9 changes: 5 additions & 4 deletions pvc.Core/ActionWrappingConsumer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ public class ActionWrappingConsumer<T> : Consumes<T> where T:Message
public void Handle(T message) {
_action(message);
}
public ActionWrappingConsumer (Action<T> action)
{
_action = action;
}
public ActionWrappingConsumer (Action<T> action)
{
if (action == null) throw new ArgumentNullException("action");
_action = action;
}
}
}
40 changes: 25 additions & 15 deletions pvc.Core/Extensions.cs
Original file line number Diff line number Diff line change
@@ -1,23 +1,33 @@
using System;
namespace pvc.Core
{
public static class Extensions
{
public static Consumes<T> AsConsumer<T>(this Action<T> action) where T:Message {
return new ActionWrappingConsumer<T>(action);
}

using System;
namespace pvc.Core
{
public static class Extensions
{
public static Consumes<T> AsConsumer<T>(this Action<T> action) where T:Message
{
if (action == null) throw new ArgumentNullException("action");
return new ActionWrappingConsumer<T>(action);
}

public static Action<T> AsAction<T>(this Consumes<T> consumer) where T:Message
{
if (consumer == null) throw new ArgumentNullException("consumer");
return consumer.Handle;
}

}

public static void TryConsume<T>(this Consumes<T> consumer, T message) where T:Message
{
if (consumer == null) return;
consumer.Handle(message);
}

public static Produces<T> AcceptingMany<T>(this Produces<T> produces) where T: Message
{
if (produces == null) throw new ArgumentNullException("produces");
var multi = new Multiplexor<T>();
produces.AttachConsumer(multi);
return multi;
}
}
}

}
}
}
Binary file modified pvc.Core/bin/Debug/pvc.Core.dll
Binary file not shown.
Binary file modified pvc.Core/bin/Debug/pvc.Core.pdb
Binary file not shown.
Binary file modified pvc.Core/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache
Binary file not shown.
10 changes: 5 additions & 5 deletions pvc.Core/obj/Debug/pvc.Core.csproj.FileListAbsolute.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
C:\sode\Event-handling\pvc.Core\bin\Debug\pvc.Core.dll
C:\sode\Event-handling\pvc.Core\bin\Debug\pvc.Core.pdb
C:\sode\Event-handling\pvc.Core\obj\Debug\ResolveAssemblyReference.cache
C:\sode\Event-handling\pvc.Core\obj\Debug\pvc.Core.dll
C:\sode\Event-handling\pvc.Core\obj\Debug\pvc.Core.pdb
C:\sode\Spikes\PayoutSpike\lib\Event-handling\pvc.Core\bin\Debug\pvc.Core.dll
C:\sode\Spikes\PayoutSpike\lib\Event-handling\pvc.Core\bin\Debug\pvc.Core.pdb
C:\sode\Spikes\PayoutSpike\lib\Event-handling\pvc.Core\obj\Debug\ResolveAssemblyReference.cache
C:\sode\Spikes\PayoutSpike\lib\Event-handling\pvc.Core\obj\Debug\pvc.Core.dll
C:\sode\Spikes\PayoutSpike\lib\Event-handling\pvc.Core\obj\Debug\pvc.Core.pdb
Binary file modified pvc.Core/obj/Debug/pvc.Core.dll
Binary file not shown.
Binary file modified pvc.Core/obj/Debug/pvc.Core.pdb
Binary file not shown.
3 changes: 3 additions & 0 deletions pvc.Core/pvc.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,11 @@
<Compile Include="Combiner.cs" />
<Compile Include="CriticalSection.cs" />
<Compile Include="EventAggregator.cs" />
<Compile Include="IMessagePublisher.cs" />
<Compile Include="InMemQueue.cs" />
<Compile Include="IQueue.cs" />
<Compile Include="MessagePublisher.cs" />
<Compile Include="NullConsumer.cs" />
<Compile Include="Produces.cs" />
<Compile Include="QueueReader.cs" />
<Compile Include="QueueWriter.cs" />
Expand Down
1 change: 0 additions & 1 deletion pvc.Projections/ActivatorProjectionCreator.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using pvc.Core;

namespace pvc.Projections
{
Expand Down
4 changes: 2 additions & 2 deletions pvc.Projections/ProjectionHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ public void SetUpProjections()
if (typeDef.Equals(typeof(Consumes<>)))
{
var messageType = genericInterface.GetGenericArguments();
MethodInfo method = typeof(EventAggregator<Message>).GetMethod("SubscribeTo");
MethodInfo generic = method.MakeGenericMethod(messageType);
var method = typeof(EventAggregator<Message>).GetMethod("SubscribeTo");
var generic = method.MakeGenericMethod(messageType);
generic.Invoke(_aggregator, new [] {projector});
}
}
Expand Down
2 changes: 1 addition & 1 deletion pvc.Projections/TypeFinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public static IEnumerable<Type> GetTypesMatching<TAttribute>() where TAttribute
return (from assembly in assemblies
from item in assembly.GetTypes()
where !item.IsAbstract && item.IsClass && item.GetCustomAttributes(typeof (TAttribute), false).Length > 0
select item).ToList();
select item);
}
}
}
Binary file modified pvc.Projections/bin/Debug/pvc.Core.dll
Binary file not shown.
Binary file modified pvc.Projections/bin/Debug/pvc.Core.pdb
Binary file not shown.
Binary file modified pvc.Projections/bin/Debug/pvc.Projections.dll
Binary file not shown.
Binary file modified pvc.Projections/bin/Debug/pvc.Projections.pdb
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
C:\sode\Event-handling\pvc.Projections\bin\Debug\pvc.Projections.dll
C:\sode\Event-handling\pvc.Projections\bin\Debug\pvc.Projections.pdb
C:\sode\Event-handling\pvc.Projections\bin\Debug\pvc.Core.dll
C:\sode\Event-handling\pvc.Projections\bin\Debug\pvc.Core.pdb
C:\sode\Event-handling\pvc.Projections\obj\Debug\ResolveAssemblyReference.cache
C:\sode\Event-handling\pvc.Projections\obj\Debug\pvc.Projections.dll
C:\sode\Event-handling\pvc.Projections\obj\Debug\pvc.Projections.pdb
C:\sode\Spikes\PayoutSpike\lib\Event-handling\pvc.Projections\bin\Debug\pvc.Projections.dll
C:\sode\Spikes\PayoutSpike\lib\Event-handling\pvc.Projections\bin\Debug\pvc.Projections.pdb
C:\sode\Spikes\PayoutSpike\lib\Event-handling\pvc.Projections\bin\Debug\pvc.Core.dll
C:\sode\Spikes\PayoutSpike\lib\Event-handling\pvc.Projections\bin\Debug\pvc.Core.pdb
C:\sode\Spikes\PayoutSpike\lib\Event-handling\pvc.Projections\obj\Debug\ResolveAssemblyReference.cache
C:\sode\Spikes\PayoutSpike\lib\Event-handling\pvc.Projections\obj\Debug\pvc.Projections.dll
C:\sode\Spikes\PayoutSpike\lib\Event-handling\pvc.Projections\obj\Debug\pvc.Projections.pdb
Binary file modified pvc.Projections/obj/Debug/pvc.Projections.dll
Binary file not shown.
Binary file modified pvc.Projections/obj/Debug/pvc.Projections.pdb
Binary file not shown.
4 changes: 4 additions & 0 deletions pvc.Projections/pvc.Projections.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
<SccProjectName>SAK</SccProjectName>
<SccLocalPath>SAK</SccLocalPath>
<SccAuxPath>SAK</SccAuxPath>
<SccProvider>SAK</SccProvider>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand Down
84 changes: 42 additions & 42 deletions pvc.Tests/ByTypeDispatcherTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,45 +3,45 @@
using pvc.Core;
using pvc.Tests.Messages;

namespace pvc.Tests
{
public class when_dispatching_a_message : ConsumerFixture<Message> {
TestConsumer<TestMessage> correctSubscriber;
TestConsumer<OtherMessage> incorrectSubscriber;
TestConsumer<BaseMessage> baseClassSubscriber;


protected override Consumes<Message> GivenConsumer ()
{
var dispatcher = new ByTypeDispatcher<Message>();
correctSubscriber = new TestConsumer<TestMessage>();
incorrectSubscriber = new TestConsumer<OtherMessage>();
baseClassSubscriber = new TestConsumer<BaseMessage>();
dispatcher.Subscribe(correctSubscriber);
dispatcher.Subscribe(incorrectSubscriber);
dispatcher.Subscribe(baseClassSubscriber);
return dispatcher;
}

protected override Message When ()
{
return new TestMessage();
}

[Test]
public void exactly_subscribed_consumer_receives_correct_message() {
Assert.AreEqual(published, correctSubscriber.OnlyMessageReceived);
}

[Test]
public void other_consumer_did_not_receive_message() {
Assert.IsFalse(incorrectSubscriber.WasCalled);
}

[Test]
public void base_subscribed_consumer_receives_correct_message() {
Assert.AreEqual(published, baseClassSubscriber.OnlyMessageReceived);
}
}
}

namespace pvc.Tests
{
public class when_dispatching_a_message : ConsumerFixture<Message> {
TestConsumer<TestMessage> correctSubscriber;
TestConsumer<OtherMessage> incorrectSubscriber;
TestConsumer<BaseMessage> baseClassSubscriber;


protected override Consumes<Message> GivenConsumer ()
{
var dispatcher = new ByTypeDispatcher<Message>();
correctSubscriber = new TestConsumer<TestMessage>();
incorrectSubscriber = new TestConsumer<OtherMessage>();
baseClassSubscriber = new TestConsumer<BaseMessage>();
dispatcher.Subscribe(correctSubscriber);
dispatcher.Subscribe(incorrectSubscriber);
dispatcher.Subscribe(baseClassSubscriber);
return dispatcher;
}

protected override Message When ()
{
return new TestMessage();
}

[Test]
public void exactly_subscribed_consumer_receives_correct_message() {
Assert.AreEqual(published, correctSubscriber.OnlyMessageReceived);
}

[Test]
public void other_consumer_did_not_receive_message() {
Assert.IsFalse(incorrectSubscriber.WasCalled);
}

[Test]
public void base_subscribed_consumer_receives_correct_message() {
Assert.AreEqual(published, baseClassSubscriber.OnlyMessageReceived);
}
}
}
48 changes: 24 additions & 24 deletions pvc.Tests/ConsumerFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,28 @@
using NUnit.Framework;
using pvc.Core;

namespace pvc.Tests
{
public abstract class ConsumerFixture<TMessage> where TMessage : Message
{
protected abstract Consumes<TMessage> GivenConsumer();
namespace pvc.Tests
{
public abstract class ConsumerFixture<TMessage> where TMessage : Message
{
protected abstract Consumes<TMessage> GivenConsumer();
protected Exception caught;
protected abstract TMessage When();
protected Consumes<TMessage> consumer;
protected TMessage published;

[SetUp]
public void SetUp() {
consumer = GivenConsumer();
try {
published = When();
if(published != null)
consumer.Handle(published);
}
catch(Exception Ex) {
caught = Ex;
}
}
}
}

protected abstract TMessage When();
protected Consumes<TMessage> consumer;
protected TMessage published;

[SetUp]
public virtual void SetUp() {
consumer = GivenConsumer();
try {
published = When();
if(published != null)
consumer.Handle(published);
}
catch(Exception Ex) {
caught = Ex;
}
}
}
}
Loading

0 comments on commit 77902c8

Please sign in to comment.