Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,13 @@ public ILightTransitionReactiveNodeConfigurator AddCycle<T>(IObservable<T> trigg
configure(compositeCycleConfigurator);
configurators.ForEach(kvp => kvp.Value.AddNodeSource(triggerObservable.ToCycleObservable(cycleConfigurators[kvp.Key].CycleNodeFactories.Select(tuple =>
{
var serviceScope = serviceProvider.CreateScope();
var context = new LightPipelineContext(serviceScope.ServiceProvider, kvp.Value.Light);
var factory = new Func<IPipelineNode<LightTransition>>(() => new ScopedNode<LightTransition>(serviceScope, tuple.nodeFactory(context)));
var valueIsActiveFunc = () => tuple.matchesNodeState(context);
var factory = new Func<IPipelineNode<LightTransition>>(() =>
{
var serviceScope = serviceProvider.CreateScope();
var context = new LightPipelineContext(serviceScope.ServiceProvider, kvp.Value.Light);
return new ScopedNode<LightTransition>(serviceScope, tuple.nodeFactory(context));
});
var valueIsActiveFunc = () => tuple.matchesNodeState(new LightPipelineContext(serviceProvider, kvp.Value.Light));
return (factory, valueIsActiveFunc);
}))));
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,13 @@ public ILightTransitionReactiveNodeConfigurator AddCycle<T>(IObservable<T> trigg
configure(cycleConfigurator);
AddNodeSource(triggerObservable.ToCycleObservable(cycleConfigurator.CycleNodeFactories.Select(tuple =>
{
var serviceScope = serviceProvider.CreateScope();
var context = new LightPipelineContext(serviceScope.ServiceProvider, Light);
var factory = new Func<IPipelineNode<LightTransition>>(() => new ScopedNode<LightTransition>(serviceScope, tuple.nodeFactory(context)));
var valueIsActiveFunc = () => tuple.matchesNodeState(context);
var factory = new Func<IPipelineNode<LightTransition>>(() =>
{
var serviceScope = serviceProvider.CreateScope();
var context = new LightPipelineContext(serviceScope.ServiceProvider, Light);
return new ScopedNode<LightTransition>(serviceScope, tuple.nodeFactory(context));
});
var valueIsActiveFunc = () => tuple.matchesNodeState(new LightPipelineContext(serviceProvider, Light));
return (factory, valueIsActiveFunc);
})));
return this;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
using System.Reactive;
using System.Reactive.Concurrency;
using System.Reactive.Linq;
using CodeCasa.Abstractions;
using CodeCasa.Abstractions;
using CodeCasa.AutomationPipelines.Lights.Context;
using CodeCasa.AutomationPipelines.Lights.Extensions;
using CodeCasa.AutomationPipelines.Lights.Nodes;
using CodeCasa.AutomationPipelines.Lights.Pipeline;
using CodeCasa.Lights;
using System.Reactive;
using System.Reactive.Concurrency;
using System.Reactive.Linq;
using System.Xml.Linq;
using CodeCasa.AutomationPipelines.Lights.Utils;
using Microsoft.Extensions.DependencyInjection;

namespace CodeCasa.AutomationPipelines.Lights.ReactiveNode;

Expand Down Expand Up @@ -99,7 +102,18 @@ public ILightTransitionReactiveNodeConfigurator AddNodeSource(IObservable<IPipel
/// <inheritdoc/>
public ILightTransitionReactiveNodeConfigurator AddNodeSource(IObservable<Func<ILightPipelineContext, IPipelineNode<LightTransition>?>> nodeFactorySource)
{
return AddNodeSource(nodeFactorySource.Select(f => f(new LightPipelineContext(serviceProvider, Light))));
return AddNodeSource(nodeFactorySource.Select(nodeFactory =>
{
var scope = serviceProvider.CreateScope();
var context = new LightPipelineContext(scope.ServiceProvider, Light);
var node = nodeFactory(context);
if (node != null)
{
return new ScopedNode<LightTransition>(scope, node);
}
scope.Dispose();
return null;
}));
}

/// <inheritdoc/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

<ItemGroup>
<PackageReference Include="MSTest" Version="4.0.2" />
<PackageReference Include="Moq" Version="4.20.72" />
</ItemGroup>

<ItemGroup>
Expand Down
Loading