Skip to content

Commit 38da023

Browse files
author
Marcelo Gobetti
committed
Uses C#6 nameof feature to improve maintainability
This will require VS2015+, but nameof was already being used anyway. A future PR will also use typeof(MyProperty) instead of explicitly defining e.g. typeof(bool) on DependencyProperty.Register calls.
1 parent 16bc608 commit 38da023

File tree

17 files changed

+67
-67
lines changed

17 files changed

+67
-67
lines changed

MaterialDesignThemes.Wpf/Card.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ protected override void OnRenderSizeChanged(SizeChangedInfo sizeInfo)
4949
}
5050

5151
public static readonly DependencyProperty UniformCornerRadiusProperty = DependencyProperty.Register(
52-
"UniformCornerRadius", typeof (double), typeof (Card), new FrameworkPropertyMetadata(2.0, FrameworkPropertyMetadataOptions.AffectsMeasure));
52+
nameof(UniformCornerRadius), typeof (double), typeof (Card), new FrameworkPropertyMetadata(2.0, FrameworkPropertyMetadataOptions.AffectsMeasure));
5353

5454
public double UniformCornerRadius
5555
{

MaterialDesignThemes.Wpf/Clock.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public Clock()
6565
}
6666

6767
public static readonly DependencyProperty TimeProperty = DependencyProperty.Register(
68-
"Time", typeof (DateTime), typeof (Clock), new FrameworkPropertyMetadata(default(DateTime), FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, TimePropertyChangedCallback));
68+
nameof(Time), typeof (DateTime), typeof (Clock), new FrameworkPropertyMetadata(default(DateTime), FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, TimePropertyChangedCallback));
6969

7070
private static void TimePropertyChangedCallback(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs)
7171
{
@@ -108,7 +108,7 @@ public bool IsMiddayHour
108108
}
109109

110110
public static readonly DependencyProperty IsPostMeridiemProperty = DependencyProperty.Register(
111-
"IsPostMeridiem", typeof (bool), typeof (Clock), new PropertyMetadata(default(bool), IsPostMeridiemPropertyChangedCallback));
111+
nameof(IsPostMeridiem), typeof (bool), typeof (Clock), new PropertyMetadata(default(bool), IsPostMeridiemPropertyChangedCallback));
112112

113113
private static void IsPostMeridiemPropertyChangedCallback(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs)
114114
{
@@ -126,7 +126,7 @@ public bool IsPostMeridiem
126126
}
127127

128128
public static readonly DependencyProperty Is24HoursProperty = DependencyProperty.Register(
129-
"Is24Hours", typeof (bool), typeof (Clock), new PropertyMetadata(default(bool)));
129+
nameof(Is24Hours), typeof (bool), typeof (Clock), new PropertyMetadata(default(bool)));
130130

131131
public bool Is24Hours
132132
{
@@ -136,7 +136,7 @@ public bool Is24Hours
136136

137137

138138
public static readonly DependencyProperty DisplayModeProperty = DependencyProperty.Register(
139-
"DisplayMode", typeof (ClockDisplayMode), typeof (Clock), new FrameworkPropertyMetadata(ClockDisplayMode.Hours, DisplayModePropertyChangedCallback));
139+
nameof(DisplayMode), typeof (ClockDisplayMode), typeof (Clock), new FrameworkPropertyMetadata(ClockDisplayMode.Hours, DisplayModePropertyChangedCallback));
140140

141141
private static void DisplayModePropertyChangedCallback(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs)
142142
{
@@ -150,7 +150,7 @@ public ClockDisplayMode DisplayMode
150150
}
151151

152152
public static readonly DependencyProperty DisplayAutomationProperty = DependencyProperty.Register(
153-
"DisplayAutomation", typeof (ClockDisplayAutomation), typeof (Clock), new PropertyMetadata(default(ClockDisplayAutomation)));
153+
nameof(DisplayAutomation), typeof (ClockDisplayAutomation), typeof (Clock), new PropertyMetadata(default(ClockDisplayAutomation)));
154154

155155
public ClockDisplayAutomation DisplayAutomation
156156
{
@@ -159,7 +159,7 @@ public ClockDisplayAutomation DisplayAutomation
159159
}
160160

161161
public static readonly DependencyProperty ButtonStyleProperty = DependencyProperty.Register(
162-
"ButtonStyle", typeof (Style), typeof (Clock), new PropertyMetadata(default(Style)));
162+
nameof(ButtonStyle), typeof (Style), typeof (Clock), new PropertyMetadata(default(Style)));
163163

164164
public Style ButtonStyle
165165
{
@@ -168,7 +168,7 @@ public Style ButtonStyle
168168
}
169169

