mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-02-18 14:15:12 +00:00
fix: try adding _SimplSharp suffix to assembly if GetType fails
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
using ICD.Common.Utils.Extensions;
|
using ICD.Common.Utils.Extensions;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
@@ -70,8 +71,17 @@ namespace ICD.Common.Utils.Json
|
|||||||
|
|
||||||
string itemString = (string)token.SelectToken(ITEM_TOKEN);
|
string itemString = (string)token.SelectToken(ITEM_TOKEN);
|
||||||
Type type = Type.GetType(typeString);
|
Type type = Type.GetType(typeString);
|
||||||
|
if (type == null)
|
||||||
|
typeString = AddSimplSharpSuffix(typeString);
|
||||||
|
|
||||||
return JsonConvert.DeserializeObject(itemString, type);
|
return JsonConvert.DeserializeObject(itemString, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static string AddSimplSharpSuffix(string typeString)
|
||||||
|
{
|
||||||
|
return Regex.Replace(typeString,
|
||||||
|
"(?'prefix'[^,]+, )(?'assembly'[^,]*)(?'suffix', .*)",
|
||||||
|
"${prefix}${assembly}_SimplSharp${suffix}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user