Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.09 KB | None | 0 0
  1.  /// <summary>
  2.         /// Checks if a tubing is straight or two-directional.
  3.         /// </summary>
  4.         /// <returns>True if the connector is straight.</returns>
  5.         private bool IsConnectorStraight(IItem item)
  6.         {
  7.             var children = item.Children;
  8.  
  9.             var flanges = children.Where(i => i.GetType() == typeof(Flange));
  10.  
  11.             var elbows = children.Where(i => i.GetType() == typeof(Elbow)).Count();
  12.  
  13.             return !(AllElementsParallel(flanges) && elbows > 0);
  14.         }
  15.  
  16.         /// <summary>
  17.         /// Compares an IEnumerable of items and their orientation / direction.
  18.         /// </summary>
  19.         /// <param name="items">The items to compare.</param>
  20.         /// <returns>True if all the elements are parallel.</returns>
  21.         private bool AllElementsParallel(IEnumerable<IItem> items)
  22.         {
  23.             var distinctOrientations = items
  24.                 .ToList()
  25.                 .GroupBy(i => i.Orientation)
  26.                 .Select(g => g.First())
  27.                 .ToList();
  28.  
  29.             return distinctOrientations.Count > 1;
  30.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement