Files
react-native-code-push/windows/CodePushUtils.cs
Geoffrey Goh 08283efe2d CR feedback
2016-05-05 10:37:38 -07:00

54 lines
1.4 KiB
C#

using Newtonsoft.Json.Linq;
using System;
using System.Diagnostics;
using System.Threading.Tasks;
using Windows.Storage;
using Windows.Storage.Streams;
using Windows.System.Profile;
namespace CodePush.ReactNative
{
internal class CodePushUtils
{
internal async static Task<JObject> GetJObjectFromFile(StorageFile file)
{
string jsonString = await FileIO.ReadTextAsync(file);
if (jsonString.Length == 0)
{
return new JObject();
}
try
{
return JObject.Parse(jsonString);
}
catch (Exception)
{
return null;
}
}
internal static void Log(string message)
{
Debug.WriteLine("[CodePush] " + message, CodePushConstants.ReactNativeLogCategory);
}
internal static void LogBundleUrl(string path)
{
Log("Loading JS bundle from \"" + path + "\"");
}
internal static string GetDeviceId()
{
HardwareToken token = HardwareIdentification.GetPackageSpecificToken(null);
IBuffer hardwareId = token.Id;
var dataReader = DataReader.FromBuffer(hardwareId);
var bytes = new byte[hardwareId.Length];
dataReader.ReadBytes(bytes);
return BitConverter.ToString(bytes);
}
}
}