Architect's Log

I'm a Cloud Architect. I'm highly motivated to reduce toils with driving DevOps.

DataRowプロパティの糖衣構文を拡張メソッドで定義する。

DataRowプロパティの糖衣構文を拡張メソッドで定義します。

どういうこと?

毎回DataRowのプロパティをチェックすると、ソースコードが煩雑になります。糖衣構文を用意しておくと親切です。

どうすれば?

1例です。

using System;
using System.Data;

namespace Extensions {
    public static class DataSetExtensions {
        /// <summary>
        /// 重要なメールかどうかを示す値を取得します。
        /// </summary>
        /// <param name="self">MailRowのインスタンス。</param>
        /// <returns>重要なメールの場合はtrue。それ以外の場合はfalse。</returns>
        public static bool IsCaution(this HogeDataSet.MailRow self)
        {
            return 5 <= self.mail_priority;
        }
    }
}