Skip to content

Commit

Permalink
housekeeping: Update copyright year, apply more refactorings (#415)
Browse files Browse the repository at this point in the history
* Update copyright year
* More file scoped namespaces
  • Loading branch information
worldbeater committed Jan 8, 2022
1 parent d69202d commit 9146f19
Show file tree
Hide file tree
Showing 45 changed files with 277 additions and 280 deletions.
2 changes: 1 addition & 1 deletion samples/LoginApp.Avalonia/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2021 .NET Foundation and Contributors. All rights reserved.
// Copyright (c) 2022 .NET Foundation and Contributors. All rights reserved.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.
Expand Down
2 changes: 1 addition & 1 deletion samples/LoginApp.Avalonia/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2021 .NET Foundation and Contributors. All rights reserved.
// Copyright (c) 2022 .NET Foundation and Contributors. All rights reserved.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.
Expand Down
2 changes: 1 addition & 1 deletion samples/LoginApp.Avalonia/Services/AvaloniaUserDialogs.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2021 .NET Foundation and Contributors. All rights reserved.
// Copyright (c) 2022 .NET Foundation and Contributors. All rights reserved.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.
Expand Down
2 changes: 1 addition & 1 deletion samples/LoginApp.Avalonia/Views/SignUpView.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2021 .NET Foundation and Contributors. All rights reserved.
// Copyright (c) 2022 .NET Foundation and Contributors. All rights reserved.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.
Expand Down
53 changes: 26 additions & 27 deletions samples/LoginApp.Uwp/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2021 .NET Foundation and Contributors. All rights reserved.
// Copyright (c) 2022 .NET Foundation and Contributors. All rights reserved.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.
Expand All @@ -8,40 +8,39 @@
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;

namespace LoginApp.Uwp
namespace LoginApp.Uwp;

/// <summary>
/// Defines the main Universal Windows Application class.
/// </summary>
/// <inheritdoc />
public sealed partial class App : Application
{
/// <summary>
/// Defines the main Universal Windows Application class.
/// Initializes a new instance of the <see cref="App"/> class.
/// </summary>
public App() => InitializeComponent();

/// <inheritdoc />
public sealed partial class App : Application
protected override void OnLaunched(LaunchActivatedEventArgs e)
{
/// <summary>
/// Initializes a new instance of the <see cref="App"/> class.
/// </summary>
public App() => InitializeComponent();

/// <inheritdoc />
protected override void OnLaunched(LaunchActivatedEventArgs e)
Frame rootFrame = Window.Current.Content as Frame;
if (rootFrame == null)
{
Frame rootFrame = Window.Current.Content as Frame;
if (rootFrame == null)
{
rootFrame = new Frame();
Window.Current.Content = rootFrame;
}

if (e?.PrelaunchActivated == true)
{
return;
}
rootFrame = new Frame();
Window.Current.Content = rootFrame;
}

if (rootFrame.Content == null)
{
rootFrame.Navigate(typeof(SignUpView), e?.Arguments);
}
if (e?.PrelaunchActivated == true)
{
return;
}

Window.Current.Activate();
if (rootFrame.Content == null)
{
rootFrame.Navigate(typeof(SignUpView), e?.Arguments);
}

Window.Current.Activate();
}
}
1 change: 1 addition & 0 deletions samples/LoginApp.Uwp/LoginApp.Uwp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<ProjectTypeGuids>{A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WindowsXamlEnableOverview>true</WindowsXamlEnableOverview>
<AppxPackageSigningEnabled>false</AppxPackageSigningEnabled>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
Expand Down
2 changes: 1 addition & 1 deletion samples/LoginApp.Uwp/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2021 .NET Foundation and Contributors. All rights reserved.
// Copyright (c) 2022 .NET Foundation and Contributors. All rights reserved.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.
Expand Down
19 changes: 9 additions & 10 deletions samples/LoginApp.Uwp/Services/UwpUserDialogs.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
// Copyright (c) 2021 .NET Foundation and Contributors. All rights reserved.
// Copyright (c) 2022 .NET Foundation and Contributors. All rights reserved.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.

using LoginApp.Services;
using Windows.UI.Popups;

namespace LoginApp.Uwp.Services
namespace LoginApp.Uwp.Services;

/// <summary>
/// This class defines user dialogs for the Universal Windows Platform app.
/// </summary>
public class UwpUserDialogs : IUserDialogs
{
/// <summary>
/// This class defines user dialogs for the Universal Windows Platform app.
/// </summary>
public class UwpUserDialogs : IUserDialogs
{
/// <inheritdoc />
public void ShowDialog(string message) => new MessageDialog(message).ShowAsync();
}
/// <inheritdoc />
public void ShowDialog(string message) => new MessageDialog(message).ShowAsync();
}
119 changes: 59 additions & 60 deletions samples/LoginApp.Uwp/Views/SignUpView.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2021 .NET Foundation and Contributors. All rights reserved.
// Copyright (c) 2022 .NET Foundation and Contributors. All rights reserved.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.
Expand All @@ -11,74 +11,73 @@
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;

namespace LoginApp.Uwp.Views
namespace LoginApp.Uwp.Views;

/// <summary>
/// A page which contains controls for signing up.
/// </summary>
public sealed partial class SignUpView : Page, IViewFor<SignUpViewModel>
{
/// <summary>
/// A page which contains controls for signing up.
/// Defines the view model dependency property for the <see cref="SignUpView" /> class.
/// </summary>
public sealed partial class SignUpView : Page, IViewFor<SignUpViewModel>
{
/// <summary>
/// Defines the view model dependency property for the <see cref="SignUpView" /> class.
/// </summary>
// ReSharper disable once MemberCanBePrivate.Global due to MSDN recommendations.
public static readonly DependencyProperty ViewModelProperty = DependencyProperty
.Register(nameof(ViewModel), typeof(SignUpViewModel), typeof(SignUpView), null);
// ReSharper disable once MemberCanBePrivate.Global due to MSDN recommendations.
public static readonly DependencyProperty ViewModelProperty = DependencyProperty
.Register(nameof(ViewModel), typeof(SignUpViewModel), typeof(SignUpView), null);

/// <summary>
/// Initializes a new instance of the <see cref="SignUpView"/> class.
/// </summary>
public SignUpView()
/// <summary>
/// Initializes a new instance of the <see cref="SignUpView"/> class.
/// </summary>
public SignUpView()
{
ViewModel = new SignUpViewModel(null, new UwpUserDialogs());
InitializeComponent();
this.WhenActivated(disposables =>
{
ViewModel = new SignUpViewModel(null, new UwpUserDialogs());
InitializeComponent();
this.WhenActivated(disposables =>
{
this.Bind(ViewModel, x => x.UserName, x => x.UserNameTextBox.Text)
.DisposeWith(disposables);
this.Bind(ViewModel, x => x.Password, x => x.PasswordTextBox.Text)
.DisposeWith(disposables);
this.Bind(ViewModel, x => x.ConfirmPassword, x => x.ConfirmPasswordTextBox.Text)
.DisposeWith(disposables);
this.Bind(ViewModel, x => x.UserName, x => x.UserNameTextBox.Text)
.DisposeWith(disposables);
this.Bind(ViewModel, x => x.Password, x => x.PasswordTextBox.Text)
.DisposeWith(disposables);
this.Bind(ViewModel, x => x.ConfirmPassword, x => x.ConfirmPasswordTextBox.Text)
.DisposeWith(disposables);
this.BindCommand(ViewModel, x => x.SignUp, x => x.SignUpButton)
.DisposeWith(disposables);
this.BindCommand(ViewModel, x => x.SignUp, x => x.SignUpButton)
.DisposeWith(disposables);
this.BindValidation(ViewModel, x => x.UserName, x => x.UserNameErrorLabel.Text)
.DisposeWith(disposables);
this.BindValidation(ViewModel, x => x.Password, x => x.PasswordErrorLabel.Text)
.DisposeWith(disposables);
this.BindValidation(ViewModel, x => x.ConfirmPassword, x => x.ConfirmPasswordErrorLabel.Text)
.DisposeWith(disposables);
this.BindValidation(ViewModel, x => x.ErrorLabel.Text)
.DisposeWith(disposables);
this.BindValidation(ViewModel, x => x.UserName, x => x.UserNameErrorLabel.Text)
.DisposeWith(disposables);
this.BindValidation(ViewModel, x => x.Password, x => x.PasswordErrorLabel.Text)
.DisposeWith(disposables);
this.BindValidation(ViewModel, x => x.ConfirmPassword, x => x.ConfirmPasswordErrorLabel.Text)
.DisposeWith(disposables);
this.BindValidation(ViewModel, x => x.ErrorLabel.Text)
.DisposeWith(disposables);
this.WhenAnyValue(x => x.UserNameErrorLabel.Text, text => !string.IsNullOrWhiteSpace(text))
.BindTo(this, x => x.UserNameErrorLabel.Visibility)
.DisposeWith(disposables);
this.WhenAnyValue(x => x.PasswordErrorLabel.Text, text => !string.IsNullOrWhiteSpace(text))
.BindTo(this, x => x.PasswordErrorLabel.Visibility)
.DisposeWith(disposables);
this.WhenAnyValue(x => x.ConfirmPasswordErrorLabel.Text, text => !string.IsNullOrWhiteSpace(text))
.BindTo(this, x => x.ConfirmPasswordErrorLabel.Visibility)
.DisposeWith(disposables);
});
}
this.WhenAnyValue(x => x.UserNameErrorLabel.Text, text => !string.IsNullOrWhiteSpace(text))
.BindTo(this, x => x.UserNameErrorLabel.Visibility)
.DisposeWith(disposables);
this.WhenAnyValue(x => x.PasswordErrorLabel.Text, text => !string.IsNullOrWhiteSpace(text))
.BindTo(this, x => x.PasswordErrorLabel.Visibility)
.DisposeWith(disposables);
this.WhenAnyValue(x => x.ConfirmPasswordErrorLabel.Text, text => !string.IsNullOrWhiteSpace(text))
.BindTo(this, x => x.ConfirmPasswordErrorLabel.Visibility)
.DisposeWith(disposables);
});
}

/// <summary>
/// Gets or sets the view model.
/// </summary>
public SignUpViewModel ViewModel
{
get => (SignUpViewModel)GetValue(ViewModelProperty);
set => SetValue(ViewModelProperty, value);
}
/// <summary>
/// Gets or sets the view model.
/// </summary>
public SignUpViewModel ViewModel
{
get => (SignUpViewModel)GetValue(ViewModelProperty);
set => SetValue(ViewModelProperty, value);
}

/// <inheritdoc/>
object IViewFor.ViewModel
{
get => ViewModel;
set => ViewModel = (SignUpViewModel)value;
}
/// <inheritdoc/>
object IViewFor.ViewModel
{
get => ViewModel;
set => ViewModel = (SignUpViewModel)value;
}
}
2 changes: 1 addition & 1 deletion samples/LoginApp.WinForms/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2021 .NET Foundation and Contributors. All rights reserved.
// Copyright (c) 2022 .NET Foundation and Contributors. All rights reserved.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.
Expand Down
2 changes: 1 addition & 1 deletion samples/LoginApp.WinForms/Services/WindowsUserDialogs.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2021 .NET Foundation and Contributors. All rights reserved.
// Copyright (c) 2022 .NET Foundation and Contributors. All rights reserved.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.
Expand Down
2 changes: 1 addition & 1 deletion samples/LoginApp.WinForms/Views/SignUpView.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2021 .NET Foundation and Contributors. All rights reserved.
// Copyright (c) 2022 .NET Foundation and Contributors. All rights reserved.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.
Expand Down
2 changes: 1 addition & 1 deletion samples/LoginApp.Wpf/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2021 .NET Foundation and Contributors. All rights reserved.
// Copyright (c) 2022 .NET Foundation and Contributors. All rights reserved.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.
Expand Down
2 changes: 1 addition & 1 deletion samples/LoginApp.Wpf/AppBootstrapper.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2021 .NET Foundation and Contributors. All rights reserved.
// Copyright (c) 2022 .NET Foundation and Contributors. All rights reserved.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.
Expand Down
2 changes: 1 addition & 1 deletion samples/LoginApp.Wpf/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2021 .NET Foundation and Contributors. All rights reserved.
// Copyright (c) 2022 .NET Foundation and Contributors. All rights reserved.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.
Expand Down
2 changes: 1 addition & 1 deletion samples/LoginApp.Wpf/Services/WindowsUserDialogs.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2021 .NET Foundation and Contributors. All rights reserved.
// Copyright (c) 2022 .NET Foundation and Contributors. All rights reserved.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.
Expand Down
2 changes: 1 addition & 1 deletion samples/LoginApp.Wpf/Views/SignUpView.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2021 .NET Foundation and Contributors. All rights reserved.
// Copyright (c) 2022 .NET Foundation and Contributors. All rights reserved.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.
Expand Down
1 change: 1 addition & 0 deletions samples/LoginApp/LoginApp.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="ReactiveUI" Version="17.*" />
Expand Down
21 changes: 10 additions & 11 deletions samples/LoginApp/Services/IUserDialogs.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
// Copyright (c) 2021 .NET Foundation and Contributors. All rights reserved.
// Copyright (c) 2022 .NET Foundation and Contributors. All rights reserved.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.

namespace LoginApp.Services
namespace LoginApp.Services;

/// <summary>
/// This interface defines a platform-specific notification manager.
/// </summary>
public interface IUserDialogs
{
/// <summary>
/// This interface defines a platform-specific notification manager.
/// Displays a platform-specific notification containing a message.
/// </summary>
public interface IUserDialogs
{
/// <summary>
/// Displays a platform-specific notification containing a message.
/// </summary>
/// <param name="message">The message to show.</param>
void ShowDialog(string message);
}
/// <param name="message">The message to show.</param>
void ShowDialog(string message);
}

0 comments on commit 9146f19

Please sign in to comment.