私はファイルヘルパーを使用しており、クラスの上に置きます [DelimitedRecord("|")]
値が「|」かどうかを確認したい そうでない場合は、例外をスローしたい..
public void WriteResults<T>(IList<T> resultsToWrite, string path, string fileName) where T: class
{
var attr = (DelimitedRecordAttribute)Attribute.GetCustomAttribute(typeof(T), typeof(DelimitedRecordAttribute));
if (attr.HasValue("|")) // has value does not exist.
{
FileHelperEngine<T> engine = new FileHelperEngine<T>();
engine.HeaderText = String.Join("|", typeof(T).GetFields().Select(x => x.Name));
string fullPath = String.Format(@"{0}\{1}-{2}.csv", path, fileName, DateTime.Now.ToString("yyyy-MM-dd"));
engine.WriteFile(fullPath, resultsToWrite);
}
}
その属性がその値を持つクラスにあることを確認するには、何を使用できますか?
編集
これは、利用可能なプロパティとして私が見るものです