Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge dev to remodel #443

Merged
merged 3 commits into from
Aug 29, 2021
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
17 changes: 13 additions & 4 deletions src/App/NetDaemon.App/Common/ExtensionMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ namespace NetDaemon.Common
public static class NetDaemonExtensions
{
/// <summary>
/// Converts a valuepair to dynamic object
/// Converts valuepairs to dynamic object
/// </summary>
/// <param name="attributeNameValuePair"></param>
/// <param name="attributeNameValuePairs"></param>
[SuppressMessage("", "CA1062")]
public static dynamic ToDynamic(this (string name, object val)[] attributeNameValuePair)
public static dynamic ToDynamic(this (string name, object val)[] attributeNameValuePairs)
{
// Convert the tuple name/value pair to tuple that can be serialized dynamically
var attributes = new FluentExpandoObject(true, true);
foreach (var (attribute, value) in attributeNameValuePair)
foreach (var (attribute, value) in attributeNameValuePairs)
{
// We only add non-null values since the FluentExpandoObject will
// return null on missing anyway
Expand All @@ -32,6 +32,15 @@ public static dynamic ToDynamic(this (string name, object val)[] attributeNameVa
return attributes;
}

/// <summary>
/// Converts a valuepair to dynamic object
/// </summary>
/// <param name="attributeNameValuePair"></param>
public static dynamic ToDynamic(this (string name, object val) attributeNameValuePair)
{
return ToDynamic(new[] { attributeNameValuePair });
}

/// <summary>
/// Converts a anoumous type to expando object
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion src/App/NetDaemon.App/NetDaemon.App.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<ItemGroup>
<PackageReference Include="JoySoftware.HassClient" Version="21.30.1-beta" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="5.0.0" />
<PackageReference Include="Roslynator.Analyzers" Version="3.2.0">
<PackageReference Include="Roslynator.Analyzers" Version="3.2.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
2 changes: 1 addition & 1 deletion src/Daemon/NetDaemon.Daemon/NetDaemon.Daemon.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<PackageReference Include="Microsoft.Extensions.Http" Version="5.0.0" />
<PackageReference Include="YamlDotNet" Version="11.2.1" />
<PackageReference Include="System.Reactive" Version="5.0.0" />
<PackageReference Include="Roslynator.Analyzers" Version="3.2.0">
<PackageReference Include="Roslynator.Analyzers" Version="3.2.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
2 changes: 1 addition & 1 deletion src/DaemonRunner/DaemonRunner/DaemonRunner.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<PackageReference Include="Serilog.AspNetCore" Version="4.1.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="4.0.0" />
<PackageReference Include="YamlDotNet" Version="11.2.1" />
<PackageReference Include="Roslynator.Analyzers" Version="3.2.0">
<PackageReference Include="Roslynator.Analyzers" Version="3.2.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
2 changes: 1 addition & 1 deletion src/Fakes/NetDaemon.Fakes/NetDaemon.Fakes.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Roslynator.Analyzers" Version="3.2.0">
<PackageReference Include="Roslynator.Analyzers" Version="3.2.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
31 changes: 31 additions & 0 deletions src/Fakes/NetDaemon.Fakes/ReactiveEventMock.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using System;
using NetDaemon.Common.Reactive;

namespace NetDaemon.Daemon.Fakes
{
/// <summary>
/// Implements Observable RxEvent
/// </summary>
public class ReactiveEventMock<T> : IRxEvent where T: class, INetDaemonRxApp
{
private readonly RxAppMock<T> _daemonRxApp;

/// <summary>
/// Constructor
/// </summary>
/// <param name="daemon">The NetDaemon host object</param>
public ReactiveEventMock(RxAppMock<T> daemon)
{
_daemonRxApp = daemon;
}

/// <summary>
/// Implements IObservable ReactiveEvent
/// </summary>
/// <param name="observer">Observer</param>
public IDisposable Subscribe(IObserver<RxEvent> observer)
{
return _daemonRxApp!.EventChangesObservable.Subscribe(observer);
}
}
}
Loading