Skip to content

Commit

Permalink
Moving to Green Pipes for pipe context usage
Browse files Browse the repository at this point in the history
  • Loading branch information
phatboyg committed Sep 15, 2016
1 parent f247cd0 commit 93f54de
Show file tree
Hide file tree
Showing 55 changed files with 232 additions and 960 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@
<Compile Include="Vanilla_Specs.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\GreenPipes\src\GreenPipes\GreenPipes.csproj">
<Project>{59052db9-b527-4683-a56a-56c4d8fb6584}</Project>
<Name>GreenPipes</Name>
</ProjectReference>
<ProjectReference Include="..\Automatonymous.NHibernateIntegration\Automatonymous.NHibernateIntegration.csproj">
<Project>{c0932502-0847-4966-8d0a-2ca80b1669ed}</Project>
<Name>Automatonymous.NHibernateIntegration</Name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@
<Compile Include="UserTypes\StringStateUserTypeConverter.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\GreenPipes\src\GreenPipes\GreenPipes.csproj">
<Project>{59052db9-b527-4683-a56a-56c4d8fb6584}</Project>
<Name>GreenPipes</Name>
</ProjectReference>
<ProjectReference Include="..\Automatonymous\Automatonymous.csproj">
<Project>{fd8f92eb-5818-4c59-8859-19d3a74f979b}</Project>
<Name>Automatonymous</Name>
Expand Down
4 changes: 4 additions & 0 deletions src/Automatonymous.Tests/Automatonymous.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@
<Compile Include="FilterExpression_Specs.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\GreenPipes\src\GreenPipes\GreenPipes.csproj">
<Project>{59052db9-b527-4683-a56a-56c4d8fb6584}</Project>
<Name>GreenPipes</Name>
</ProjectReference>
<ProjectReference Include="..\Automatonymous.Visualizer\Automatonymous.Visualizer.csproj">
<Project>{CD346A24-EEBB-493C-AAC0-E9896340B66A}</Project>
<Name>Automatonymous.Visualizer</Name>
Expand Down
7 changes: 5 additions & 2 deletions src/Automatonymous.Tests/StateChangeObserver.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2011-2015 Chris Patterson, Dru Sellers
// Copyright 2011-2016 Chris Patterson, Dru Sellers
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use
// this file except in compliance with the License. You may obtain a copy of the
Expand All @@ -14,6 +14,7 @@ namespace Automatonymous.Tests
{
using System.Collections.Generic;
using System.Threading.Tasks;
using GreenPipes.Util;


class StateChangeObserver<T> :
Expand All @@ -27,9 +28,11 @@ public StateChangeObserver()

public IList<StateChange> Events { get; private set; }

public async Task StateChanged(InstanceContext<T> context, State currentState, State previousState)
public Task StateChanged(InstanceContext<T> context, State currentState, State previousState)
{
Events.Add(new StateChange(context, currentState, previousState));

return TaskUtil.Completed;
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@
<Compile Include="StateMachineGraphGenerator.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\GreenPipes\src\GreenPipes\GreenPipes.csproj">
<Project>{59052db9-b527-4683-a56a-56c4d8fb6584}</Project>
<Name>GreenPipes</Name>
</ProjectReference>
<ProjectReference Include="..\Automatonymous\Automatonymous.csproj">
<Project>{FD8F92EB-5818-4C59-8859-19D3A74F979B}</Project>
<Name>Automatonymous</Name>
Expand Down
8 changes: 7 additions & 1 deletion src/Automatonymous.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.23107.0
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Automatonymous", "Automatonymous\Automatonymous.csproj", "{FD8F92EB-5818-4C59-8859-19D3A74F979B}"
EndProject
Expand All @@ -24,6 +24,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{2EF18B
.nuget\NuGet.targets = .nuget\NuGet.targets
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GreenPipes", "..\..\GreenPipes\src\GreenPipes\GreenPipes.csproj", "{59052DB9-B527-4683-A56A-56C4D8FB6584}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -50,6 +52,10 @@ Global
{06A25528-1537-4E70-85E2-CC979B924417}.Debug|Any CPU.Build.0 = Debug|Any CPU
{06A25528-1537-4E70-85E2-CC979B924417}.Release|Any CPU.ActiveCfg = Release|Any CPU
{06A25528-1537-4E70-85E2-CC979B924417}.Release|Any CPU.Build.0 = Release|Any CPU
{59052DB9-B527-4683-A56A-56C4D8FB6584}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{59052DB9-B527-4683-A56A-56C4D8FB6584}.Debug|Any CPU.Build.0 = Debug|Any CPU
{59052DB9-B527-4683-A56A-56C4D8FB6584}.Release|Any CPU.ActiveCfg = Release|Any CPU
{59052DB9-B527-4683-A56A-56C4D8FB6584}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
1 change: 1 addition & 0 deletions src/Automatonymous.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<s:Int64 x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/BLANK_LINES_AROUND_TYPE/@EntryValue">2</s:Int64>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/EXPLICIT_INTERNAL_MODIFIER/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/EXPLICIT_PRIVATE_MODIFIER/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/OLD_ENGINE/@EntryValue">True</s:Boolean>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SIMPLE_EMBEDDED_STATEMENT_STYLE/@EntryValue">LINE_BREAK</s:String>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SPACE_AFTER_TYPECAST_PARENTHESES/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SPACE_AROUND_MULTIPLICATIVE_OP/@EntryValue">True</s:Boolean>
Expand Down
6 changes: 3 additions & 3 deletions src/Automatonymous/Accessors/InitialIfNullStateAccessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ public InitialIfNullStateAccessor(State<TInstance> initialState, StateAccessor<T

async Task<State<TInstance>> StateAccessor<TInstance>.Get(InstanceContext<TInstance> context)
{
State<TInstance> state = await _stateAccessor.Get(context);
State<TInstance> state = await _stateAccessor.Get(context).ConfigureAwait(false);
if (state == null)
{
var behaviorContext = new EventBehaviorContext<TInstance>(context);

await _initialBehavior.Execute(behaviorContext);
await _initialBehavior.Execute(behaviorContext).ConfigureAwait(false);

state = await _stateAccessor.Get(context);
state = await _stateAccessor.Get(context).ConfigureAwait(false);
}
return state;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2011-2015 Chris Patterson, Dru Sellers
// Copyright 2011-2016 Chris Patterson, Dru Sellers
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use
// this file except in compliance with the License. You may obtain a copy of the
Expand All @@ -13,7 +13,7 @@
namespace Automatonymous.Accessors
{
using System.Reflection;
using Internals;
using GreenPipes.Internals.Reflection;


public class IntCompositeEventStatusAccessor<TInstance> :
Expand Down
6 changes: 4 additions & 2 deletions src/Automatonymous/Accessors/IntStateAccessor.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2011-2015 Chris Patterson, Dru Sellers
// Copyright 2011-2016 Chris Patterson, Dru Sellers
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use
// this file except in compliance with the License. You may obtain a copy of the
Expand All @@ -16,7 +16,9 @@ namespace Automatonymous.Accessors
using System.Linq.Expressions;
using System.Reflection;
using System.Threading.Tasks;
using Internals;
using GreenPipes.Internals.Extensions;
using GreenPipes.Internals.Reflection;
using GreenPipes.Util;


/// <summary>
Expand Down
6 changes: 4 additions & 2 deletions src/Automatonymous/Accessors/RawStateAccessor.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2011-2015 Chris Patterson, Dru Sellers
// Copyright 2011-2016 Chris Patterson, Dru Sellers
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use
// this file except in compliance with the License. You may obtain a copy of the
Expand All @@ -16,7 +16,9 @@ namespace Automatonymous.Accessors
using System.Linq.Expressions;
using System.Reflection;
using System.Threading.Tasks;
using Internals;
using GreenPipes.Internals.Extensions;
using GreenPipes.Internals.Reflection;
using GreenPipes.Util;


public class RawStateAccessor<TInstance> :
Expand Down
7 changes: 5 additions & 2 deletions src/Automatonymous/Accessors/StringStateAccessor.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2011-2015 Chris Patterson, Dru Sellers
// Copyright 2011-2016 Chris Patterson, Dru Sellers
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use
// this file except in compliance with the License. You may obtain a copy of the
Expand All @@ -16,7 +16,10 @@ namespace Automatonymous.Accessors
using System.Linq.Expressions;
using System.Reflection;
using System.Threading.Tasks;
using Internals;
using GreenPipes.Internals.Extensions;
using GreenPipes.Internals.Reflection;
using GreenPipes.Util;


/// <summary>
/// Accesses the current state as a string property
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2011-2015 Chris Patterson, Dru Sellers
// Copyright 2011-2016 Chris Patterson, Dru Sellers
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use
// this file except in compliance with the License. You may obtain a copy of the
Expand All @@ -13,7 +13,7 @@
namespace Automatonymous.Accessors
{
using System.Reflection;
using Internals;
using GreenPipes.Internals.Reflection;


public class StructCompositeEventStatusAccessor<TInstance> :
Expand Down
6 changes: 3 additions & 3 deletions src/Automatonymous/Activities/ActionActivity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ async Task Activity<TInstance>.Execute(BehaviorContext<TInstance> context, Behav
{
_action(context);

await next.Execute(context);
await next.Execute(context).ConfigureAwait(false);
}

async Task Activity<TInstance>.Execute<TData>(BehaviorContext<TInstance, TData> context, Behavior<TInstance, TData> next)
{
_action(context);

await next.Execute(context);
await next.Execute(context).ConfigureAwait(false);
}

Task Activity<TInstance>.Faulted<TException>(BehaviorExceptionContext<TInstance, TException> context, Behavior<TInstance> next)
Expand Down Expand Up @@ -76,7 +76,7 @@ async Task Activity<TInstance, TData>.Execute(BehaviorContext<TInstance, TData>
{
_action(context);

await next.Execute(context);
await next.Execute(context).ConfigureAwait(false);
}

Task Activity<TInstance, TData>.Faulted<TException>(BehaviorExceptionContext<TInstance, TData, TException> context, Behavior<TInstance, TData> next)
Expand Down
12 changes: 6 additions & 6 deletions src/Automatonymous/Activities/AsyncActivity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,16 @@ void Visitable.Accept(StateMachineVisitor visitor)

async Task Activity<TInstance>.Execute(BehaviorContext<TInstance> context, Behavior<TInstance> next)
{
await _asyncAction(context);
await _asyncAction(context).ConfigureAwait(false);

await next.Execute(context);
await next.Execute(context).ConfigureAwait(false);
}

async Task Activity<TInstance>.Execute<TData>(BehaviorContext<TInstance, TData> context, Behavior<TInstance, TData> next)
{
await _asyncAction(context);
await _asyncAction(context).ConfigureAwait(false);

await next.Execute(context);
await next.Execute(context).ConfigureAwait(false);
}

Task Activity<TInstance>.Faulted<TException>(BehaviorExceptionContext<TInstance, TException> context, Behavior<TInstance> next)
Expand Down Expand Up @@ -75,9 +75,9 @@ void Visitable.Accept(StateMachineVisitor visitor)

async Task Activity<TInstance, TData>.Execute(BehaviorContext<TInstance, TData> context, Behavior<TInstance, TData> next)
{
await _asyncAction(context);
await _asyncAction(context).ConfigureAwait(false);

await next.Execute(context);
await next.Execute(context).ConfigureAwait(false);
}

Task Activity<TInstance, TData>.Faulted<TException>(BehaviorExceptionContext<TInstance, TData, TException> context,
Expand Down
12 changes: 6 additions & 6 deletions src/Automatonymous/Activities/AsyncFactoryActivity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ void Visitable.Accept(StateMachineVisitor visitor)

async Task Activity<TInstance, TData>.Execute(BehaviorContext<TInstance, TData> context, Behavior<TInstance, TData> next)
{
Activity<TInstance, TData> activity = await _activityFactory(context);
Activity<TInstance, TData> activity = await _activityFactory(context).ConfigureAwait(false);

await activity.Execute(context, next);
await activity.Execute(context, next).ConfigureAwait(false);
}

Task Activity<TInstance, TData>.Faulted<TException>(BehaviorExceptionContext<TInstance, TData, TException> context,
Expand Down Expand Up @@ -64,18 +64,18 @@ void Visitable.Accept(StateMachineVisitor visitor)

async Task Activity<TInstance>.Execute(BehaviorContext<TInstance> context, Behavior<TInstance> next)
{
Activity<TInstance> activity = await _activityFactory(context);
Activity<TInstance> activity = await _activityFactory(context).ConfigureAwait(false);

await activity.Execute(context, next);
await activity.Execute(context, next).ConfigureAwait(false);
}

async Task Activity<TInstance>.Execute<T>(BehaviorContext<TInstance, T> context, Behavior<TInstance, T> next)
{
Activity<TInstance> activity = await _activityFactory(context);
Activity<TInstance> activity = await _activityFactory(context).ConfigureAwait(false);

var upconvert = new WidenBehavior<TInstance, T>(next, context);

await activity.Execute(context, upconvert);
await activity.Execute(context, upconvert).ConfigureAwait(false);
}

Task Activity<TInstance>.Faulted<TException>(BehaviorExceptionContext<TInstance, TException> context, Behavior<TInstance> next)
Expand Down
12 changes: 6 additions & 6 deletions src/Automatonymous/Activities/CatchFaultActivity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ async Task Activity<TInstance>.Faulted<T>(BehaviorExceptionContext<TInstance, T>
var exceptionContext = context as BehaviorExceptionContext<TInstance, TException>;
if (exceptionContext != null)
{
await _behavior.Faulted(exceptionContext);
await _behavior.Faulted(exceptionContext).ConfigureAwait(false);

// if the compensate returns, we should go forward normally
await next.Execute(context);
await next.Execute(context).ConfigureAwait(false);
}
else
await next.Faulted(context);
await next.Faulted(context).ConfigureAwait(false);
}

async Task Activity<TInstance>.Faulted<TData, T>(BehaviorExceptionContext<TInstance, TData, T> context,
Expand All @@ -68,13 +68,13 @@ async Task Activity<TInstance>.Faulted<TData, T>(BehaviorExceptionContext<TInsta
var exceptionContext = context as BehaviorExceptionContext<TInstance, TData, TException>;
if (exceptionContext != null)
{
await _behavior.Faulted(exceptionContext);
await _behavior.Faulted(exceptionContext).ConfigureAwait(false);

// if the compensate returns, we should go forward normally
await next.Execute(context);
await next.Execute(context).ConfigureAwait(false);
}
else
await next.Faulted(context);
await next.Faulted(context).ConfigureAwait(false);
}
}
}
15 changes: 8 additions & 7 deletions src/Automatonymous/Activities/CompositeEventActivity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ namespace Automatonymous.Activities
{
using System.Threading.Tasks;
using Accessors;
using GreenPipes.Util;


public class CompositeEventActivity<TInstance> :
Expand Down Expand Up @@ -42,29 +43,29 @@ void Visitable.Accept(StateMachineVisitor visitor)

async Task Activity<TInstance>.Execute(BehaviorContext<TInstance> context, Behavior<TInstance> next)
{
await Execute(context);
await Execute(context).ConfigureAwait(false);

await next.Execute(context);
await next.Execute(context).ConfigureAwait(false);
}

async Task Activity<TInstance>.Execute<TData>(BehaviorContext<TInstance, TData> context, Behavior<TInstance, TData> next)
{
await Execute(context);
await Execute(context).ConfigureAwait(false);

await next.Execute(context);
await next.Execute(context).ConfigureAwait(false);
}

async Task Execute(BehaviorContext<TInstance> context)
Task Execute(BehaviorContext<TInstance> context)
{
CompositeEventStatus value = _accessor.Get(context.Instance);
value.Set(_flag);

_accessor.Set(context.Instance, value);

if (!value.Equals(_complete))
return;
return TaskUtil.Completed;

await RaiseCompositeEvent(context);
return RaiseCompositeEvent(context);
}

Task RaiseCompositeEvent(BehaviorContext<TInstance> context)
Expand Down
4 changes: 2 additions & 2 deletions src/Automatonymous/Activities/DataConverterActivity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Task Activity<TInstance>.Execute(BehaviorContext<TInstance> context, Behavior<TI
throw new AutomatonymousException("This activity requires a body with the event, but no body was specified.");
}

async Task Activity<TInstance>.Execute<T>(BehaviorContext<TInstance, T> context, Behavior<TInstance, T> next)
Task Activity<TInstance>.Execute<T>(BehaviorContext<TInstance, T> context, Behavior<TInstance, T> next)
{
var dataContext = context as BehaviorContext<TInstance, TData>;
if (dataContext == null)
Expand All @@ -45,7 +45,7 @@ async Task Activity<TInstance>.Execute<T>(BehaviorContext<TInstance, T> context,
if (dataNext == null)
throw new AutomatonymousException("The next behavior was not a valid type");

await _activity.Execute(dataContext, dataNext);
return _activity.Execute(dataContext, dataNext);
}

Task Activity<TInstance>.Faulted<TException>(BehaviorExceptionContext<TInstance, TException> context, Behavior<TInstance> next)
Expand Down
Loading

0 comments on commit 93f54de

Please sign in to comment.