Skip to content

Commit a136eeb

Browse files
authored
Merge pull request #71 from CommunityToolkit/dev/fix-line-terminators
Normalize line terminators to CRLF
2 parents 2251e13 + 385f4d1 commit a136eeb

36 files changed

+650
-662
lines changed

.git-blame-ignore-revs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
# Refactor to file-scoped namespaces
22
4c8a30e4d6588d0921dca49e8ab3fb1c01e35c08
3+
4+
# Fix incorrect line terminators
5+
382a58f8883388e36fdbc0154c415141317080d9
Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
1-
// Licensed to the .NET Foundation under one or more agreements.
2-
// The .NET Foundation licenses this file to you under the MIT license.
3-
// See the LICENSE file in the project root for more information.
4-
5-
using System.Threading.Tasks;
6-
using CommunityToolkit.Mvvm.Input;
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
using System.Threading.Tasks;
6+
using CommunityToolkit.Mvvm.Input;
77
using MvvmSample.Core.Services;
8-
9-
namespace MvvmSample.Core.ViewModels;
10-
11-
public class AsyncRelayCommandPageViewModel : SamplePageViewModel
12-
{
13-
public AsyncRelayCommandPageViewModel(IFilesService filesService)
14-
: base(filesService)
15-
{
16-
DownloadTextCommand = new AsyncRelayCommand(DownloadTextAsync);
17-
}
18-
19-
public IAsyncRelayCommand DownloadTextCommand { get; }
20-
21-
private async Task<string> DownloadTextAsync()
22-
{
23-
await Task.Delay(3000); // Simulate a web request
24-
25-
return "Hello world!";
26-
}
27-
}
8+
9+
namespace MvvmSample.Core.ViewModels;
10+
11+
public class AsyncRelayCommandPageViewModel : SamplePageViewModel
12+
{
13+
public AsyncRelayCommandPageViewModel(IFilesService filesService)
14+
: base(filesService)
15+
{
16+
DownloadTextCommand = new AsyncRelayCommand(DownloadTextAsync);
17+
}
18+
19+
public IAsyncRelayCommand DownloadTextCommand { get; }
20+
21+
private async Task<string> DownloadTextAsync()
22+
{
23+
await Task.Delay(3000); // Simulate a web request
24+
25+
return "Hello world!";
26+
}
27+
}
Lines changed: 107 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -1,108 +1,108 @@
1-
// Licensed to the .NET Foundation under one or more agreements.
2-
// The .NET Foundation licenses this file to you under the MIT license.
3-
// See the LICENSE file in the project root for more information.
4-
5-
using System.Windows.Input;
6-
using CommunityToolkit.Mvvm.ComponentModel;
7-
using CommunityToolkit.Mvvm.Input;
8-
using CommunityToolkit.Mvvm.Messaging;
9-
using CommunityToolkit.Mvvm.Messaging.Messages;
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
using System.Windows.Input;
6+
using CommunityToolkit.Mvvm.ComponentModel;
7+
using CommunityToolkit.Mvvm.Input;
8+
using CommunityToolkit.Mvvm.Messaging;
9+
using CommunityToolkit.Mvvm.Messaging.Messages;
1010
using MvvmSample.Core.Services;
11-
12-
namespace MvvmSample.Core.ViewModels;
13-
14-
public class MessengerPageViewModel : SamplePageViewModel
15-
{
16-
public MessengerPageViewModel(IFilesService filesService)
17-
: base(filesService)
18-
{
19-
RequestCurrentUsernameCommand = new RelayCommand(RequestCurrentUsername);
20-
ResetCurrentUsernameCommand = new RelayCommand(ResetCurrentUsername);
21-
}
22-
23-
public ICommand RequestCurrentUsernameCommand { get; }
24-
public ICommand ResetCurrentUsernameCommand { get; }
25-
26-
public UserSenderViewModel SenderViewModel { get; } = new();
27-
28-
public UserReceiverViewModel ReceiverViewModel { get; } = new();
29-
30-
// Simple viewmodel for a module sending a username message
31-
public class UserSenderViewModel : ObservableRecipient
32-
{
33-
public UserSenderViewModel()
34-
{
35-
SendUserMessageCommand = new RelayCommand(SendUserMessage);
36-
}
37-
38-
public ICommand SendUserMessageCommand { get; }
39-
40-
private string username = "Bob";
41-
42-
public string Username
43-
{
44-
get => username;
45-
private set => SetProperty(ref username, value);
46-
}
47-
48-
protected override void OnActivated()
49-
{
50-
Messenger.Register<UserSenderViewModel, CurrentUsernameRequestMessage>(this, (r, m) => m.Reply(r.Username));
51-
}
52-
53-
public void SendUserMessage()
54-
{
55-
Username = Username == "Bob" ? "Alice" : "Bob";
56-
57-
Messenger.Send(new UsernameChangedMessage(Username));
58-
}
59-
}
60-
61-
// Simple viewmodel for a module receiving a username message
62-
public class UserReceiverViewModel : ObservableRecipient
63-
{
64-
private string username = "";
65-
66-
public string Username
67-
{
68-
get => username;
69-
private set => SetProperty(ref username, value);
70-
}
71-
72-
protected override void OnActivated()
73-
{
74-
Messenger.Register<UserReceiverViewModel, UsernameChangedMessage>(this, (r, m) => r.Username = m.Value);
75-
}
76-
}
77-
78-
private string? username;
79-
80-
public string? Username
81-
{
82-
get => username;
83-
private set => SetProperty(ref username, value);
84-
}
85-
86-
public void RequestCurrentUsername()
87-
{
88-
Username = WeakReferenceMessenger.Default.Send<CurrentUsernameRequestMessage>();
89-
}
90-
91-
public void ResetCurrentUsername()
92-
{
93-
Username = null;
94-
}
95-
96-
// A sample message with a username value
97-
public sealed class UsernameChangedMessage : ValueChangedMessage<string>
98-
{
99-
public UsernameChangedMessage(string value) : base(value)
100-
{
101-
}
102-
}
103-
104-
// A sample request message to get the current username
105-
public sealed class CurrentUsernameRequestMessage : RequestMessage<string>
106-
{
107-
}
108-
}
11+
12+
namespace MvvmSample.Core.ViewModels;
13+
14+
public class MessengerPageViewModel : SamplePageViewModel
15+
{
16+
public MessengerPageViewModel(IFilesService filesService)
17+
: base(filesService)
18+
{
19+
RequestCurrentUsernameCommand = new RelayCommand(RequestCurrentUsername);
20+
ResetCurrentUsernameCommand = new RelayCommand(ResetCurrentUsername);
21+
}
22+
23+
public ICommand RequestCurrentUsernameCommand { get; }
24+
public ICommand ResetCurrentUsernameCommand { get; }
25+
26+
public UserSenderViewModel SenderViewModel { get; } = new();
27+
28+
public UserReceiverViewModel ReceiverViewModel { get; } = new();
29+
30+
// Simple viewmodel for a module sending a username message
31+
public class UserSenderViewModel : ObservableRecipient
32+
{
33+
public UserSenderViewModel()
34+
{
35+
SendUserMessageCommand = new RelayCommand(SendUserMessage);
36+
}
37+
38+
public ICommand SendUserMessageCommand { get; }
39+
40+
private string username = "Bob";
41+
42+
public string Username
43+
{
44+
get => username;
45+
private set => SetProperty(ref username, value);
46+
}
47+
48+
protected override void OnActivated()
49+
{
50+
Messenger.Register<UserSenderViewModel, CurrentUsernameRequestMessage>(this, (r, m) => m.Reply(r.Username));
51+
}
52+
53+
public void SendUserMessage()
54+
{
55+
Username = Username == "Bob" ? "Alice" : "Bob";
56+
57+
Messenger.Send(new UsernameChangedMessage(Username));
58+
}
59+
}
60+
61+
// Simple viewmodel for a module receiving a username message
62+
public class UserReceiverViewModel : ObservableRecipient
63+
{
64+
private string username = "";
65+
66+
public string Username
67+
{
68+
get => username;
69+
private set => SetProperty(ref username, value);
70+
}
71+
72+
protected override void OnActivated()
73+
{
74+
Messenger.Register<UserReceiverViewModel, UsernameChangedMessage>(this, (r, m) => r.Username = m.Value);
75+
}
76+
}
77+
78+
private string? username;
79+
80+
public string? Username
81+
{
82+
get => username;
83+
private set => SetProperty(ref username, value);
84+
}
85+
86+
public void RequestCurrentUsername()
87+
{
88+
Username = WeakReferenceMessenger.Default.Send<CurrentUsernameRequestMessage>();
89+
}
90+
91+
public void ResetCurrentUsername()
92+
{
93+
Username = null;
94+
}
95+
96+
// A sample message with a username value
97+
public sealed class UsernameChangedMessage : ValueChangedMessage<string>
98+
{
99+
public UsernameChangedMessage(string value) : base(value)
100+
{
101+
}
102+
}
103+
104+
// A sample request message to get the current username
105+
public sealed class CurrentUsernameRequestMessage : RequestMessage<string>
106+
{
107+
}
108+
}
Lines changed: 53 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,54 @@
1-
// Licensed to the .NET Foundation under one or more agreements.
2-
// The .NET Foundation licenses this file to you under the MIT license.
3-
// See the LICENSE file in the project root for more information.
4-
5-
using System.Threading.Tasks;
6-
using System.Windows.Input;
7-
using CommunityToolkit.Mvvm.Input;
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
using System.Threading.Tasks;
6+
using System.Windows.Input;
7+
using CommunityToolkit.Mvvm.Input;
88
using MvvmSample.Core.Services;
9-
10-
namespace MvvmSample.Core.ViewModels;
11-
12-
public class ObservableObjectPageViewModel : SamplePageViewModel
13-
{
14-
public ObservableObjectPageViewModel(IFilesService filesService)
15-
: base(filesService)
16-
{
17-
ReloadTaskCommand = new RelayCommand(ReloadTask);
18-
}
19-
20-
/// <summary>
21-
/// Gets the <see cref="ICommand"/> responsible for setting <see cref="MyTask"/>.
22-
/// </summary>
23-
public ICommand ReloadTaskCommand { get; }
24-
25-
private string? name;
26-
27-
/// <summary>
28-
/// Gets or sets the name to display.
29-
/// </summary>
30-
public string? Name
31-
{
32-
get => name;
33-
set => SetProperty(ref name, value);
34-
}
35-
36-
private TaskNotifier? myTask;
37-
38-
/// <summary>
39-
/// Gets or sets the name to display.
40-
/// </summary>
41-
public Task? MyTask
42-
{
43-
get => myTask;
44-
private set => SetPropertyAndNotifyOnCompletion(ref myTask, value);
45-
}
46-
47-
/// <summary>
48-
/// Simulates an asynchronous method.
49-
/// </summary>
50-
public void ReloadTask()
51-
{
52-
MyTask = Task.Delay(3000);
53-
}
54-
}
9+
10+
namespace MvvmSample.Core.ViewModels;
11+
12+
public class ObservableObjectPageViewModel : SamplePageViewModel
13+
{
14+
public ObservableObjectPageViewModel(IFilesService filesService)
15+
: base(filesService)
16+
{
17+
ReloadTaskCommand = new RelayCommand(ReloadTask);
18+
}
19+
20+
/// <summary>
21+
/// Gets the <see cref="ICommand"/> responsible for setting <see cref="MyTask"/>.
22+
/// </summary>
23+
public ICommand ReloadTaskCommand { get; }
24+
25+
private string? name;
26+
27+
/// <summary>
28+
/// Gets or sets the name to display.
29+
/// </summary>
30+
public string? Name
31+
{
32+
get => name;
33+
set => SetProperty(ref name, value);
34+
}
35+
36+
private TaskNotifier? myTask;
37+
38+
/// <summary>
39+
/// Gets or sets the name to display.
40+
/// </summary>
41+
public Task? MyTask
42+
{
43+
get => myTask;
44+
private set => SetPropertyAndNotifyOnCompletion(ref myTask, value);
45+
}
46+
47+
/// <summary>
48+
/// Simulates an asynchronous method.
49+
/// </summary>
50+
public void ReloadTask()
51+
{
52+
MyTask = Task.Delay(3000);
53+
}
54+
}

0 commit comments

Comments
 (0)