mirror of
https://github.com/zhigang1992/react-native-code-push.git
synced 2026-06-10 15:49:36 +08:00
Added support react-native-windows dotNet Added example for react-native-windows UWP based Added example for react-native-windows dotNet based Project structure: CodePush.Shared - shared code between UWP and dotNet CodePush - UWP specific code CodePush.Net46 - dotNet specific code For UWP solution it needs to be added the following projects: CodePush.Shared CodePush For dotNet solution it needs to be added the following projects: CodePush.Shared CodePush.Net46 Examples: Examples\CodePushDemoApp\windows\CodePushDemoApp.sln the solution contains both examples (UWP and dotNet). Notes Example for ARM configuration has not been tested. Since there is no changes in UWP part of implementation, there is low risk of failure. In this implementation we tried to reuse UWP library as much as possible. The following issues are relevant for both platforms: ZipFile.ExtractToDirectory is not reliable and throws exception if: folder exists already path is too long (> 250 chars) Un-zipping is quite long operation. Does it make sense for async? await UpdateUtils.UnzipBundleAsync(downloadFile.Path, unzippedFolder.Path);
108 lines
3.4 KiB
C#
108 lines
3.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Configuration;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Navigation;
|
|
|
|
namespace CodePushDemoApp.Wpf
|
|
{
|
|
/// <summary>
|
|
/// Interaction logic for App.xaml
|
|
/// </summary>
|
|
public partial class App : Application
|
|
{
|
|
private readonly AppReactPage _reactPage = new AppReactPage();
|
|
|
|
/// <summary>
|
|
/// Initializes the singleton application object. This is the first line of authored code
|
|
/// executed, and as such is the logical equivalent of main() or WinMain().
|
|
/// </summary>
|
|
public App()
|
|
{
|
|
}
|
|
|
|
/// <summary>
|
|
/// Override method fired prior to the Startup event when the Run method of the Application object is called...
|
|
/// </summary>
|
|
/// <param name="e"></param>
|
|
protected override void OnStartup(StartupEventArgs e)
|
|
{
|
|
base.OnStartup(e);
|
|
OnCreate(e.Args);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Called whenever the app is opened to initialized...
|
|
/// </summary>
|
|
/// <param name="arguments"></param>
|
|
private void OnCreate(string[] arguments)
|
|
{
|
|
var shellWindow = Application.Current.MainWindow;
|
|
|
|
if (shellWindow == null)
|
|
{
|
|
shellWindow = new Window
|
|
{
|
|
ShowActivated = true,
|
|
ShowInTaskbar = true,
|
|
Title = "CodePushDemoApp.WPF",
|
|
Height = 768,
|
|
Width = 1024,
|
|
WindowStartupLocation = WindowStartupLocation.CenterScreen
|
|
};
|
|
|
|
Application.Current.MainWindow = shellWindow;
|
|
}
|
|
|
|
//Show Window if it is not already active...
|
|
if (!shellWindow.IsLoaded)
|
|
{
|
|
shellWindow.Show();
|
|
}
|
|
|
|
var rootFrame = shellWindow.Content as Frame;
|
|
|
|
// Do not repeat app initialization when the Window already has content,
|
|
// just ensure that the window is active
|
|
if (rootFrame == null)
|
|
{
|
|
_reactPage.OnCreate(arguments);
|
|
|
|
// Create a Frame to act as the navigation context and navigate to the first page
|
|
rootFrame = new Frame();
|
|
|
|
rootFrame.NavigationFailed += OnNavigationFailed;
|
|
|
|
// Place the frame in the current Window
|
|
shellWindow.Content = rootFrame;
|
|
}
|
|
|
|
if (rootFrame.Content == null)
|
|
{
|
|
// When the navigation stack isn't restored navigate to the first page,
|
|
// configuring the new page by passing required information as a navigation
|
|
// parameter
|
|
rootFrame.Content = _reactPage;
|
|
}
|
|
|
|
// Ensure the current window is active
|
|
shellWindow.Activate();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Invoked when Navigation to a certain page fails
|
|
/// </summary>
|
|
/// <param name="sender">The Frame which failed navigation</param>
|
|
/// <param name="e">Details about the navigation failure</param>
|
|
private void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
|
|
{
|
|
throw new Exception("Failed to load Page...");
|
|
}
|
|
}
|
|
}
|
|
|