< Summary

Information
Class: SolidEdgeCommunity.Extensions.DraftDocumentExtensions
Assembly: SolidEdgeCommunity
File(s): D:\a\SolidEdge.Community\SolidEdge.Community\src\SolidEdgeCommunity\Extensions\DraftDocumentExtensions.cs
Line coverage
100%
Covered lines: 46
Uncovered lines: 0
Coverable lines: 46
Total lines: 176
Line coverage: 100%
Branch coverage
100%
Covered branches: 30
Total branches: 30
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%44100%
EnumerateDrawingObjects()100%44100%
EnumerateDrawingObjects()100%66100%
EnumerateDrawingObjects()100%66100%
EnumerateDrawingViews()100%44100%
EnumerateDrawingViews()100%66100%
GetCreatedVersion(...)100%11100%
GetLastSavedVersion(...)100%11100%
GetProperties(...)100%11100%
GetSummaryInfo(...)100%11100%
GetVariables(...)100%11100%

File(s)

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

#LineLine coverage
 1using System;
 2using System.Collections.Generic;
 3
 4namespace SolidEdgeCommunity.Extensions;
 5
 6/// <summary>
 7/// SolidEdgeDraft.DraftDocument extensions.
 8/// </summary>
 9public static class DraftDocumentExtensions
 10{
 11    /// <summary>
 12    /// Returns an enumerable collection of drawing objects.
 13    /// </summary>
 14    /// <param name="document"></param>
 15    /// <returns></returns>
 16    public static IEnumerable<object> EnumerateDrawingObjects(this SolidEdgeDraft.DraftDocument document)
 17    {
 118        var sections = document.Sections;
 19
 420        for (int i = 1; i <= sections.Count; i++)
 21        {
 122            var section = sections.Item(i);
 423            foreach (var drawingObject in section.EnumerateDrawingObjects())
 24            {
 125                yield return drawingObject;
 26            }
 27        }
 128    }
 29
 30    /// <summary>
 31    /// Returns an enumerable collection of drawing objects of the specified type.
 32    /// </summary>
 33    /// <param name="document"></param>
 34    /// <returns></returns>
 35    public static IEnumerable<T> EnumerateDrawingObjects<T>(this SolidEdgeDraft.DraftDocument document) where T : class
 36    {
 137        var sections = document.Sections;
 38
 439        for (int i = 1; i <= sections.Count; i++)
 40        {
 141            var section = sections.Item(i);
 442            foreach (var drawingObject in section.EnumerateDrawingObjects<T>())
 43            {
 144                yield return drawingObject;
 45            }
 46        }
 147    }
 48
 49    /// <summary>
 50    /// Returns an enumerable collection of drawing objects in the specified section.
 51    /// </summary>
 52    /// <param name="document"></param>
 53    /// <param name="sectionType"></param>
 54    /// <returns></returns>
 55    public static IEnumerable<object> EnumerateDrawingObjects(this SolidEdgeDraft.DraftDocument document, SolidEdgeDraft
 56    {
 157        var sections = document.Sections;
 58
 459        for (int i = 1; i <= sections.Count; i++)
 60        {
 161            var section = sections.Item(i);
 62
 163            if (section.Type == sectionType)
 64            {
 465                foreach (var drawingObject in section.EnumerateDrawingObjects())
 66                {
 167                    yield return drawingObject;
 68                }
 69            }
 70        }
 171    }
 72
 73    /// <summary>
 74    /// Returns an enumerable collection of drawing objects of the specified type in the specified section.
 75    /// </summary>
 76    /// <param name="document"></param>
 77    /// <param name="sectionType"></param>
 78    /// <returns></returns>
 79    public static IEnumerable<object> EnumerateDrawingObjects<T>(this SolidEdgeDraft.DraftDocument document, SolidEdgeDr
 80    {
 181        var sections = document.Sections;
 82
 483        for (int i = 1; i <= sections.Count; i++)
 84        {
 185            var section = sections.Item(i);
 86
 187            if (section.Type == sectionType)
 88            {
 489                foreach (var drawingObject in section.EnumerateDrawingObjects<T>())
 90                {
 191                    yield return drawingObject;
 92                }
 93            }
 94        }
 195    }
 96
 97    /// <summary>
 98    /// Returns an enumerable collection of drawing views.
 99    /// </summary>
 100    /// <param name="document"></param>
 101    /// <returns></returns>
 102    public static IEnumerable<SolidEdgeDraft.DrawingView> EnumerateDrawingViews(this SolidEdgeDraft.DraftDocument docume
 103    {
 1104        var sheets = document.Sheets;
 105
 4106        for (int i = 1; i <= sheets.Count; i++)
 107        {
 1108            var sheet = sheets.Item(i);
 1109            var drawingViews = sheet.DrawingViews;
 110
 4111            for (int j = 1; j <= drawingViews.Count; j++)
 112            {
 1113                yield return drawingViews.Item(j);
 114            }
 1115        }
 1116    }
 117
 118    /// <summary>
 119    /// Returns an enumerable collection of drawing views in the specified section.
 120    /// </summary>
 121    /// <param name="document"></param>
 122    /// <param name="sectionType"></param>
 123    /// <returns></returns>
 124    public static IEnumerable<SolidEdgeDraft.DrawingView> EnumerateDrawingViews(this SolidEdgeDraft.DraftDocument docume
 125    {
 1126        var sections = document.Sections;
 127
 4128        for (int i = 1; i <= sections.Count; i++)
 129        {
 1130            var section = sections.Item(i);
 131
 1132            if (section.Type == sectionType)
 133            {
 4134                foreach (SolidEdgeDraft.DrawingView drawingView in section.EnumerateDrawingViews())
 135                {
 1136                    yield return drawingView;
 137                }
 138            }
 139        }
 1140    }
 141
 142    /// <summary>
 143    /// Returns the version of Solid Edge that was used to create the referenced document.
 144    /// </summary>
 145    /// <param name="document"></param>
 146    /// <returns></returns>
 1147    public static Version GetCreatedVersion(this SolidEdgeDraft.DraftDocument document) => new(document.CreatedVersion);
 148
 149    /// <summary>
 150    /// Returns the version of Solid Edge that was used the last time the referenced document was saved.
 151    /// </summary>
 152    /// <param name="document"></param>
 153    /// <returns></returns>
 1154    public static Version GetLastSavedVersion(this SolidEdgeDraft.DraftDocument document) => new(document.LastSavedVersi
 155
 156    /// <summary>
 157    /// Returns the properties for the referenced document.
 158    /// </summary>
 159    /// <param name="document"></param>
 160    /// <returns></returns>
 2161    public static PropertySets GetProperties(this SolidEdgeDraft.DraftDocument document) => document.Properties as Prope
 162
 163    /// <summary>
 164    /// Returns the summary information property set for the referenced document.
 165    /// </summary>
 166    /// <param name="document"></param>
 167    /// <returns></returns>
 1168    public static SummaryInfo GetSummaryInfo(this SolidEdgeDraft.DraftDocument document) => document.SummaryInfo as Summ
 169
 170    /// <summary>
 171    /// Returns a collection of variables for the referenced document.
 172    /// </summary>
 173    /// <param name="document"></param>
 174    /// <returns></returns>
 1175    public static Variables GetVariables(this SolidEdgeDraft.DraftDocument document) => document.Variables as Variables;
 176}