Added NightAlert project for travel kit
This commit is contained in:
59
ThirdParty/SocketIoClientDotNet/Src/SocketIoClientDotNet.net45/Modules/HasBinaryData.cs
vendored
Normal file
59
ThirdParty/SocketIoClientDotNet/Src/SocketIoClientDotNet.net45/Modules/HasBinaryData.cs
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System.Linq;
|
||||
|
||||
namespace Quobject.SocketIoClientDotNet.Modules
|
||||
{
|
||||
public static class HasBinaryData
|
||||
{
|
||||
public static bool HasBinary(object data)
|
||||
{
|
||||
return RecursiveCheckForBinary(data);
|
||||
}
|
||||
|
||||
private static bool RecursiveCheckForBinary(object obj)
|
||||
{
|
||||
if (obj == null || obj is string)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (obj is byte[])
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
var array = obj as JArray;
|
||||
if (array != null)
|
||||
{
|
||||
if (array.Any(token => RecursiveCheckForBinary(token)))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
var jobject = obj as JObject;
|
||||
if (jobject != null)
|
||||
{
|
||||
if (jobject.Children().Any(child => RecursiveCheckForBinary(child)))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
var jvalue = obj as JValue;
|
||||
if (jvalue != null)
|
||||
{
|
||||
return RecursiveCheckForBinary(jvalue.Value);
|
||||
}
|
||||
|
||||
var jprop = obj as JProperty;
|
||||
if (jprop != null)
|
||||
{
|
||||
return RecursiveCheckForBinary(jprop.Value);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user