170170
public static readonly DependencyProperty LesserButtonStyleProperty = DependencyProperty.Register(
171-
"LesserButtonStyle", typeof (Style), typeof (Clock), new PropertyMetadata(default(Style)));
171+
nameof(LesserButtonStyle), typeof (Style), typeof (Clock), new PropertyMetadata(default(Style)));
172172

173173
public Style LesserButtonStyle
174174
{
@@ -177,7 +177,7 @@ public Style LesserButtonStyle
177177
}
178178

179179
public static readonly DependencyProperty ButtonRadiusRatioProperty = DependencyProperty.Register(
180-
"ButtonRadiusRatio", typeof (double), typeof (Clock), new PropertyMetadata(default(double)));
180+
nameof(ButtonRadiusRatio), typeof (double), typeof (Clock), new PropertyMetadata(default(double)));
181181

182182
public double ButtonRadiusRatio
183183
{
@@ -186,7 +186,7 @@ public double ButtonRadiusRatio
186186
}
187187

188188
public static readonly DependencyProperty ButtonRadiusInnerRatioProperty = DependencyProperty.Register(
189-
"ButtonRadiusInnerRatio", typeof (double), typeof (Clock), new PropertyMetadata(default(double)));
189+
nameof(ButtonRadiusInnerRatio), typeof (double), typeof (Clock), new PropertyMetadata(default(double)));
190190

191191
public double ButtonRadiusInnerRatio
192192
{

MaterialDesignThemes.Wpf/ClockItemButton.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public class ClockItemButton : ToggleButton
1212
public const string ThumbPartName = "PART_Thumb";
1313

1414
public static readonly DependencyProperty CentreXProperty = DependencyProperty.Register(
15-
"CentreX", typeof (double), typeof (ClockItemButton), new PropertyMetadata(default(double)));
15+
nameof(CentreX), typeof (double), typeof (ClockItemButton), new PropertyMetadata(default(double)));
1616

1717
public double CentreX
1818
{
@@ -21,7 +21,7 @@ public double CentreX
2121
}
2222

2323
public static readonly DependencyProperty CentreYProperty = DependencyProperty.Register(
24-
"CentreY", typeof (double), typeof (ClockItemButton), new PropertyMetadata(default(double)));
24+
nameof(CentreY), typeof (double), typeof (ClockItemButton), new PropertyMetadata(default(double)));
2525

2626
public double CentreY
2727
{

MaterialDesignThemes.Wpf/ColorZone.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ static ColorZone()
3838
}
3939

4040
public static readonly DependencyProperty ModeProperty = DependencyProperty.Register(
41-
"Mode", typeof (ColorZoneMode), typeof (ColorZone), new PropertyMetadata(default(ColorZoneMode)));
41+
nameof(Mode), typeof (ColorZoneMode), typeof (ColorZone), new PropertyMetadata(default(ColorZoneMode)));
4242

4343
public ColorZoneMode Mode
4444
{
@@ -47,7 +47,7 @@ public ColorZoneMode Mode
4747
}
4848

4949
public static readonly DependencyProperty CornerRadiusProperty = DependencyProperty.Register(
50-
"CornerRadius", typeof (CornerRadius), typeof (ColorZone), new PropertyMetadata(default(CornerRadius)));
50+
nameof(CornerRadius), typeof (CornerRadius), typeof (ColorZone), new PropertyMetadata(default(CornerRadius)));
5151

5252
public CornerRadius CornerRadius
5353
{

MaterialDesignThemes.Wpf/DialogHost.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ public DialogHost()
210210
}
211211

212212
public static readonly DependencyProperty IdentifierProperty = DependencyProperty.Register(
213-
"Identifier", typeof (object), typeof (DialogHost), new PropertyMetadata(default(object)));
213+
nameof(Identifier), typeof (object), typeof (DialogHost), new PropertyMetadata(default(object)));
214214

215215
/// <summary>
216216
/// Identifier which is used in conjunction with <see cref="Show(object)"/> to determine where a dialog should be shown.
@@ -222,7 +222,7 @@ public object Identifier
222222
}
223223

224224
public static readonly DependencyProperty IsOpenProperty = DependencyProperty.Register(
225-
"IsOpen", typeof (bool), typeof (DialogHost), new FrameworkPropertyMetadata(default(bool), FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, IsOpenPropertyChangedCallback));
225+
nameof(IsOpen), typeof (bool), typeof (DialogHost), new FrameworkPropertyMetadata(default(bool), FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, IsOpenPropertyChangedCallback));
226226

227227
private static void IsOpenPropertyChangedCallback(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs)
228228
{
@@ -281,7 +281,7 @@ public bool IsOpen
281281
}
282282

283283
public static readonly DependencyProperty DialogContentProperty = DependencyProperty.Register(
284-
"DialogContent", typeof (object), typeof (DialogHost), new PropertyMetadata(default(object)));
284+
nameof(DialogContent), typeof (object), typeof (DialogHost), new PropertyMetadata(default(object)));
285285

