/// <summary> /// 指定要素から指定属性値を取得 /// </summary> /// <typeparam name="T">型指定</typeparam> /// <param name="element">指定要素</param> /// <param name="name">属性名称</param> /// <param name="defaultValue">値取得失敗時の戻り値</param> /// <returns>値</returns> protected T GetAttribute <T>(XElement element, string name, T defaultValue) { if (element != null) { var value = ValueConvert.FromString <T>(element.Attribute(name).Value); return(value.Equals(default(T)) ? defaultValue : value); } else { return(defaultValue); } }
/// <summary> /// 指定要素から指定属性値を取得 /// </summary> /// <typeparam name="T">型指定</typeparam> /// <param name="element">指定要素</param> /// <param name="name">属性名称</param> /// <returns>値</returns> protected T GetAttribute <T>(XElement element, string name) { return((element != null && element.Attribute(name) != null) ? ValueConvert.FromString <T>(element.Attribute(name).Value) : default(T)); }
/// <summary> /// 指定要素から値取得 /// </summary> /// <typeparam name="T">型指定</typeparam> /// <param name="element">指定要素</param> /// <param name="tag">子要素タグ名</param> /// <returns>値</returns> protected T GetValue <T>(XElement element) { return(element != null?ValueConvert.FromString <T>(element.Value) : default(T)); }