Skip to content

Commit 22b477b

Browse files
committed
file scoped namespaces
1 parent 1448aa6 commit 22b477b

File tree

103 files changed

+2849
-2953
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+2849
-2953
lines changed

ValidCode.Netcore/IntControl.cs

Lines changed: 53 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,72 @@
1-
namespace ValidCode.Netcore
1+
namespace ValidCode.Netcore;
2+
3+
using System.ComponentModel;
4+
using System.Windows;
5+
using System.Windows.Controls;
6+
7+
public class IntControl : Control
28
{
3-
using System.ComponentModel;
4-
using System.Windows;
5-
using System.Windows.Controls;
9+
/// <summary>Identifies the <see cref="Number"/> dependency property.</summary>
10+
public static readonly DependencyProperty NumberProperty = DependencyProperty.Register(
11+
nameof(Number),
12+
typeof(int),
13+
typeof(IntControl),
14+
new PropertyMetadata(
15+
0,
16+
OnNumberChanged,
17+
CoerceNumber),
18+
ValidateNumber);
619

7-
public class IntControl : Control
20+
static IntControl()
821
{
9-
/// <summary>Identifies the <see cref="Number"/> dependency property.</summary>
10-
public static readonly DependencyProperty NumberProperty = DependencyProperty.Register(
11-
nameof(Number),
12-
typeof(int),
13-
typeof(IntControl),
14-
new PropertyMetadata(
15-
0,
16-
OnNumberChanged,
17-
CoerceNumber),
18-
ValidateNumber);
22+
DefaultStyleKeyProperty.OverrideMetadata(typeof(IntControl), new FrameworkPropertyMetadata(typeof(IntControl)));
23+
}
1924

20-
static IntControl()
21-
{
22-
DefaultStyleKeyProperty.OverrideMetadata(typeof(IntControl), new FrameworkPropertyMetadata(typeof(IntControl)));
23-
}
25+
public int Number
26+
{
27+
get => (int)this.GetValue(NumberProperty);
28+
set => this.SetValue(NumberProperty, value);
29+
}
2430

25-
public int Number
26-
{
27-
get => (int)this.GetValue(NumberProperty);
28-
set => this.SetValue(NumberProperty, value);
29-
}
31+
protected void OnNumberChanged(int oldValue, int newValue)
32+
{
33+
}
3034

31-
protected void OnNumberChanged(int oldValue, int newValue)
35+
private static void OnNumberChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
36+
{
37+
if (DesignerProperties.GetIsInDesignMode(d))
3238
{
39+
return;
3340
}
3441

35-
private static void OnNumberChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
36-
{
37-
if (DesignerProperties.GetIsInDesignMode(d))
38-
{
39-
return;
40-
}
42+
((IntControl)d).OnNumberChanged((int)e.NewValue, (int)e.OldValue);
43+
}
4144

42-
((IntControl)d).OnNumberChanged((int)e.NewValue, (int)e.OldValue);
45+
private static object CoerceNumber(DependencyObject d, object? baseValue)
46+
{
47+
if (DesignerProperties.GetIsInDesignMode(d))
48+
{
49+
return -1;
4350
}
4451

45-
private static object CoerceNumber(DependencyObject d, object? baseValue)
52+
return baseValue switch
4653
{
47-
if (DesignerProperties.GetIsInDesignMode(d))
48-
{
49-
return -1;
50-
}
54+
int i => i,
55+
_ => 0,
56+
};
57+
}
5158

52-
return baseValue switch
53-
{
54-
int i => i,
55-
_ => 0,
56-
};
59+
private static bool ValidateNumber(object? value)
60+
{
61+
if (value is int)
62+
{
63+
return false;
5764
}
5865

59-
private static bool ValidateNumber(object? value)
66+
return value switch
6067
{
61-
if (value is int)
62-
{
63-
return false;
64-
}
65-
66-
return value switch
67-
{
68-
string s => s.Length > 1,
69-
_ => false,
70-
};
71-
}
68+
string s => s.Length > 1,
69+
_ => false,
70+
};
7271
}
7372
}
Lines changed: 53 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,72 @@
1-
namespace ValidCode.Netcore
1+
namespace ValidCode.Netcore;
2+
3+
using System.ComponentModel;
4+
using System.Windows;
5+
using System.Windows.Controls;
6+
7+
public class NullableIntControl : Control
28
{
3-
using System.ComponentModel;
4-
using System.Windows;
5-
using System.Windows.Controls;
9+
/// <summary>Identifies the <see cref="Number"/> dependency property.</summary>
10+
public static readonly DependencyProperty NumberProperty = DependencyProperty.Register(
11+
nameof(Number),
12+
typeof(int?),
13+
typeof(NullableIntControl),
14+
new PropertyMetadata(
15+
null,
16+
OnNumberChanged,
17+
CoerceNumber),
18+
ValidateNumber);
619

7-
public class NullableIntControl : Control
20+
static NullableIntControl()
821
{
9-
/// <summary>Identifies the <see cref="Number"/> dependency property.</summary>
10-
public static readonly DependencyProperty NumberProperty = DependencyProperty.Register(
11-
nameof(Number),
12-
typeof(int?),
13-
typeof(NullableIntControl),
14-
new PropertyMetadata(
15-
null,
16-
OnNumberChanged,
17-
CoerceNumber),
18-
ValidateNumber);
22+
DefaultStyleKeyProperty.OverrideMetadata(typeof(NullableIntControl), new FrameworkPropertyMetadata(typeof(NullableIntControl)));
23+
}
1924

20-
static NullableIntControl()
21-
{
22-
DefaultStyleKeyProperty.OverrideMetadata(typeof(NullableIntControl), new FrameworkPropertyMetadata(typeof(NullableIntControl)));
23-
}
25+
public int? Number
26+
{
27+
get => (int?)this.GetValue(NumberProperty);
28+
set => this.SetValue(NumberProperty, value);
29+
}
2430

25-
public int? Number
26-
{
27-
get => (int?)this.GetValue(NumberProperty);
28-
set => this.SetValue(NumberProperty, value);
29-
}
31+
protected void OnNumberChanged(int? oldValue, int? newValue)
32+
{
33+
}
3034

31-
protected void OnNumberChanged(int? oldValue, int? newValue)
35+
private static void OnNumberChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
36+
{
37+
if (DesignerProperties.GetIsInDesignMode(d))
3238
{
39+
return;
3340
}
3441

35-
private static void OnNumberChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
36-
{
37-
if (DesignerProperties.GetIsInDesignMode(d))
38-
{
39-
return;
40-
}
42+
((NullableIntControl)d).OnNumberChanged((int?)e.NewValue, (int?)e.OldValue);
43+
}
4144

42-
((NullableIntControl)d).OnNumberChanged((int?)e.NewValue, (int?)e.OldValue);
45+
private static object CoerceNumber(DependencyObject d, object? baseValue)
46+
{
47+
if (DesignerProperties.GetIsInDesignMode(d))
48+
{
49+
return -1;
4350
}
4451

45-
private static object CoerceNumber(DependencyObject d, object? baseValue)
52+
return baseValue switch
4653
{
47-
if (DesignerProperties.GetIsInDesignMode(d))
48-
{
49-
return -1;
50-
}
54+
int i => i,
55+
_ => 0,
56+
};
57+
}
5158

52-
return baseValue switch
53-
{
54-
int i => i,
55-
_ => 0,
56-
};
59+
private static bool ValidateNumber(object? value)
60+
{
61+
if (value is int)
62+
{
63+
return false;
5764
}
5865

59-
private static bool ValidateNumber(object? value)
66+
return value switch
6067
{
61-
if (value is int)
62-
{
63-
return false;
64-
}
65-
66-
return value switch
67-
{
68-
string s => s.Length > 1,
69-
_ => false,
70-
};
71-
}
68+
string s => s.Length > 1,
69+
_ => false,
70+
};
7271
}
7372
}
Lines changed: 53 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,72 @@
1-
namespace ValidCode.Netcore
1+
namespace ValidCode.Netcore;
2+
3+
using System.ComponentModel;
4+
using System.Windows;
5+
using System.Windows.Controls;
6+
7+
public class NullableStringControl : Control
28
{
3-
using System.ComponentModel;
4-
using System.Windows;
5-
using System.Windows.Controls;
9+
/// <summary>Identifies the <see cref="Text"/> dependency property.</summary>
10+
public static readonly DependencyProperty TextProperty = DependencyProperty.Register(
11+
nameof(Text),
12+
typeof(string),
13+
typeof(NullableStringControl),
14+
new PropertyMetadata(
15+
null,
16+
OnTextChanged,
17+
CoerceText),
18+
ValidateText);
619

7-
public class NullableStringControl : Control
20+
static NullableStringControl()
821
{
9-
/// <summary>Identifies the <see cref="Text"/> dependency property.</summary>
10-
public static readonly DependencyProperty TextProperty = DependencyProperty.Register(
11-
nameof(Text),
12-
typeof(string),
13-
typeof(NullableStringControl),
14-
new PropertyMetadata(
15-
null,
16-
OnTextChanged,
17-
CoerceText),
18-
ValidateText);
22+
DefaultStyleKeyProperty.OverrideMetadata(typeof(NullableStringControl), new FrameworkPropertyMetadata(typeof(NullableStringControl)));
23+
}
1924

20-
static NullableStringControl()
21-
{
22-
DefaultStyleKeyProperty.OverrideMetadata(typeof(NullableStringControl), new FrameworkPropertyMetadata(typeof(NullableStringControl)));
23-
}
25+
public string? Text
26+
{
27+
get => (string?)this.GetValue(TextProperty);
28+
set => this.SetValue(TextProperty, value);
29+
}
2430

25-
public string? Text
26-
{
27-
get => (string?)this.GetValue(TextProperty);
28-
set => this.SetValue(TextProperty, value);
29-
}
31+
protected void OnTextChanged(string? oldValue, string? newValue)
32+
{
33+
}
3034

31-
protected void OnTextChanged(string? oldValue, string? newValue)
35+
private static void OnTextChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
36+
{
37+
if (DesignerProperties.GetIsInDesignMode(d))
3238
{
39+
return;
3340
}
3441

35-
private static void OnTextChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
36-
{
37-
if (DesignerProperties.GetIsInDesignMode(d))
38-
{
39-
return;
40-
}
42+
((NullableStringControl)d).OnTextChanged((string?)e.NewValue, (string?)e.OldValue);
43+
}
4144

42-
((NullableStringControl)d).OnTextChanged((string?)e.NewValue, (string?)e.OldValue);
45+
private static object? CoerceText(DependencyObject d, object? baseValue)
46+
{
47+
if (DesignerProperties.GetIsInDesignMode(d))
48+
{
49+
return null;
4350
}
4451

45-
private static object? CoerceText(DependencyObject d, object? baseValue)
52+
return baseValue switch
4653
{
47-
if (DesignerProperties.GetIsInDesignMode(d))
48-
{
49-
return null;
50-
}
54+
string s => s,
55+
_ => null,
56+
};
57+
}
5158

52-
return baseValue switch
53-
{
54-
string s => s,
55-
_ => null,
56-
};
59+
private static bool ValidateText(object? value)
60+
{
61+
if (value is null)
62+
{
63+
return true;
5764
}
5865

59-
private static bool ValidateText(object? value)
66+
return value switch
6067
{
61-
if (value is null)
62-
{
63-
return true;
64-
}
65-
66-
return value switch
67-
{
68-
string s => s.Length > 1,
69-
_ => false,
70-
};
71-
}
68+
string s => s.Length > 1,
69+
_ => false,
70+
};
7271
}
7372
}

0 commit comments

Comments
 (0)