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 @@ -36,7 +36,7 @@ public ILightTransitionCycleConfigurator<TLight> Add(LightParameters lightParame

public ILightTransitionCycleConfigurator<TLight> Add(Func<IServiceProvider, LightParameters?> lightParametersFactory, Func<IServiceProvider, bool> matchesNodeState)
{
return Add(c => lightParametersFactory(c)?.AsTransition(), matchesNodeState);
return Add(sp => lightParametersFactory(sp)?.AsTransition(), matchesNodeState);
}

public ILightTransitionCycleConfigurator<TLight> Add(Func<IServiceProvider, LightTransition?, LightParameters?> lightParametersFactory, Func<IServiceProvider, bool> matchesNodeState)
Expand All @@ -56,12 +56,12 @@ public ILightTransitionCycleConfigurator<TLight> Add(LightTransition lightTransi

public ILightTransitionCycleConfigurator<TLight> Add(Func<IServiceProvider, LightTransition?> lightTransitionFactory, Func<IServiceProvider, bool> matchesNodeState)
{
return Add(c => new StaticLightTransitionNode(lightTransitionFactory(c), c.GetRequiredService<IScheduler>()), matchesNodeState);
return Add(sp => new StaticLightTransitionNode(lightTransitionFactory(sp), sp.GetRequiredService<IScheduler>()), matchesNodeState);
}

public ILightTransitionCycleConfigurator<TLight> Add(Func<IServiceProvider, LightTransition?, LightTransition?> lightTransitionFactory, Func<IServiceProvider, bool> matchesNodeState)
{
return Add(c => new FactoryNode<LightTransition>(t => lightTransitionFactory(c, t)), matchesNodeState);
return Add(sp => new FactoryNode<LightTransition>(t => lightTransitionFactory(sp, t)), matchesNodeState);
}

public ILightTransitionCycleConfigurator<TLight> Add<TNode>(Func<IServiceProvider, bool> matchesNodeState) where TNode : IPipelineNode<LightTransition>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ public ILightTransitionCycleConfigurator<TLight> Add(LightParameters lightParame

public ILightTransitionCycleConfigurator<TLight> Add(Func<IServiceProvider, LightParameters?> lightParametersFactory, Func<IServiceProvider, bool> matchesNodeState)
{
return Add(c => lightParametersFactory(c)?.AsTransition(), matchesNodeState);
return Add(sp => lightParametersFactory(sp)?.AsTransition(), matchesNodeState);
}

public ILightTransitionCycleConfigurator<TLight> Add(Func<IServiceProvider, LightTransition?, LightParameters?> lightParametersFactory, Func<IServiceProvider, bool> matchesNodeState)
{
return Add((c, t) => lightParametersFactory(c, t)?.AsTransition(), matchesNodeState);
return Add((sp, t) => lightParametersFactory(sp, t)?.AsTransition(), matchesNodeState);
}

public ILightTransitionCycleConfigurator<TLight> Add(LightTransition lightTransition, IEqualityComparer<LightParameters>? comparer = null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,6 @@ public ILightTransitionPipelineConfigurator<TLight> AddToggle<T>(IObservable<T>
public ILightTransitionPipelineConfigurator<TLight> AddToggle<T>(IObservable<T> triggerObservable,
Action<ITimelineConfigurator> configure)
{
return AddToggle(triggerObservable, (Action<ILightTransitionToggleConfigurator<TLight>>)(c => c.AddTimeline(configure)));
return AddToggle(triggerObservable, c => c.AddTimeline(configure));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ public ILightTransitionPipelineConfigurator<TLight> Switch(IObservable<bool> obs
public ILightTransitionPipelineConfigurator<TLight> Switch<TObservable>(Func<IServiceProvider, LightParameters?> trueLightParametersFactory,
Func<IServiceProvider, LightParameters?> falseLightParametersFactory) where TObservable : IObservable<bool>
{
return Switch<TObservable>(c => falseLightParametersFactory(c)?.AsTransition(), c => trueLightParametersFactory(c)?.AsTransition());
return Switch<TObservable>(sp => falseLightParametersFactory(sp)?.AsTransition(), c => trueLightParametersFactory(c)?.AsTransition());
}

/// <inheritdoc/>
public ILightTransitionPipelineConfigurator<TLight> Switch(IObservable<bool> observable, Func<IServiceProvider, LightParameters?> trueLightParametersFactory,
Func<IServiceProvider, LightParameters?> falseLightParametersFactory)
{
return Switch(observable, c => trueLightParametersFactory(c)?.AsTransition(), c => falseLightParametersFactory(c)?.AsTransition());
return Switch(observable, sp => trueLightParametersFactory(sp)?.AsTransition(), c => falseLightParametersFactory(c)?.AsTransition());
}

/// <inheritdoc/>
Expand All @@ -60,8 +60,8 @@ public ILightTransitionPipelineConfigurator<TLight> Switch<TObservable>(Func<ISe
Func<IServiceProvider, LightTransition?> falseLightTransitionFactory) where TObservable : IObservable<bool>
{
return Switch<TObservable>(
c => new StaticLightTransitionNode(trueLightTransitionFactory(c), c.GetRequiredService<IScheduler>()),
c => new StaticLightTransitionNode(falseLightTransitionFactory(c), c.GetRequiredService<IScheduler>()));
sp => new StaticLightTransitionNode(trueLightTransitionFactory(sp), sp.GetRequiredService<IScheduler>()),
sp => new StaticLightTransitionNode(falseLightTransitionFactory(sp), sp.GetRequiredService<IScheduler>()));
}

/// <inheritdoc/>
Expand All @@ -70,8 +70,8 @@ public ILightTransitionPipelineConfigurator<TLight> Switch(IObservable<bool> obs
{
return Switch(
observable,
c => new StaticLightTransitionNode(trueLightTransitionFactory(c), c.GetRequiredService<IScheduler>()),
c => new StaticLightTransitionNode(falseLightTransitionFactory(c), c.GetRequiredService<IScheduler>()));
sp => new StaticLightTransitionNode(trueLightTransitionFactory(sp), sp.GetRequiredService<IScheduler>()),
sp => new StaticLightTransitionNode(falseLightTransitionFactory(sp), sp.GetRequiredService<IScheduler>()));
}

/// <inheritdoc/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ public ILightTransitionPipelineConfigurator<TLight> SwitchWhen(IObservable<bool>
Func<IServiceProvider, LightParameters?> falseLightParametersFactory)
{
return SwitchWhen(whenObservable, switchObservable,
c => trueLightParametersFactory(c)?.AsTransition(),
c => falseLightParametersFactory(c)?.AsTransition());
sp => trueLightParametersFactory(sp)?.AsTransition(),
sp => falseLightParametersFactory(sp)?.AsTransition());
}

/// <inheritdoc/>
Expand Down Expand Up @@ -106,8 +106,8 @@ public ILightTransitionPipelineConfigurator<TLight> SwitchWhen(IObservable<bool>
Func<IServiceProvider, LightTransition?> falseLightTransitionFactory)
{
return SwitchWhen(whenObservable, switchObservable,
c => new StaticLightTransitionNode(trueLightTransitionFactory(c), c.GetRequiredService<IScheduler>()),
c => new StaticLightTransitionNode(falseLightTransitionFactory(c), c.GetRequiredService<IScheduler>()));
sp => new StaticLightTransitionNode(trueLightTransitionFactory(sp), sp.GetRequiredService<IScheduler>()),
sp => new StaticLightTransitionNode(falseLightTransitionFactory(sp), sp.GetRequiredService<IScheduler>()));
}

/// <inheritdoc/>
Expand Down Expand Up @@ -137,7 +137,7 @@ public ILightTransitionPipelineConfigurator<TLight> SwitchWhen(IObservable<bool>
Func<IServiceProvider, IPipelineNode<LightTransition>> trueNodeFactory,
Func<IServiceProvider, IPipelineNode<LightTransition>> falseNodeFactory)
{
return AddReactiveNode(c => c
return AddReactiveNode(sp => sp
.SetHierarchyContext(HierarchyPath, "SwitchWhen", LoggingEnabled ?? false)
.On(whenObservable.Where(x => x).CombineLatest(switchObservable, (_, s) => s).Where(x => x), trueNodeFactory)
.On(whenObservable.Where(x => x).CombineLatest(switchObservable, (_, s) => s).Where(x => !x), falseNodeFactory)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ public ILightTransitionReactiveNodeConfigurator<TLight> On<T>(IObservable<T> tri

/// <inheritdoc/>
public ILightTransitionReactiveNodeConfigurator<TLight> On<T>(IObservable<T> triggerObservable, Func<IServiceProvider, LightParameters?> lightParametersFactory)
=> On(triggerObservable, c => lightParametersFactory(c)?.AsTransition());
=> On(triggerObservable, sp => lightParametersFactory(sp)?.AsTransition());

/// <inheritdoc/>
public ILightTransitionReactiveNodeConfigurator<TLight> On<T>(IObservable<T> triggerObservable, LightTransition lightTransition)
=> On(triggerObservable, c => new StaticLightTransitionNode(lightTransition, c.GetRequiredService<IScheduler>()));
=> On(triggerObservable, sp => new StaticLightTransitionNode(lightTransition, sp.GetRequiredService<IScheduler>()));

/// <inheritdoc/>
public ILightTransitionReactiveNodeConfigurator<TLight> On<T>(IObservable<T> triggerObservable, Func<IServiceProvider, LightTransition?> lightTransitionFactory)
=> On(triggerObservable, c => new StaticLightTransitionNode(lightTransitionFactory(c), c.GetRequiredService<IScheduler>()));
=> On(triggerObservable, sp => new StaticLightTransitionNode(lightTransitionFactory(sp), sp.GetRequiredService<IScheduler>()));

/// <inheritdoc/>
public ILightTransitionReactiveNodeConfigurator<TLight> On<T, TNode>(IObservable<T> triggerObservable) where TNode : IPipelineNode<LightTransition>
Expand Down Expand Up @@ -110,13 +110,13 @@ public ILightTransitionReactiveNodeConfigurator<TLight> TurnOnWhen<T>(IObservabl
/// <inheritdoc/>
public ILightTransitionReactiveNodeConfigurator<TLight> On<T>(IObservable<T> triggerObservable,
Dictionary<ITimeline, LightParameters> timeline, TimeSpan? transitionTimeForTimelineState = null)
=> On(triggerObservable, c => new TimelineNode(timeline, c.GetRequiredService<IScheduler>(), transitionTimeForTimelineState));
=> On(triggerObservable, sp => new TimelineNode(timeline, sp.GetRequiredService<IScheduler>(), transitionTimeForTimelineState));

/// <inheritdoc/>
public ILightTransitionReactiveNodeConfigurator<TLight> On<T>(IObservable<T> triggerObservable,
Func<IServiceProvider, Dictionary<ITimeline, LightParameters>> timelineFactory,
TimeSpan? transitionTimeForTimelineState = null)
=> On(triggerObservable, c => new TimelineNode(timelineFactory(c), c.GetRequiredService<IScheduler>(), transitionTimeForTimelineState));
=> On(triggerObservable, sp => new TimelineNode(timelineFactory(sp), sp.GetRequiredService<IScheduler>(), transitionTimeForTimelineState));

/// <inheritdoc/>
public ILightTransitionReactiveNodeConfigurator<TLight> On<T>(IObservable<T> triggerObservable,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,24 @@ public ILightTransitionReactiveNodeConfigurator<TLight> On<T>(IObservable<T> tri
/// <inheritdoc/>
public ILightTransitionReactiveNodeConfigurator<TLight> On<T>(IObservable<T> triggerObservable,
Func<IServiceProvider, LightParameters?> lightParametersFactory)
=> On(triggerObservable, c => lightParametersFactory(c)?.AsTransition());
=> On(triggerObservable, sp => lightParametersFactory(sp)?.AsTransition());

/// <inheritdoc/>
public ILightTransitionReactiveNodeConfigurator<TLight> On<T>(IObservable<T> triggerObservable,
LightTransition lightTransition) =>
On(triggerObservable, c => new StaticLightTransitionNode(lightTransition, c.GetRequiredService<IScheduler>()));
On(triggerObservable, sp => new StaticLightTransitionNode(lightTransition, sp.GetRequiredService<IScheduler>()));

/// <inheritdoc/>
public ILightTransitionReactiveNodeConfigurator<TLight> On<T>(IObservable<T> triggerObservable,
Func<IServiceProvider, LightTransition?> lightTransitionFactory)
=> On(triggerObservable, c => new StaticLightTransitionNode(lightTransitionFactory(c), c.GetRequiredService<IScheduler>()));
=> On(triggerObservable, sp => new StaticLightTransitionNode(lightTransitionFactory(sp), sp.GetRequiredService<IScheduler>()));

/// <inheritdoc/>
public ILightTransitionReactiveNodeConfigurator<TLight> On<T, TNode>(IObservable<T> triggerObservable)
where TNode : IPipelineNode<LightTransition> =>
AddNodeSource(triggerObservable.Select(_ =>
new Func<IServiceProvider, IPipelineNode<LightTransition>?>(c =>
ActivatorUtilities.CreateInstance<TNode>(c))));
new Func<IServiceProvider, IPipelineNode<LightTransition>?>(sp =>
ActivatorUtilities.CreateInstance<TNode>(sp))));

/// <inheritdoc/>
public ILightTransitionReactiveNodeConfigurator<TLight> On<T>(IObservable<T> triggerObservable,
Expand All @@ -47,7 +47,7 @@ public ILightTransitionReactiveNodeConfigurator<TLight> On<T>(IObservable<T> tri
public ILightTransitionReactiveNodeConfigurator<TLight> On<T>(IObservable<T> triggerObservable, Action<ILightTransitionPipelineConfigurator<TLight>> pipelineConfigurator, InstantiationScope _ = InstantiationScope.Shared)
{
return On(triggerObservable,
s => s.GetRequiredService<LightPipelineFactory>().CreateLightPipeline(ServiceProvider, Light, pipelineConfigurator.ApplyHierarchySettings(HierarchyPath, LoggingEnabled ?? false)));
sp => sp.GetRequiredService<LightPipelineFactory>().CreateLightPipeline(ServiceProvider, Light, pipelineConfigurator.ApplyHierarchySettings(HierarchyPath, LoggingEnabled ?? false)));
}

/// <inheritdoc/>
Expand Down Expand Up @@ -80,13 +80,13 @@ public ILightTransitionReactiveNodeConfigurator<TLight> TurnOnWhen<T>(IObservabl
/// <inheritdoc/>
public ILightTransitionReactiveNodeConfigurator<TLight> On<T>(IObservable<T> triggerObservable,
Dictionary<ITimeline, LightParameters> timeline, TimeSpan? transitionTimeForTimelineState = null)
=> On(triggerObservable, c => new TimelineNode(timeline, c.GetRequiredService<IScheduler>(), transitionTimeForTimelineState));
=> On(triggerObservable, sp => new TimelineNode(timeline, sp.GetRequiredService<IScheduler>(), transitionTimeForTimelineState));

/// <inheritdoc/>
public ILightTransitionReactiveNodeConfigurator<TLight> On<T>(IObservable<T> triggerObservable,
Func<IServiceProvider, Dictionary<ITimeline, LightParameters>> timelineFactory,
TimeSpan? transitionTimeForTimelineState = null)
=> On(triggerObservable, c => new TimelineNode(timelineFactory(c), c.GetRequiredService<IScheduler>(), transitionTimeForTimelineState));
=> On(triggerObservable, sp => new TimelineNode(timelineFactory(sp), sp.GetRequiredService<IScheduler>(), transitionTimeForTimelineState));

/// <inheritdoc/>
public ILightTransitionReactiveNodeConfigurator<TLight> On<T>(IObservable<T> triggerObservable,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ public ILightTransitionSwitchFalseConfigurator<TLight> WhenTrue(LightTransition
=> WhenTrue(_ => lightTransition);

public ILightTransitionSwitchFalseConfigurator<TLight> WhenTrue(Func<IServiceProvider, LightParameters?> lightParametersFactory)
=> WhenTrue(c => lightParametersFactory(c)?.AsTransition());
=> WhenTrue(sp => lightParametersFactory(sp)?.AsTransition());

public ILightTransitionSwitchFalseConfigurator<TLight> WhenTrue(Func<IServiceProvider, LightTransition?> lightTransitionFactory)
=> WhenTrue(c => new StaticLightTransitionNode(lightTransitionFactory(c), c.GetRequiredService<IScheduler>()));
=> WhenTrue(sp => new StaticLightTransitionNode(lightTransitionFactory(sp), sp.GetRequiredService<IScheduler>()));

public ILightTransitionSwitchFalseConfigurator<TLight> WhenTrue(Func<IServiceProvider, IPipelineNode<LightTransition>> nodeFactory)
{
Expand All @@ -33,16 +33,16 @@ public ILightTransitionSwitchFalseConfigurator<TLight> WhenTrue(Func<IServicePro
}

public ILightTransitionSwitchFalseConfigurator<TLight> WhenTrue<TNode>() where TNode : IPipelineNode<LightTransition>
=> WhenTrue(c => ActivatorUtilities.CreateInstance<TNode>(c));
=> WhenTrue(sp => ActivatorUtilities.CreateInstance<TNode>(sp));

public ILightTransitionSwitchFalseConfigurator<TLight> WhenTrue(Dictionary<ITimeline, LightParameters> timeline,
TimeSpan? transitionTimeForTimelineState = null)
=> WhenTrue(c => new TimelineNode(timeline, c.GetRequiredService<IScheduler>(), transitionTimeForTimelineState));
=> WhenTrue(sp => new TimelineNode(timeline, sp.GetRequiredService<IScheduler>(), transitionTimeForTimelineState));

public ILightTransitionSwitchFalseConfigurator<TLight> WhenTrue(
Func<IServiceProvider, Dictionary<ITimeline, LightParameters>> timelineFactory,
TimeSpan? transitionTimeForTimelineState = null)
=> WhenTrue(c => new TimelineNode(timelineFactory(c), c.GetRequiredService<IScheduler>(), transitionTimeForTimelineState));
=> WhenTrue(sp => new TimelineNode(timelineFactory(sp), sp.GetRequiredService<IScheduler>(), transitionTimeForTimelineState));

public ILightTransitionSwitchFalseConfigurator<TLight> WhenTrue(Action<ITimelineConfigurator> configure)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,26 @@ public void WhenFalse(LightTransition lightTransition)
=> WhenFalse(_ => lightTransition);

public void WhenFalse(Func<IServiceProvider, LightParameters?> lightParametersFactory)
=> WhenFalse(c => lightParametersFactory(c)?.AsTransition());
=> WhenFalse(sp => lightParametersFactory(sp)?.AsTransition());

public void WhenFalse(Func<IServiceProvider, LightTransition?> lightTransitionFactory)
=> WhenFalse(c => new StaticLightTransitionNode(lightTransitionFactory(c), c.GetRequiredService<IScheduler>()));
=> WhenFalse(sp => new StaticLightTransitionNode(lightTransitionFactory(sp), sp.GetRequiredService<IScheduler>()));

public void WhenFalse(Func<IServiceProvider, IPipelineNode<LightTransition>> nodeFactory)
{
FalseNodeFactory = nodeFactory;
}

public void WhenFalse<TNode>() where TNode : IPipelineNode<LightTransition>
=> WhenFalse(c => ActivatorUtilities.CreateInstance<TNode>(c));
=> WhenFalse(sp => ActivatorUtilities.CreateInstance<TNode>(sp));

public void WhenFalse(Dictionary<ITimeline, LightParameters> timeline,
TimeSpan? transitionTimeForTimelineState = null)
=> WhenFalse(c => new TimelineNode(timeline, c.GetRequiredService<IScheduler>(), transitionTimeForTimelineState));
=> WhenFalse(sp => new TimelineNode(timeline, sp.GetRequiredService<IScheduler>(), transitionTimeForTimelineState));

public void WhenFalse(Func<IServiceProvider, Dictionary<ITimeline, LightParameters>> timelineFactory,
TimeSpan? transitionTimeForTimelineState = null)
=> WhenFalse(c => new TimelineNode(timelineFactory(c), c.GetRequiredService<IScheduler>(), transitionTimeForTimelineState));
=> WhenFalse(sp => new TimelineNode(timelineFactory(sp), sp.GetRequiredService<IScheduler>(), transitionTimeForTimelineState));

public void WhenFalse(Action<ITimelineConfigurator> configure)
{
Expand Down
Loading