Skip to content

Commit b5188d7

Browse files
committed
use nameof and constants instead of string literals for names and identifiers
1 parent 5ac5e2a commit b5188d7

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

MaterialDesignThemes.Wpf/Snackbar.cs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,12 @@ namespace MaterialDesignThemes.Wpf
1717
/// <summary>
1818
/// Implements a <see cref="Snackbar"/> inspired by the Material Design specs (https://material.google.com/components/snackbars-toasts.html).
1919
/// </summary>
20-
[ContentProperty("Message")]
20+
[ContentProperty(nameof(Message))]
2121
public class Snackbar : Control
2222
{
23+
private const string ActivateStoryboardName = "ActivateStoryboard";
24+
private const string DeactivateStoryboardName = "DeactivateStoryboard";
25+
2326
private Action _messageQueueRegistrationCleanUp = null;
2427

2528
static Snackbar()
@@ -28,7 +31,7 @@ static Snackbar()
2831
}
2932

3033
public static readonly DependencyProperty MessageProperty = DependencyProperty.Register(
31-
"Message", typeof(SnackbarMessage), typeof(Snackbar), new PropertyMetadata(default(SnackbarMessage)));
34+
nameof(Message), typeof(SnackbarMessage), typeof(Snackbar), new PropertyMetadata(default(SnackbarMessage)));
3235

3336
public SnackbarMessage Message
3437
{
@@ -37,7 +40,7 @@ public SnackbarMessage Message
3740
}
3841

3942
public static readonly DependencyProperty MessageQueueProperty = DependencyProperty.Register(
40-
"MessageQueue", typeof(SnackbarMessageQueue), typeof(Snackbar), new PropertyMetadata(default(SnackbarMessageQueue), MessageQueuePropertyChangedCallback));
43+
nameof(MessageQueue), typeof(SnackbarMessageQueue), typeof(Snackbar), new PropertyMetadata(default(SnackbarMessageQueue), MessageQueuePropertyChangedCallback));
4144

4245
private static void MessageQueuePropertyChangedCallback(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs)
4346
{
@@ -54,7 +57,7 @@ public SnackbarMessageQueue MessageQueue
5457
}
5558

5659
public static readonly DependencyProperty IsActiveProperty = DependencyProperty.Register(
57-
"IsActive", typeof(bool), typeof(Snackbar), new PropertyMetadata(default(bool), IsActivePropertyChangedCallback));
60+
nameof(IsActive), typeof(bool), typeof(Snackbar), new PropertyMetadata(default(bool), IsActivePropertyChangedCallback));
5861

5962
public bool IsActive
6063
{
@@ -70,7 +73,7 @@ public event RoutedPropertyChangedEventHandler<bool> IsActiveChanged
7073

7174
public static readonly RoutedEvent IsActiveChangedEvent =
7275
EventManager.RegisterRoutedEvent(
73-
"IsActiveChanged",
76+
nameof(IsActiveChanged),
7477
RoutingStrategy.Bubble,
7578
typeof(RoutedPropertyChangedEventHandler<bool>),
7679
typeof(Snackbar));
@@ -87,7 +90,7 @@ private static void OnIsActiveChanged(
8790

8891
public static readonly RoutedEvent DeactivateStoryboardCompletedEvent =
8992
EventManager.RegisterRoutedEvent(
90-
"DeactivateStoryboardCompleted",
93+
nameof(DeactivateStoryboardCompleted),
9194
RoutingStrategy.Bubble,
9295
typeof(SnackbarMessageEventArgs),
9396
typeof(Snackbar));
@@ -110,7 +113,7 @@ private static void OnDeactivateStoryboardCompleted(
110113
public TimeSpan DeactivateStoryboardDuration { get; private set; }
111114

112115
public static readonly DependencyProperty ActionButtonStyleProperty = DependencyProperty.Register(
113-
"ActionButtonStyle", typeof(Style), typeof(Snackbar), new PropertyMetadata(default(Style)));
116+
nameof(ActionButtonStyle), typeof(Style), typeof(Snackbar), new PropertyMetadata(default(Style)));
114117

115118
public Style ActionButtonStyle
116119
{
@@ -129,8 +132,8 @@ public override void OnApplyTemplate()
129132
//(currently we have no even on the activate animation; don't
130133
// need it just now, but it would mirror the deactivate)
131134

132-
ActivateStoryboardDuration = GetStoryboardResourceDuration("ActivateStoryboard");
133-
DeactivateStoryboardDuration = GetStoryboardResourceDuration("DeactivateStoryboard");
135+
ActivateStoryboardDuration = GetStoryboardResourceDuration(ActivateStoryboardName);
136+
DeactivateStoryboardDuration = GetStoryboardResourceDuration(DeactivateStoryboardName);
134137

135138
base.OnApplyTemplate();
136139
}

0 commit comments

Comments
 (0)