Exemple #1
0
 /// <summary>
 /// 条件にマッチする最初のユニットを返します。
 /// </summary>
 /// <returns>条件にマッチした要素</returns>
 /// <param name="self"></param>
 /// <param name="type">ユニット種別</param>
 public static IUnit First(this NonNullCollection <IUnit> self, UnitType type)
 {
     return(self.First(a => a.Type == type));
 }
Exemple #2
0
 /// <summary>
 /// 条件にマッチするユニットが存在するかどうかを確認します。
 /// </summary>
 /// <returns>存在する場合は<c>true</c></returns>
 /// <param name="self"></param>
 /// <param name="type">ユニット種別</param>
 public static bool Any(this NonNullCollection <IUnit> self, UnitType type)
 {
     return(self.Any(x => x.Type == type));
 }
Exemple #3
0
 /// <summary>
 /// 条件にマッチするユニットが存在するかどうかを確認します。
 /// </summary>
 /// <returns>存在する場合は<c>true</c></returns>
 /// <param name="self"></param>
 /// <param name="type">ユニット種別</param>
 public static bool Any(this NonNullCollection <IUnit> self, string type)
 {
     return(self.Any(UnitType.FromName(type)));
 }
Exemple #4
0
 /// <summary>
 /// 保有する子ユニットによるフィルタリングを行います。
 /// </summary>
 /// <returns>フィルタリングされたシーケンス</returns>
 /// <param name="self"></param>
 /// <param name="type">子ユニットのユニット種別</param>
 public static IEnumerable <IUnit> HasChildren(this IEnumerable <IUnit> self, UnitType type)
 {
     return(self.Where(u => u.SubUnits.Any(s => s.Type == type)));
 }
Exemple #5
0
        /// <summary>
        /// 保有する子ユニットによるフィルタリングを行います。
        /// </summary>
        /// <returns>フィルタリングされたシーケンス</returns>
        /// <param name="self"></param>
        /// <param name="type">子ユニットのユニット種別</param>
        public static IEnumerable <IUnit> HasChildren(this IEnumerable <IUnit> self, string type)
        {
            var expected = UnitType.FromName(type);

            return(self.Where(u => u.SubUnits.Any(s => s.Type == expected)));
        }
Exemple #6
0
 /// <summary>
 /// このユニット群の子孫ユニットを探索して返します。
 /// </summary>
 /// <returns>子孫ユニットのシーケンス</returns>
 /// <param name="self"></param>
 /// <param name="type">ユニット種別</param>
 public static IEnumerable <IUnit> TheirDescendants(this IEnumerable <IUnit> self, UnitType type)
 {
     return(self.TheirDescendants(x => x.Type == type));
 }
Exemple #7
0
 /// <summary>
 /// このユニット群の子孫ユニットを探索して返します。
 /// </summary>
 /// <returns>子孫ユニットのシーケンス</returns>
 /// <param name="self"></param>
 /// <param name="type">ユニット種別</param>
 public static IEnumerable <IUnit> TheirDescendants(this IEnumerable <IUnit> self, string type)
 {
     return(self.TheirDescendants(UnitType.FromName(type)));
 }
Exemple #8
0
 /// <summary>
 /// このユニット群の子ユニットを探索して返します。
 /// </summary>
 /// <returns>子ユニットのシーケンス</returns>
 /// <param name="self"></param>
 /// <param name="type">ユニット種別</param>
 public static IEnumerable <IUnit> TheirChildren(this IEnumerable <IUnit> self, UnitType type)
 {
     return(self.TheirChildren(x => x.Type == type));
 }
Exemple #9
0
 /// <summary>
 /// このユニット群の子ユニットを探索して返します。
 /// </summary>
 /// <returns>子ユニットのシーケンス</returns>
 /// <param name="self"></param>
 /// <param name="type">ユニット種別</param>
 public static IEnumerable <IUnit> TheirChildren(this IEnumerable <IUnit> self, string type)
 {
     return(self.TheirChildren(UnitType.FromName(type)));
 }
Exemple #10
0
 /// <summary>
 /// このユニットおよびこのユニットの子孫ユニットを探索して返します。
 /// </summary>
 /// <returns>子孫ユニットのシーケンス</returns>
 /// <param name="self"></param>
 /// <param name="type">ユニット種別</param>
 public static IEnumerable <IUnit> ItSelfAndDescendants(this IUnit self, UnitType type)
 {
     return(self.ItSelfAndDescendants(x => x.Type == type));
 }
Exemple #11
0
 /// <summary>
 /// このユニットおよびこのユニットの子孫ユニットを探索して返します。
 /// </summary>
 /// <returns>子孫ユニットのシーケンス</returns>
 /// <param name="self"></param>
 /// <param name="type">ユニット種別</param>
 public static IEnumerable <IUnit> ItSelfAndDescendants(this IUnit self, string type)
 {
     return(self.ItSelfAndDescendants(UnitType.FromName(type)));
 }
Exemple #12
0
 /// <summary>
 /// このユニットおよびこのユニットの子ユニットを探索して返します。
 /// </summary>
 /// <returns>このユニットおよび子ユニットのシーケンス</returns>
 /// <param name="self"></param>
 /// <param name="type">ユニット種別</param>
 public static IEnumerable <IUnit> ItSelfAndChildren(this IUnit self, string type)
 {
     return(self.ItSelfAndChildren(UnitType.FromName(type)));
 }
Exemple #13
0
 /// <summary>
 /// このユニットおよびこのユニットの子ユニットを探索して返します。
 /// </summary>
 /// <returns>このユニットおよび子ユニットのシーケンス</returns>
 /// <param name="self"></param>
 /// <param name="type">ユニット種別</param>
 public static IEnumerable <IUnit> ItSelfAndChildren(this IUnit self, UnitType type)
 {
     return(self.ItSelfAndChildren(u => u.Type == type));
 }
Exemple #14
0
 /// <summary>
 /// 条件にマッチする要素をすべて削除しその要素数を返します。
 /// </summary>
 /// <returns>削除した要素の数</returns>
 /// <param name="self"></param>
 /// <param name="type">ユニット種別</param>
 /// <exception cref="NotSupportedException">コレクションがイミュータブルな場合</exception>
 public static int RemoveAll(this NonNullCollection <IUnit> self, string type)
 {
     return(self.RemoveAll(UnitType.FromName(type)));
 }
Exemple #15
0
 /// <summary>
 /// 条件にマッチする要素をすべて削除しその要素数を返します。
 /// </summary>
 /// <returns>削除した要素の数</returns>
 /// <param name="self"></param>
 /// <param name="type">ユニット種別</param>
 /// <exception cref="NotSupportedException">コレクションがイミュータブルな場合</exception>
 public static int RemoveAll(this NonNullCollection <IUnit> self, UnitType type)
 {
     return(self.RemoveAll(x => x.Type == type));
 }
Exemple #16
0
 /// <summary>
 /// 条件にマッチする最初のユニットを返します。
 /// 条件にマッチする要素がない場合は<c>null</c>を返します。
 /// </summary>
 /// <returns>条件にマッチした要素</returns>
 /// <param name="self"></param>
 /// <param name="type">ユニット種別</param>
 public static IUnit FirstOrDefault(this NonNullCollection <IUnit> self, string type)
 {
     return(self.FirstOrDefault(UnitType.FromName(type)));
 }