Skip to content

Commit

Permalink
Issue demonstrated
Browse files Browse the repository at this point in the history
  • Loading branch information
jjouppi committed Jun 26, 2020
1 parent e1f32ad commit 7316243
Show file tree
Hide file tree
Showing 36 changed files with 1,615 additions and 0 deletions.
26 changes: 26 additions & 0 deletions SecondWndowIssueTest_v01.Core/Helpers/Json.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System;
using System.Threading.Tasks;

using Newtonsoft.Json;

namespace SecondWndowIssueTest_v01.Core.Helpers
{
public static class Json
{
public static async Task<T> ToObjectAsync<T>(string value)
{
return await Task.Run<T>(() =>
{
return JsonConvert.DeserializeObject<T>(value);
});
}

public static async Task<string> StringifyAsync(object value)
{
return await Task.Run<string>(() =>
{
return JsonConvert.SerializeObject(value);
});
}
}
}
19 changes: 19 additions & 0 deletions SecondWndowIssueTest_v01.Core/Helpers/Singleton.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System;
using System.Collections.Concurrent;

namespace SecondWndowIssueTest_v01.Core.Helpers
{
public static class Singleton<T>
where T : new()
{
private static ConcurrentDictionary<Type, T> _instances = new ConcurrentDictionary<Type, T>();

public static T Instance
{
get
{
return _instances.GetOrAdd(typeof(T), (t) => new T());
}
}
}
}
15 changes: 15 additions & 0 deletions SecondWndowIssueTest_v01.Core/SecondWndowIssueTest_v01.Core.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<RootNamespace>SecondWndowIssueTest_v01.Core</RootNamespace>
</PropertyGroup>

<ItemGroup>
<Folder Include="Models\" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
</ItemGroup>
</Project>
2 changes: 2 additions & 0 deletions SecondWndowIssueTest_v01.Core/readme.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This core project is a .net standard project.
It's a great place to put all your logic that is not platform dependent (e.g. model/helper classes) so they can be reused.
77 changes: 77 additions & 0 deletions SecondWndowIssueTest_v01.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28307.1145
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SecondWndowIssueTest_v01", "SecondWndowIssueTest_v01\SecondWndowIssueTest_v01.csproj", "{B5F40F5B-86C2-4791-8E1A-314F97B3F621}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SecondWndowIssueTest_v01.Core", "SecondWndowIssueTest_v01.Core\SecondWndowIssueTest_v01.Core.csproj", "{BA5DEF64-AC57-443B-A478-19C971323A5F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|ARM = Debug|ARM
Debug|ARM64 = Debug|ARM64
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|ARM = Release|ARM
Release|ARM64 = Release|ARM64
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{B5F40F5B-86C2-4791-8E1A-314F97B3F621}.Debug|Any CPU.ActiveCfg = Debug|x86
{B5F40F5B-86C2-4791-8E1A-314F97B3F621}.Debug|ARM.ActiveCfg = Debug|ARM
{B5F40F5B-86C2-4791-8E1A-314F97B3F621}.Debug|ARM.Build.0 = Debug|ARM
{B5F40F5B-86C2-4791-8E1A-314F97B3F621}.Debug|ARM.Deploy.0 = Debug|ARM
{B5F40F5B-86C2-4791-8E1A-314F97B3F621}.Debug|ARM64.ActiveCfg = Debug|ARM64
{B5F40F5B-86C2-4791-8E1A-314F97B3F621}.Debug|ARM64.Build.0 = Debug|ARM64
{B5F40F5B-86C2-4791-8E1A-314F97B3F621}.Debug|ARM64.Deploy.0 = Debug|ARM64
{B5F40F5B-86C2-4791-8E1A-314F97B3F621}.Debug|x64.ActiveCfg = Debug|x64
{B5F40F5B-86C2-4791-8E1A-314F97B3F621}.Debug|x64.Build.0 = Debug|x64
{B5F40F5B-86C2-4791-8E1A-314F97B3F621}.Debug|x64.Deploy.0 = Debug|x64
{B5F40F5B-86C2-4791-8E1A-314F97B3F621}.Debug|x86.ActiveCfg = Debug|x86
{B5F40F5B-86C2-4791-8E1A-314F97B3F621}.Debug|x86.Build.0 = Debug|x86
{B5F40F5B-86C2-4791-8E1A-314F97B3F621}.Debug|x86.Deploy.0 = Debug|x86
{B5F40F5B-86C2-4791-8E1A-314F97B3F621}.Release|Any CPU.ActiveCfg = Release|x86
{B5F40F5B-86C2-4791-8E1A-314F97B3F621}.Release|ARM.ActiveCfg = Release|ARM
{B5F40F5B-86C2-4791-8E1A-314F97B3F621}.Release|ARM.Build.0 = Release|ARM
{B5F40F5B-86C2-4791-8E1A-314F97B3F621}.Release|ARM.Deploy.0 = Release|ARM
{B5F40F5B-86C2-4791-8E1A-314F97B3F621}.Release|ARM64.ActiveCfg = Release|ARM64
{B5F40F5B-86C2-4791-8E1A-314F97B3F621}.Release|ARM64.Build.0 = Release|ARM64
{B5F40F5B-86C2-4791-8E1A-314F97B3F621}.Release|ARM64.Deploy.0 = Release|ARM64
{B5F40F5B-86C2-4791-8E1A-314F97B3F621}.Release|x64.ActiveCfg = Release|x64
{B5F40F5B-86C2-4791-8E1A-314F97B3F621}.Release|x64.Build.0 = Release|x64
{B5F40F5B-86C2-4791-8E1A-314F97B3F621}.Release|x64.Deploy.0 = Release|x64
{B5F40F5B-86C2-4791-8E1A-314F97B3F621}.Release|x86.ActiveCfg = Release|x86
{B5F40F5B-86C2-4791-8E1A-314F97B3F621}.Release|x86.Build.0 = Release|x86
{B5F40F5B-86C2-4791-8E1A-314F97B3F621}.Release|x86.Deploy.0 = Release|x86
{BA5DEF64-AC57-443B-A478-19C971323A5F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BA5DEF64-AC57-443B-A478-19C971323A5F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BA5DEF64-AC57-443B-A478-19C971323A5F}.Debug|ARM.ActiveCfg = Debug|Any CPU
{BA5DEF64-AC57-443B-A478-19C971323A5F}.Debug|ARM.Build.0 = Debug|Any CPU
{BA5DEF64-AC57-443B-A478-19C971323A5F}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{BA5DEF64-AC57-443B-A478-19C971323A5F}.Debug|ARM64.Build.0 = Debug|Any CPU
{BA5DEF64-AC57-443B-A478-19C971323A5F}.Debug|x64.ActiveCfg = Debug|Any CPU
{BA5DEF64-AC57-443B-A478-19C971323A5F}.Debug|x64.Build.0 = Debug|Any CPU
{BA5DEF64-AC57-443B-A478-19C971323A5F}.Debug|x86.ActiveCfg = Debug|Any CPU
{BA5DEF64-AC57-443B-A478-19C971323A5F}.Debug|x86.Build.0 = Debug|Any CPU
{BA5DEF64-AC57-443B-A478-19C971323A5F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BA5DEF64-AC57-443B-A478-19C971323A5F}.Release|Any CPU.Build.0 = Release|Any CPU
{BA5DEF64-AC57-443B-A478-19C971323A5F}.Release|ARM.ActiveCfg = Release|Any CPU
{BA5DEF64-AC57-443B-A478-19C971323A5F}.Release|ARM.Build.0 = Release|Any CPU
{BA5DEF64-AC57-443B-A478-19C971323A5F}.Release|ARM64.ActiveCfg = Release|Any CPU
{BA5DEF64-AC57-443B-A478-19C971323A5F}.Release|ARM64.Build.0 = Release|Any CPU
{BA5DEF64-AC57-443B-A478-19C971323A5F}.Release|x64.ActiveCfg = Release|Any CPU
{BA5DEF64-AC57-443B-A478-19C971323A5F}.Release|x64.Build.0 = Release|Any CPU
{BA5DEF64-AC57-443B-A478-19C971323A5F}.Release|x86.ActiveCfg = Release|Any CPU
{BA5DEF64-AC57-443B-A478-19C971323A5F}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {A71A1292-B997-4A37-BC04-BD690BADB880}
EndGlobalSection
EndGlobal
11 changes: 11 additions & 0 deletions SecondWndowIssueTest_v01/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# top-most EditorConfig file
root = true

[*]
end_of_line = crlf

[*.{cs,xaml}]
indent_style = space
indent_size = 4
trim_trailing_whitespace = true
insert_final_newline = true
40 changes: 40 additions & 0 deletions SecondWndowIssueTest_v01/Activation/ActivationHandler.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using System;
using System.Threading.Tasks;

namespace SecondWndowIssueTest_v01.Activation
{
// For more information on understanding and extending activation flow see
// https://github.com/Microsoft/WindowsTemplateStudio/blob/master/docs/UWP/activation.md
internal abstract class ActivationHandler
{
public abstract bool CanHandle(object args);

public abstract Task HandleAsync(object args);
}

// Extend this class to implement new ActivationHandlers
internal abstract class ActivationHandler<T> : ActivationHandler
where T : class
{
// Override this method to add the activation logic in your activation handler
protected abstract Task HandleInternalAsync(T args);

public override async Task HandleAsync(object args)
{
await HandleInternalAsync(args as T);
}

public override bool CanHandle(object args)
{
// CanHandle checks the args is of type you have configured
return args is T && CanHandleInternal(args as T);
}

// You can override this method to add extra validation on activation args
// to determine if your ActivationHandler should handle this activation args
protected virtual bool CanHandleInternal(T args)
{
return true;
}
}
}
39 changes: 39 additions & 0 deletions SecondWndowIssueTest_v01/Activation/DefaultActivationHandler.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using System;
using System.Threading.Tasks;

using SecondWndowIssueTest_v01.Services;

using Windows.ApplicationModel.Activation;

namespace SecondWndowIssueTest_v01.Activation
{
internal class DefaultActivationHandler : ActivationHandler<IActivatedEventArgs>
{
private readonly Type _navElement;

public DefaultActivationHandler(Type navElement)
{
_navElement = navElement;
}

protected override async Task HandleInternalAsync(IActivatedEventArgs args)
{
// When the navigation stack isn't restored, navigate to the first page and configure
// the new page by passing required information in the navigation parameter
object arguments = null;
if (args is LaunchActivatedEventArgs launchArgs)
{
arguments = launchArgs.Arguments;
}

NavigationService.Navigate(_navElement, arguments);
await Task.CompletedTask;
}

protected override bool CanHandleInternal(IActivatedEventArgs args)
{
// None of the ActivationHandlers has handled the app activation
return NavigationService.Frame.Content == null && _navElement != null;
}
}
}
19 changes: 19 additions & 0 deletions SecondWndowIssueTest_v01/App.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<Application
x:Class="SecondWndowIssueTest_v01.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
>

<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/Styles/_Colors.xaml" />
<ResourceDictionary Source="/Styles/_FontSizes.xaml" />
<ResourceDictionary Source="/Styles/_Thickness.xaml" />

<ResourceDictionary Source="/Styles/TextBlock.xaml" />
<ResourceDictionary Source="/Styles/Page.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
45 changes: 45 additions & 0 deletions SecondWndowIssueTest_v01/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using System;

using SecondWndowIssueTest_v01.Services;

using Windows.ApplicationModel.Activation;
using Windows.UI.Xaml;

namespace SecondWndowIssueTest_v01
{
public sealed partial class App : Application
{
private Lazy<ActivationService> _activationService;

private ActivationService ActivationService
{
get { return _activationService.Value; }
}

public App()
{
InitializeComponent();

// Deferred execution until used. Check https://msdn.microsoft.com/library/dd642331(v=vs.110).aspx for further info on Lazy<T> class.
_activationService = new Lazy<ActivationService>(CreateActivationService);
}

protected override async void OnLaunched(LaunchActivatedEventArgs args)
{
if (!args.PrelaunchActivated)
{
await ActivationService.ActivateAsync(args);
}
}

protected override async void OnActivated(IActivatedEventArgs args)
{
await ActivationService.ActivateAsync(args);
}

private ActivationService CreateActivationService()
{
return new ActivationService(this, typeof(Views.BlankPage));
}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added SecondWndowIssueTest_v01/Assets/StoreLogo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions SecondWndowIssueTest_v01/Helpers/ResourceExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System;
using System.Runtime.InteropServices;

using Windows.ApplicationModel.Resources;

namespace SecondWndowIssueTest_v01.Helpers
{
internal static class ResourceExtensions
{
private static ResourceLoader _resLoader = new ResourceLoader();

public static string GetLocalized(this string resourceKey)
{
return _resLoader.GetString(resourceKey);
}
}
}
Loading

0 comments on commit 7316243

Please sign in to comment.