286286
public object DialogContent
287287
{
@@ -290,7 +290,7 @@ public object DialogContent
290290
}
291291

292292
public static readonly DependencyProperty DialogContentTemplateProperty = DependencyProperty.Register(
293-
"DialogContentTemplate", typeof (DataTemplate), typeof (DialogHost), new PropertyMetadata(default(DataTemplate)));
293+
nameof(DialogContentTemplate), typeof (DataTemplate), typeof (DialogHost), new PropertyMetadata(default(DataTemplate)));
294294

295295
public DataTemplate DialogContentTemplate
296296
{
@@ -299,7 +299,7 @@ public DataTemplate DialogContentTemplate
299299
}
300300

301301
public static readonly DependencyProperty DialogContentTemplateSelectorProperty = DependencyProperty.Register(
302-
"DialogContentTemplateSelector", typeof (DataTemplateSelector), typeof (DialogHost), new PropertyMetadata(default(DataTemplateSelector)));
302+
nameof(DialogContentTemplateSelector), typeof (DataTemplateSelector), typeof (DialogHost), new PropertyMetadata(default(DataTemplateSelector)));
303303

304304
public DataTemplateSelector DialogContentTemplateSelector
305305
{
@@ -308,7 +308,7 @@ public DataTemplateSelector DialogContentTemplateSelector
308308
}
309309

310310
public static readonly DependencyProperty DialogContentStringFormatProperty = DependencyProperty.Register(
311-
"DialogContentStringFormat", typeof (string), typeof (DialogHost), new PropertyMetadata(default(string)));
311+
nameof(DialogContentStringFormat), typeof (string), typeof (DialogHost), new PropertyMetadata(default(string)));
312312

313313
public string DialogContentStringFormat
314314
{
@@ -317,7 +317,7 @@ public string DialogContentStringFormat
317317
}
318318

319319
public static readonly DependencyProperty OpenDialogCommandDataContextSourceProperty = DependencyProperty.Register(
320-
"OpenDialogCommandDataContextSource", typeof (DialogHostOpenDialogCommandDataContextSource), typeof (DialogHost), new PropertyMetadata(default(DialogHostOpenDialogCommandDataContextSource)));
320+
nameof(OpenDialogCommandDataContextSource), typeof (DialogHostOpenDialogCommandDataContextSource), typeof (DialogHost), new PropertyMetadata(default(DialogHostOpenDialogCommandDataContextSource)));
321321

322322
/// <summary>
323323
/// Defines how a data context is sourced for a dialog if a <see cref="FrameworkElement"/>
@@ -374,7 +374,7 @@ public static DialogOpenedEventHandler GetDialogOpenedAttached(DependencyObject
374374
}
375375

376376
public static readonly DependencyProperty DialogOpenedCallbackProperty = DependencyProperty.Register(
377-
"DialogOpenedCallback", typeof(DialogOpenedEventHandler), typeof(DialogHost), new PropertyMetadata(default(DialogOpenedEventHandler)));
377+
nameof(DialogOpenedCallback), typeof(DialogOpenedEventHandler), typeof(DialogHost), new PropertyMetadata(default(DialogOpenedEventHandler)));
378378

379379
/// <summary>
380380
/// Callback fired when the <see cref="DialogOpened"/> event is fired, allowing the event to be processed from a binding/view model.
@@ -427,7 +427,7 @@ public static DialogClosingEventHandler GetDialogClosingAttached(DependencyObjec
427427
}
428428

429429
public static readonly DependencyProperty DialogClosingCallbackProperty = DependencyProperty.Register(
430-
"DialogClosingCallback", typeof (DialogClosingEventHandler), typeof (DialogHost), new PropertyMetadata(default(DialogClosingEventHandler)));
430+
nameof(DialogClosingCallback), typeof (DialogClosingEventHandler), typeof (DialogHost), new PropertyMetadata(default(DialogClosingEventHandler)));
431431

432432
/// <summary>
433433
/// Callback fired when the <see cref="DialogClosing"/> event is fired, allowing the event to be processed from a binding/view model.

MaterialDesignThemes.Wpf/DrawerHost.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public DrawerHost()
3939
}
4040

4141
public static readonly DependencyProperty LeftDrawerContentProperty = DependencyProperty.Register(
42-
"LeftDrawerContent", typeof (object), typeof (DrawerHost), new PropertyMetadata(default(object)));
42+
nameof(LeftDrawerContent), typeof (object), typeof (DrawerHost), new PropertyMetadata(default(object)));
4343

4444
public object LeftDrawerContent
4545
{
@@ -48,7 +48,7 @@ public object LeftDrawerContent
4848
}
4949

