mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-01-11 19:44:52 +00:00
fix: copy dictionaries
- fixed multiple enumeration exception
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Converters;
|
using Newtonsoft.Json.Converters;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
@@ -39,10 +40,14 @@ namespace PepperDash.Essentials.AppServer.Messengers
|
|||||||
|
|
||||||
sourceDevice.CurrentSourcesChanged += (sender, e) =>
|
sourceDevice.CurrentSourcesChanged += (sender, e) =>
|
||||||
{
|
{
|
||||||
|
// need to copy the dictionaries to avoid enumeration issues
|
||||||
|
var currentSourceKeys = sourceDevice.CurrentSourceKeys.ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
|
||||||
|
var currentSources = sourceDevice.CurrentSources.ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
|
||||||
|
|
||||||
PostStatusMessage(JToken.FromObject(new
|
PostStatusMessage(JToken.FromObject(new
|
||||||
{
|
{
|
||||||
currentSourceKeys = sourceDevice.CurrentSourceKeys,
|
currentSourceKeys,
|
||||||
currentSources = sourceDevice.CurrentSources
|
currentSources,
|
||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user