mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-15 12:44:58 +00:00
fixed minor registration error
This commit is contained in:
@@ -0,0 +1,42 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using Crestron.SimplSharp;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
|
||||||
|
namespace PepperDash.Essentials.Core
|
||||||
|
{
|
||||||
|
public static class JsonExtensions
|
||||||
|
{
|
||||||
|
public static List<JToken> FindTokens(this JToken containerToken, string name)
|
||||||
|
{
|
||||||
|
List<JToken> matches = new List<JToken>();
|
||||||
|
FindTokens(containerToken, name, matches);
|
||||||
|
return matches;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void FindTokens(JToken containerToken, string name, List<JToken> matches)
|
||||||
|
{
|
||||||
|
if (containerToken.Type == JTokenType.Object)
|
||||||
|
{
|
||||||
|
foreach (JProperty child in containerToken.Children<JProperty>())
|
||||||
|
{
|
||||||
|
if (child.Name == name)
|
||||||
|
{
|
||||||
|
matches.Add(child.Value);
|
||||||
|
}
|
||||||
|
FindTokens(child.Value, name, matches);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (containerToken.Type == JTokenType.Array)
|
||||||
|
{
|
||||||
|
foreach (JToken child in containerToken.Children())
|
||||||
|
{
|
||||||
|
FindTokens(child, name, matches);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -105,15 +105,20 @@ namespace PepperDash.Essentials.Core
|
|||||||
var name = localDc.Name;
|
var name = localDc.Name;
|
||||||
var type = localDc.Type;
|
var type = localDc.Type;
|
||||||
var properties = localDc.Properties;
|
var properties = localDc.Properties;
|
||||||
|
//var propRecurse = properties;
|
||||||
|
|
||||||
|
|
||||||
var typeName = localDc.Type.ToLower();
|
var typeName = localDc.Type.ToLower();
|
||||||
|
|
||||||
Debug.Console(2, "typeName = {0}", typeName);
|
Debug.Console(2, "typeName = {0}", typeName);
|
||||||
// Check for types that have been added by plugin dlls.
|
// Check for types that have been added by plugin dlls.
|
||||||
if (FactoryMethods.ContainsKey(typeName))
|
if (!FactoryMethods.ContainsKey(typeName)) return null;
|
||||||
|
|
||||||
|
/*foreach (var obj in (propRecurse as JObject).FindTokens("secret").OfType<JObject>())
|
||||||
{
|
{
|
||||||
|
Debug.Console(2, obj.ToString());
|
||||||
|
}*/
|
||||||
|
|
||||||
|
|
||||||
//look for secret in username
|
//look for secret in username
|
||||||
var userSecretToken = properties["control"]["tcpSshProperties"]["username"]["secret"];
|
var userSecretToken = properties["control"]["tcpSshProperties"]["username"]["secret"];
|
||||||
|
|
||||||
@@ -163,8 +168,6 @@ namespace PepperDash.Essentials.Core
|
|||||||
|
|
||||||
return FactoryMethods[typeName].FactoryMethod(localDc);
|
return FactoryMethods[typeName].FactoryMethod(localDc);
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Debug.Console(2, "Issue with getting device - {0}", ex.Message);
|
Debug.Console(2, "Issue with getting device - {0}", ex.Message);
|
||||||
|
|||||||
@@ -209,6 +209,7 @@
|
|||||||
<Compile Include="DeviceTypeInterfaces\IHasFarEndContentStatus.cs" />
|
<Compile Include="DeviceTypeInterfaces\IHasFarEndContentStatus.cs" />
|
||||||
<Compile Include="DeviceTypeInterfaces\IHasPhoneDialing.cs" />
|
<Compile Include="DeviceTypeInterfaces\IHasPhoneDialing.cs" />
|
||||||
<Compile Include="DeviceTypeInterfaces\IMobileControl.cs" />
|
<Compile Include="DeviceTypeInterfaces\IMobileControl.cs" />
|
||||||
|
<Compile Include="Extensions\JsonExtensions.cs" />
|
||||||
<Compile Include="Factory\DeviceFactory.cs" />
|
<Compile Include="Factory\DeviceFactory.cs" />
|
||||||
<Compile Include="Factory\IDeviceFactory.cs" />
|
<Compile Include="Factory\IDeviceFactory.cs" />
|
||||||
<Compile Include="Factory\ReadyEventArgs.cs" />
|
<Compile Include="Factory\ReadyEventArgs.cs" />
|
||||||
|
|||||||
Reference in New Issue
Block a user