5050
public static readonly DependencyProperty LeftDrawerContentTemplateProperty = DependencyProperty.Register(
51-
"LeftDrawerContentTemplate", typeof (DataTemplate), typeof (DrawerHost), new PropertyMetadata(default(DataTemplate)));
51+
nameof(LeftDrawerContentTemplate), typeof (DataTemplate), typeof (DrawerHost), new PropertyMetadata(default(DataTemplate)));
5252

5353
public DataTemplate LeftDrawerContentTemplate
5454
{
@@ -57,7 +57,7 @@ public DataTemplate LeftDrawerContentTemplate
5757
}
5858

5959
public static readonly DependencyProperty LeftDrawerContentTemplateSelectorProperty = DependencyProperty.Register(
60-
"LeftDrawerContentTemplateSelector", typeof (DataTemplateSelector), typeof (DrawerHost), new PropertyMetadata(default(DataTemplateSelector)));
60+
nameof(LeftDrawerContentTemplateSelector), typeof (DataTemplateSelector), typeof (DrawerHost), new PropertyMetadata(default(DataTemplateSelector)));
6161

6262
public DataTemplateSelector LeftDrawerContentTemplateSelector
6363
{
@@ -66,7 +66,7 @@ public DataTemplateSelector LeftDrawerContentTemplateSelector
6666
}
6767

6868
public static readonly DependencyProperty LeftDrawerContentStringFormatProperty = DependencyProperty.Register(
69-
"LeftDrawerContentStringFormat", typeof (string), typeof (DrawerHost), new PropertyMetadata(default(string)));
69+
nameof(LeftDrawerContentStringFormat), typeof (string), typeof (DrawerHost), new PropertyMetadata(default(string)));
7070

7171
public string LeftDrawerContentStringFormat
7272
{
@@ -75,7 +75,7 @@ public string LeftDrawerContentStringFormat
7575
}
7676

7777
public static readonly DependencyProperty LeftDrawerBackgroundProperty = DependencyProperty.Register(
78-
"LeftDrawerBackground", typeof (Brush), typeof (DrawerHost), new PropertyMetadata(default(Brush)));
78+
nameof(LeftDrawerBackground), typeof (Brush), typeof (DrawerHost), new PropertyMetadata(default(Brush)));
7979

8080
public Brush LeftDrawerBackground
8181
{
@@ -84,7 +84,7 @@ public Brush LeftDrawerBackground
8484
}
8585

8686
public static readonly DependencyProperty IsLeftDrawerOpenProperty = DependencyProperty.Register(
87-
"IsLeftDrawerOpen", typeof (bool), typeof (DrawerHost), new FrameworkPropertyMetadata(default(bool), FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, IsLeftDrawerOpenPropertyChangedCallback));
87+
nameof(IsLeftDrawerOpen), typeof (bool), typeof (DrawerHost), new FrameworkPropertyMetadata(default(bool), FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, IsLeftDrawerOpenPropertyChangedCallback));
8888

8989
public bool IsLeftDrawerOpen
9090
{

MaterialDesignThemes.Wpf/Icon.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace MaterialDesignThemes.Wpf
1313
public class Icon : Control
1414
{
1515
public static readonly DependencyProperty TypeProperty = DependencyProperty.Register(
16-
"Type", typeof (IconType), typeof (Icon), new PropertyMetadata(default(IconType)));
16+
nameof(Type), typeof (IconType), typeof (Icon), new PropertyMetadata(default(IconType)));
1717

1818
/// <summary>
1919
/// Gets or sets the name of icon being displayed.

MaterialDesignThemes.Wpf/ListSortDirectionIndicator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public override void OnApplyTemplate()
3030

3131

3232
public static readonly DependencyProperty ListSortDirectionProperty = DependencyProperty.Register(
33-
"ListSortDirection", typeof (ListSortDirection?), typeof (ListSortDirectionIndicator), new PropertyMetadata(default(ListSortDirection?), ListSortDirectionPropertyChangedCallback));
33+
nameof(ListSortDirection), typeof (ListSortDirection?), typeof (ListSortDirectionIndicator), new PropertyMetadata(default(ListSortDirection?), ListSortDirectionPropertyChangedCallback));
3434

3535
private static void ListSortDirectionPropertyChangedCallback(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs)
3636
{

MaterialDesignThemes.Wpf/MaterialDateDisplay.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public MaterialDateDisplay()
4343
}
4444

4545
public static readonly DependencyProperty DisplayDateProperty = DependencyProperty.Register(
46-
"DisplayDate", typeof (DateTime), typeof (MaterialDateDisplay), new PropertyMetadata(default(DateTime), DisplayDatePropertyChangedCallback));
46+
nameof(DisplayDate), typeof (DateTime), typeof (MaterialDateDisplay), new PropertyMetadata(default(DateTime), DisplayDatePropertyChangedCallback));
4747

4848
private static void DisplayDatePropertyChangedCallback(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs)
4949
{

0 commit comments

Comments
 (0)