mirror of
https://github.com/zhigang1992/react-native-code-push.git
synced 2026-06-10 23:59:42 +08:00
* Updated Windows Example * Organized usings * Fix for update application in write protected folder * Typo fixed * Examples updated to RNW 0.43.0 * Fixed Warning CS0108
71 lines
1.9 KiB
C#
71 lines
1.9 KiB
C#
using System;
|
|
using System.Diagnostics;
|
|
using System.Linq;
|
|
using System.IO;
|
|
#if WINDOWS_UWP
|
|
using Windows.ApplicationModel;
|
|
using Windows.Storage;
|
|
#endif
|
|
|
|
namespace CodePush.ReactNative
|
|
{
|
|
internal partial class CodePushUtils
|
|
{
|
|
internal static void Log(string message)
|
|
{
|
|
Debug.WriteLine("[CodePush] " + message, CodePushConstants.ReactNativeLogCategory);
|
|
}
|
|
|
|
internal static void LogBundleUrl(string path)
|
|
{
|
|
Log("Loading JS bundle from \"" + path + "\"");
|
|
}
|
|
|
|
static string _deviceId = String.Empty;
|
|
|
|
internal static string GetDeviceId()
|
|
{
|
|
//It's quite long operation, cache it
|
|
if (!String.IsNullOrEmpty(_deviceId))
|
|
return _deviceId;
|
|
|
|
_deviceId = GetDeviceIdImpl();
|
|
return _deviceId;
|
|
}
|
|
|
|
internal static string GetAppVersion()
|
|
{
|
|
#if WINDOWS_UWP
|
|
return Package.Current.Id.Version.Major + "." + Package.Current.Id.Version.Minor + "." + Package.Current.Id.Version.Build;
|
|
#else
|
|
return applicationInfo.Version;
|
|
#endif
|
|
}
|
|
|
|
internal static string GetAppFolder()
|
|
{
|
|
#if WINDOWS_UWP
|
|
return ApplicationData.Current.LocalFolder.Path;
|
|
#else
|
|
return AppDomain.CurrentDomain.BaseDirectory;
|
|
#endif
|
|
}
|
|
|
|
internal static string GetAssetsBundlePrefix()
|
|
{
|
|
#if WINDOWS_UWP
|
|
return CodePushConstants.AssetsBundlePrefix;
|
|
#else
|
|
return Path.Combine(GetAppFolder(), CodePushConstants.AssetsBundlePrefix);
|
|
#endif
|
|
}
|
|
|
|
internal static string ExtractSubFolder(string fullPath)
|
|
{
|
|
var codePushSubPathArray = fullPath.Split(Path.DirectorySeparatorChar);
|
|
return String.Join("/", codePushSubPathArray.SkipWhile((value, index) => codePushSubPathArray.Length - index > 4).ToArray());
|
|
}
|
|
|
|
}
|
|
}
|