質問は「プロパティをまとめたい」ですが、その後のコメントを見るとプロパティの記述が簡単になりさえすればいいように見えます。
また、プロパティは何か特別な処理をするものではなく、定型的なものが並ぶだけなのでそれをループで処理できれば最も意図に沿うのではないかと思いました。
テキストテンプレートを使うと、いくらプロパティが増えても大丈夫です。
ただし、補完が使えなくなるので、主となるソースとは別ファイルにして partial class とすれば良いと思います。これによって一つのクラスを複数のファイルに分割して記述できます。
C#
1<#@ template debug="false" hostspecific="false" language="C#" #>
2<#@ assembly name="System.Core" #>
3<#@ import namespace="System.Linq" #>
4<#@ import namespace="System.Text" #>
5<#@ import namespace="System.Collections.Generic" #>
6<#@ output extension=".cs" #>
7
8using System;
9using System.Collections.Generic;
10using System.Linq;
11using System.Text;
12using System.Threading.Tasks;
13
14namespace ConsoleApp1
15{
16 public partial class Class1
17 {
18<#
19var names = new string[]
20{
21 "xAccel", "yAccel", "zAccel", "xHoge"
22};
23foreach (var name in names)
24{
25#>
26 private string _<#= name #>;
27 public string <#= name #>
28 {
29 get => _<#= name #>;
30 set
31 {
32 if (value == _<#= name #>) return;
33 _<#= name #> = value;
34 OnPropertyChanged("<#= name#>");
35 }
36 }
37<#
38}
39#>
40 }
41}
42
テキストテンプレートの記述は上記です。
プロパティが増えた時には names の要素を増やしてください。
これを保存すると次のように展開された cs が自動的に生成されます。
C#
1
2using System;
3using System.Collections.Generic;
4using System.Linq;
5using System.Text;
6using System.Threading.Tasks;
7
8namespace ConsoleApp1
9{
10 public partial class Class1
11 {
12 private string _xAccel;
13 public string xAccel
14 {
15 get => _xAccel;
16 set
17 {
18 if (value == _xAccel) return;
19 _xAccel = value;
20 OnPropertyChanged("xAccel");
21 }
22 }
23 private string _yAccel;
24 public string yAccel
25 {
26 get => _yAccel;
27 set
28 {
29 if (value == _yAccel) return;
30 _yAccel = value;
31 OnPropertyChanged("yAccel");
32 }
33 }
34 private string _zAccel;
35 public string zAccel
36 {
37 get => _zAccel;
38 set
39 {
40 if (value == _zAccel) return;
41 _zAccel = value;
42 OnPropertyChanged("zAccel");
43 }
44 }
45 private string _xHoge;
46 public string xHoge
47 {
48 get => _xHoge;
49 set
50 {
51 if (value == _xHoge) return;
52 _xHoge = value;
53 OnPropertyChanged("xHoge");
54 }
55 }
56 }
57}
###追記
プロパティ名だけでなく型も指定する場合
C#
1<#@ template debug="false" hostspecific="false" language="C#" #>
2<#@ assembly name="System.Core" #>
3<#@ import namespace="System.Linq" #>
4<#@ import namespace="System.Text" #>
5<#@ import namespace="System.Collections.Generic" #>
6<#@ output extension=".cs" #>
7
8using System;
9using System.Collections.Generic;
10using System.Linq;
11using System.Text;
12using System.Threading.Tasks;
13
14namespace ConsoleApp1
15{
16 public partial class Class1
17 {
18<#
19var properties = new[]
20{
21 new { Name = "xAccell", Type = "string" },
22 new { Name = "yAccell", Type = "string" },
23 new { Name = "zAccell", Type = "string" },
24 new { Name = "xHoge", Type = "string" },
25};
26foreach (var property in properties)
27{
28#>
29 private <#= property.Type #> _<#= property.Name #>;
30 public <#= property.Type #> <#= property.Name #>
31 {
32 get => _<#= property.Name #>;
33 set
34 {
35 if (value == _<#= property.Name #>) return;
36 _<#= property.Name #> = value;
37 OnPropertyChanged("<#= property.Name #>");
38 }
39 }
40<#
41}
42#>
43 }
44}
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。