< Summary

Information
Class: SolidEdgeCommunity.Extensions.SectionExtensions
Assembly: SolidEdgeCommunity
File(s): D:\a\SolidEdge.Community\SolidEdge.Community\src\SolidEdgeCommunity\Extensions\SectionExtensions.cs
Line coverage
100%
Covered lines: 23
Uncovered lines: 0
Coverable lines: 23
Total lines: 75
Line coverage: 100%
Branch coverage
100%
Covered branches: 16
Total branches: 16
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
EnumerateDrawingObjects()100%22100%
EnumerateDrawingObjects()100%1010100%
EnumerateDrawingViews()100%44100%

File(s)

D:\a\SolidEdge.Community\SolidEdge.Community\src\SolidEdgeCommunity\Extensions\SectionExtensions.cs

#LineLine coverage
 1using System.Collections.Generic;
 2
 3namespace SolidEdgeCommunity.Extensions;
 4
 5/// <summary>
 6/// SolidEdgeDraft.Section extensions.
 7/// </summary>
 8public static class SectionExtensions
 9{
 10    /// <summary>
 11    /// Returns an enumerable collection of drawing objects.
 12    /// </summary>
 13    /// <param name="section"></param>
 14    /// <returns></returns>
 15    public static IEnumerable<object> EnumerateDrawingObjects(this SolidEdgeDraft.Section section)
 16    {
 1417        foreach (var drawingObject in EnumerateDrawingObjects<object>(section))
 18        {
 319            yield return drawingObject;
 20        }
 421    }
 22
 23    /// <summary>
 24    /// Returns an enumerable collection of drawing objects of the specified type.
 25    /// </summary>
 26    public static IEnumerable<T> EnumerateDrawingObjects<T>(this SolidEdgeDraft.Section section) where T : class
 27    {
 728        var sheets = section.Sheets;
 29
 3430        for (int i = 1; i <= sheets.Count; i++)
 31        {
 1032            var sheet = sheets.Item(i);
 33
 34            // The following section types are hidden and should not be used.
 1035            if (sheet.SectionType == SolidEdgeDraft.SheetSectionTypeConstants.igDrawingViewSection) continue;
 936            if (sheet.SectionType == SolidEdgeDraft.SheetSectionTypeConstants.igBlockViewSection) continue;
 37
 38            // Should work but throws an exception...
 39            //foreach (var drawingObject in sheet.DrawingObjects)
 40
 841            var drawingObjects = sheet.DrawingObjects;
 42
 3043            for (int j = 1; j <= drawingObjects.Count; j++)
 44            {
 745                var drawingObject = drawingObjects.Item(j);
 46
 747                if (drawingObject is T t)
 48                {
 649                    yield return t;
 50                }
 51            }
 852        }
 753    }
 54
 55    /// <summary>
 56    /// Returns an enumerable collection of drawing views.
 57    /// </summary>
 58    /// <param name="section"></param>
 59    /// <returns></returns>
 60    public static IEnumerable<SolidEdgeDraft.DrawingView> EnumerateDrawingViews(this SolidEdgeDraft.Section section)
 61    {
 262        var sheets = section.Sheets;
 63
 864        for (int i = 1; i <= sheets.Count; i++)
 65        {
 266            var sheet = sheets.Item(i);
 267            var drawingViews = sheet.DrawingViews;
 68
 869            for (int j = 1; j <= drawingViews.Count; j++)
 70            {
 271                yield return drawingViews.Item(j);
 72            }
 273        }
 274    }
 75}