回答編集履歴
1
追記
answer
CHANGED
@@ -111,4 +111,54 @@
|
|
111
111
|
}
|
112
112
|
}
|
113
113
|
}
|
114
|
+
```
|
115
|
+
|
116
|
+
###追記
|
117
|
+
プロパティ名だけでなく型も指定する場合
|
118
|
+
|
119
|
+
```C#
|
120
|
+
<#@ template debug="false" hostspecific="false" language="C#" #>
|
121
|
+
<#@ assembly name="System.Core" #>
|
122
|
+
<#@ import namespace="System.Linq" #>
|
123
|
+
<#@ import namespace="System.Text" #>
|
124
|
+
<#@ import namespace="System.Collections.Generic" #>
|
125
|
+
<#@ output extension=".cs" #>
|
126
|
+
|
127
|
+
using System;
|
128
|
+
using System.Collections.Generic;
|
129
|
+
using System.Linq;
|
130
|
+
using System.Text;
|
131
|
+
using System.Threading.Tasks;
|
132
|
+
|
133
|
+
namespace ConsoleApp1
|
134
|
+
{
|
135
|
+
public partial class Class1
|
136
|
+
{
|
137
|
+
<#
|
138
|
+
var properties = new[]
|
139
|
+
{
|
140
|
+
new { Name = "xAccell", Type = "string" },
|
141
|
+
new { Name = "yAccell", Type = "string" },
|
142
|
+
new { Name = "zAccell", Type = "string" },
|
143
|
+
new { Name = "xHoge", Type = "string" },
|
144
|
+
};
|
145
|
+
foreach (var property in properties)
|
146
|
+
{
|
147
|
+
#>
|
148
|
+
private <#= property.Type #> _<#= property.Name #>;
|
149
|
+
public <#= property.Type #> <#= property.Name #>
|
150
|
+
{
|
151
|
+
get => _<#= property.Name #>;
|
152
|
+
set
|
153
|
+
{
|
154
|
+
if (value == _<#= property.Name #>) return;
|
155
|
+
_<#= property.Name #> = value;
|
156
|
+
OnPropertyChanged("<#= property.Name #>");
|
157
|
+
}
|
158
|
+
}
|
159
|
+
<#
|
160
|
+
}
|
161
|
+
#>
|
162
|
+
}
|
163
|
+
}
|
114
164
|
```
|