Skip to content
This repository has been archived by the owner on Aug 8, 2020. It is now read-only.

Commit

Permalink
phatboyg changes
Browse files Browse the repository at this point in the history
  • Loading branch information
drusellers committed Jul 19, 2010
2 parents 1aeddd7 + 5704c0e commit 157b111
Show file tree
Hide file tree
Showing 54 changed files with 1,072 additions and 339 deletions.
1 change: 1 addition & 0 deletions src/Magnum.Infrastructure/Magnum.Infrastructure.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
<WarningLevel>4</WarningLevel>
<DocumentationFile>..\..\bin\Magnum.Infrastructure.XML</DocumentationFile>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
<NoWarn>1591</NoWarn>
</PropertyGroup>
<ItemGroup>
<Reference Include="Castle.Core, Version=1.0.3.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL">
Expand Down
4 changes: 2 additions & 2 deletions src/Magnum.Logging.Log4Net/Magnum.Logging.Log4Net.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<OutputPath>..\..\bin\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
Expand All @@ -45,7 +45,7 @@
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<OutputPath>..\..\bin\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
Expand Down
1 change: 1 addition & 0 deletions src/Magnum.RulesEngine/Magnum.RulesEngine.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
<WarningLevel>4</WarningLevel>
<DocumentationFile>..\..\bin\Magnum.RulesEngine.XML</DocumentationFile>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
<NoWarn>1591</NoWarn>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
Expand Down
1 change: 1 addition & 0 deletions src/Magnum.Specs/Actions/ActionQueue_Specs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public void Should_result_in_no_waiting_actions_in_the_queue()
public class Running_all_actions_using_a_thread_queue
{
[Test]
[Category("Slow")]
public void Should_result_in_no_waiting_actions_in_the_queue()
{
Fiber fiber = new ThreadFiber();
Expand Down
1 change: 1 addition & 0 deletions src/Magnum.Specs/Actors/PingPongDemo/PingPong_Demo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ namespace Magnum.Specs.Actors.PingPongDemo
using NUnit.Framework;

[TestFixture]
[Category("Slow")]
public class PingPong_Demo
{
[SetUp]
Expand Down
4 changes: 2 additions & 2 deletions src/Magnum.Specs/Channels/ChannelVisitor_Specs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public void Should_capture_the_interval_channel()
public void Should_capture_the_instance_channel()
{
var provider = new DelegateChannelProvider<int>(x => new ConsumerChannel<int>(new SynchronousFiber(), y => { }));
var channel = new InstanceChannel<int>(provider);
var channel = new InstanceChannel<int>(new SynchronousFiber(), provider);

new ChannelVisitor().Visit(channel);
}
Expand All @@ -43,7 +43,7 @@ public void Should_capture_the_instance_channel_with_thread_provider()
{
var provider = new DelegateChannelProvider<int>(x => new ConsumerChannel<int>(new SynchronousFiber(), y => { }));
var threadProvider = new ThreadStaticChannelProvider<int>(provider);
var channel = new InstanceChannel<int>(threadProvider);
var channel = new InstanceChannel<int>(new SynchronousFiber(), threadProvider);

new ChannelVisitor().Visit(channel);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Magnum.Specs/Channels/Connect_Specs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ public void Should_allow_the_consumer_channel_type()
using (input.Connect(x =>
{
x.AddConsumerOf<TestMessage>()
.OnCurrentSynchronizationContext()
.UsingConsumer(message => { })
.ExecuteOnThreadPoolFiber()
.UseCurrentSychronizationContext();
.ExecuteOnThreadPoolFiber();
}))
{
}
Expand Down
19 changes: 12 additions & 7 deletions src/Magnum.Specs/Channels/ConsumerInstance_Specs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ namespace Magnum.Specs.Channels
{
using System;
using System.Threading;
using Fibers;
using Magnum.Channels;
using Magnum.Extensions;
using NUnit.Framework;
using Rhino.Mocks;
using TestFramework;


[TestFixture]
public class Sending_a_message_to_an_instance_consumer
{
Expand All @@ -34,7 +36,7 @@ public void Should_create_a_new_consumer_instance_for_each_message()
var provider = MockRepository.GenerateMock<ChannelProvider<MyMessage>>();
provider.Expect(x => x.GetChannel(message)).Return(result).Repeat.Twice();

var channel = new InstanceChannel<MyMessage>(provider);
var channel = new InstanceChannel<MyMessage>(new SynchronousFiber(), provider);

channel.Send(message);
channel.Send(message);
Expand All @@ -56,7 +58,8 @@ public void Should_pull_the_matching_instance_from_the_cace()

KeyAccessor<MyMessage, Guid> messageKeyAccessor = x => x.Id;

var channel = new InstanceChannel<MyMessage>(new KeyedChannelProvider<MyMessage, Guid>(provider, messageKeyAccessor));
var channel = new InstanceChannel<MyMessage>(new SynchronousFiber(),
new KeyedChannelProvider<MyMessage, Guid>(provider, messageKeyAccessor));

channel.Send(message);
channel.Send(message);
Expand All @@ -78,7 +81,8 @@ public void Should_work_for_primitive_types_shorty()

KeyAccessor<int, int> messageKeyAccessor = x => x;

var channel = new InstanceChannel<int>(new KeyedChannelProvider<int, int>(provider, messageKeyAccessor));
var channel = new InstanceChannel<int>(new SynchronousFiber(),
new KeyedChannelProvider<int, int>(provider, messageKeyAccessor));


channel.Send(message);
Expand All @@ -88,7 +92,8 @@ public void Should_work_for_primitive_types_shorty()
result.VerifyAllExpectations();
}

[Test, Category("Slow")]
[Test]
[Category("Slow")]
public void Should_work_for_thread_static_instances()
{
int message = 27;
Expand All @@ -99,10 +104,10 @@ public void Should_work_for_thread_static_instances()
var provider = MockRepository.GenerateMock<ChannelProvider<int>>();
provider.Expect(x => x.GetChannel(message)).Return(result).Repeat.Twice();

var channel = new InstanceChannel<int>(new ThreadStaticChannelProvider<int>(provider));
var channel = new InstanceChannel<int>(new SynchronousFiber(), new ThreadStaticChannelProvider<int>(provider));

Future<bool> first = new Future<bool>();
Future<bool> second = new Future<bool>();
var first = new Future<bool>();
var second = new Future<bool>();
var started = new Future<bool>();

ThreadPool.QueueUserWorkItem(x =>
Expand Down
4 changes: 2 additions & 2 deletions src/Magnum.Specs/Channels/SynchronizationContext_Specs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public void Should_properly_wrap_the_channel_as_synchronized()
using (input.Connect(x =>
{
x.AddConsumerOf<TestMessage>()
.OnCurrentSynchronizationContext()
.UsingConsumer(message =>
{
Trace.WriteLine("Received on Thread: " + Thread.CurrentThread.ManagedThreadId);
Expand All @@ -53,8 +54,7 @@ public void Should_properly_wrap_the_channel_as_synchronized()
Assert.AreEqual(context, SynchronizationContext.Current);
future.Complete(message);
})
.UseCurrentSychronizationContext();
});
}))
{
Trace.WriteLine("Subscribed on Thread: " + Thread.CurrentThread.ManagedThreadId);
Expand Down
10 changes: 7 additions & 3 deletions src/Magnum.Specs/Configuration/ConfigurationOverridesSpecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,17 @@ public void Configuration_values_are_read_from_a_series_of_json_files()
File.Delete("global.json");
if (File.Exists("local.json"))
File.Delete("local.json");
if (File.Exists("config.json"))
File.Delete("config.json");

const string globalConf = @"{ key1: ""global-value-1"", key2: ""global-value-2""}";
const string localConf = @"{ key1: ""local-value-1""}";
const string configConf = @"{ key3: ""config-value-3""}";


File.AppendAllText("global.json", globalConf);
File.AppendAllText("local.json", localConf);
File.AppendAllText("config.json", configConf);

_binder = ConfigurationBinderFactory.New(x =>
{
Expand All @@ -48,7 +52,7 @@ public void Configuration_values_are_read_from_a_series_of_json_files()
x.AddJsonFile("global.json");
x.AddJsonFile("local.json");
x.AddJsonFile(".\\Configuration\\config.json");
x.AddJsonFile("config.json");
});
}

Expand All @@ -59,11 +63,11 @@ public void A_local_value_should_override_a_global_value()
value.ShouldEqual("local-value-1");
}

[Then, Ignore("odd")]
[Then]
public void A_stupid_file()
{
string value = _binder.GetValueAsString("key3");
value.ShouldBeEqualTo("from-file");
value.ShouldBeEqualTo("config-value-3");
}
}
}
1 change: 0 additions & 1 deletion src/Magnum.Specs/Configuration/config.json

This file was deleted.

6 changes: 4 additions & 2 deletions src/Magnum.Web/Magnum.Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<OutputPath>..\..\bin\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
Expand All @@ -45,11 +45,13 @@
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<OutputPath>..\..\bin\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
<NoWarn>1591</NoWarn>
<DocumentationFile>bin\Release\Magnum.Web.XML</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@
// specific language governing permissions and limitations under the License.
namespace Magnum.Channels.Configuration
{
using Internal;


public interface ChannelConnectionConfigurator
{
void SetChannelConfigurator(ChannelConfigurator configurator);
}


Expand All @@ -23,6 +27,6 @@ public interface ChannelConnectionConfigurator
/// <typeparam name="TChannel">The channel type</typeparam>
public interface ChannelConnectionConfigurator<TChannel>
{
ChannelConnectionConfigurator<TChannel> SetChannelFactory(ChannelFactory<TChannel> channelFactory);
void SetChannelConfigurator(ChannelConfigurator<TChannel> configurator);
}
}
17 changes: 1 addition & 16 deletions src/Magnum/Channels/Configuration/ExtensionsForAddConsumer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace Magnum.Channels
public static class ExtensionsForAddConsumer
{
/// <summary>
/// Configures a new consumer
/// Add a consumer of the specified message type
/// </summary>
/// <typeparam name="TChannel">The channel type</typeparam>
/// <returns>A chainable method to configure additional options</returns>
Expand All @@ -32,20 +32,5 @@ public static ChannelConnectionConfigurator<TChannel> AddConsumerOf<TChannel>(

return configurator;
}

public static ConsumerChannelConfigurator<TChannel> AddConsumer<TChannel>(
this ConnectionConfigurator<TChannel> connectionConfigurator,
Consumer<TChannel> consumer)
{
var channelConfigurator = new ChannelConnectionConfiguratorImpl<TChannel>();

connectionConfigurator.RegisterChannelConfigurator(channelConfigurator);

var configurator = new ConsumerChannelConfiguratorImpl<TChannel>(consumer);

channelConfigurator.SetChannelFactory(configurator);

return configurator;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,24 @@ namespace Magnum.Channels

public static class ExtensionsForConsumerChannel
{
/// <summary>
/// Add a consumer to the channel using the message type defined for the channel
/// </summary>
/// <typeparam name="TChannel">The channel type, specifies the type of message sent by the channel</typeparam>
/// <param name="connectionConfigurator">The connection configurator</param>
/// <param name="consumer">The consumer to add to the channel</param>
/// <returns>A consumer configurator to customize the consumer settings</returns>
public static ConsumerChannelConfigurator<TChannel> AddConsumer<TChannel>(
this ConnectionConfigurator<TChannel> connectionConfigurator,
Consumer<TChannel> consumer)
{
var configurator = new ConsumerChannelConfiguratorImpl<TChannel>(consumer);

connectionConfigurator.RegisterChannelConfigurator(configurator);

return configurator;
}

/// <summary>
/// Consumes the message on a ConsumerChannel, given the specified delegate
/// </summary>
Expand All @@ -29,7 +47,7 @@ public static ConsumerChannelConfigurator<TChannel> UsingConsumer<TChannel>(
{
var consumerConfigurator = new ConsumerChannelConfiguratorImpl<TChannel>(consumer);

configurator.SetChannelFactory(consumerConfigurator);
configurator.SetChannelConfigurator(consumerConfigurator);

return consumerConfigurator;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public static DistinctChannelConfigurator<TChannel, TKey> Distinct<TChannel, TKe
{
var intervalConfigurator = new DistinctChannelConfiguratorImpl<TChannel, TKey>(keyAccessor);

configurator.SetChannelFactory(intervalConfigurator);
configurator.SetChannelConfigurator(intervalConfigurator);

return intervalConfigurator;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public static ChannelConnectionConfigurator<TChannel> Where<TChannel>(
{
var filterConfigurator = new FilterChannelConfiguratorImpl<TChannel>(filter);

configurator.SetChannelFactory(filterConfigurator);
configurator.SetChannelConfigurator(filterConfigurator);

return filterConfigurator;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public static InstanceChannelConfigurator<TChannel> UsingInstance<TChannel>(
{
var instanceConfigurator = new InstanceChannelConfiguratorImpl<TChannel>();

configurator.SetChannelFactory(instanceConfigurator);
configurator.SetChannelConfigurator(instanceConfigurator);

return instanceConfigurator;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public static IntervalChannelConfigurator<TChannel> BufferFor<TChannel>(
{
var intervalConfigurator = new IntervalChannelConfiguratorImpl<TChannel>(interval);

configurator.SetChannelFactory(intervalConfigurator);
configurator.SetChannelConfigurator(intervalConfigurator);

return intervalConfigurator;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public static LastChannelConfigurator<TChannel> Last<TChannel>(
{
var lastConfigurator = new LastChannelConfiguratorImpl<TChannel>();

configurator.SetChannelFactory(lastConfigurator);
configurator.SetChannelConfigurator(lastConfigurator);

return lastConfigurator;
}
Expand Down
Loading

0 comments on commit 157b111

Please sign in to comment.