< Summary

Information
Class: SolidEdgeCommunity.Extensions.EnvironmentExtensions
Assembly: SolidEdgeCommunity
File(s): D:\a\SolidEdge.Community\SolidEdge.Community\src\SolidEdgeCommunity\Extensions\EnvironmentExtensions.cs
Line coverage
98%
Covered lines: 56
Uncovered lines: 1
Coverable lines: 57
Total lines: 149
Line coverage: 98.2%
Branch coverage
96%
Covered branches: 50
Total branches: 52
Branch coverage: 96.1%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
GetCategoryId(...)100%11100%
GetCommandConstantType(...)100%4444100%
LookupByName(...)100%44100%
LookupByCategoryId(...)50%4480%

File(s)

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

#LineLine coverage
 1using System;
 2
 3namespace SolidEdgeCommunity.Extensions;
 4
 5/// <summary>
 6/// SolidEdgeFramework.Environment extension methods.
 7/// </summary>
 8public static class EnvironmentExtensions
 9{
 10    /// <summary>
 11    /// Returns a Guid representing the environment category.
 12    /// </summary>
 2513    public static Guid GetCategoryId(this Environment environment) => new(environment.CATID);
 14
 15    /// <summary>
 16    /// Returns a Type representing the corresponding command constants for a particular environment.
 17    /// </summary>
 18    /// <param name="environment"></param>
 19    /// <returns></returns>
 20    public static Type GetCommandConstantType(this Environment environment)
 21    {
 2322        var categoryId = environment.GetCategoryId();
 23
 2324        if (categoryId.Equals(SolidEdgeSDK.EnvironmentCategories.Application))
 25        {
 126            return typeof(SolidEdgeConstants.SolidEdgeCommandConstants);
 27        }
 2228        else if (categoryId.Equals(SolidEdgeSDK.EnvironmentCategories.Assembly))
 29        {
 130            return typeof(AssemblyCommandConstants);
 31        }
 2132        else if (categoryId.Equals(SolidEdgeSDK.EnvironmentCategories.DMAssembly))
 33        {
 134            return typeof(AssemblyCommandConstants);
 35        }
 2036        else if (categoryId.Equals(SolidEdgeSDK.EnvironmentCategories.CuttingPlaneLine))
 37        {
 138            return typeof(CuttingPlaneLineCommandConstants);
 39        }
 1940        else if (categoryId.Equals(SolidEdgeSDK.EnvironmentCategories.Draft))
 41        {
 142            return typeof(DetailCommandConstants);
 43        }
 1844        else if (categoryId.Equals(SolidEdgeSDK.EnvironmentCategories.DrawingViewEdit))
 45        {
 146            return typeof(DrawingViewEditCommandConstants);
 47        }
 1748        else if (categoryId.Equals(SolidEdgeSDK.EnvironmentCategories.Explode))
 49        {
 150            return typeof(ExplodeCommandConstants);
 51        }
 1652        else if (categoryId.Equals(SolidEdgeSDK.EnvironmentCategories.Layout))
 53        {
 154            return typeof(LayoutCommandConstants);
 55        }
 1556        else if (categoryId.Equals(SolidEdgeSDK.EnvironmentCategories.Sketch))
 57        {
 158            return typeof(LayoutInPartCommandConstants);
 59        }
 1460        else if (categoryId.Equals(SolidEdgeSDK.EnvironmentCategories.Motion))
 61        {
 162            return typeof(MotionCommandConstants);
 63        }
 1364        else if (categoryId.Equals(SolidEdgeSDK.EnvironmentCategories.Part))
 65        {
 166            return typeof(PartCommandConstants);
 67        }
 1268        else if (categoryId.Equals(SolidEdgeSDK.EnvironmentCategories.DMPart))
 69        {
 170            return typeof(PartCommandConstants);
 71        }
 1172        else if (categoryId.Equals(SolidEdgeSDK.EnvironmentCategories.Profile))
 73        {
 174            return typeof(ProfileCommandConstants);
 75        }
 1076        else if (categoryId.Equals(SolidEdgeSDK.EnvironmentCategories.ProfileHole))
 77        {
 178            return typeof(ProfileHoleCommandConstants);
 79        }
 980        else if (categoryId.Equals(SolidEdgeSDK.EnvironmentCategories.ProfilePattern))
 81        {
 182            return typeof(ProfilePatternCommandConstants);
 83        }
 884        else if (categoryId.Equals(SolidEdgeSDK.EnvironmentCategories.ProfileRevolved))
 85        {
 186            return typeof(ProfileRevolvedCommandConstants);
 87        }
 788        else if (categoryId.Equals(SolidEdgeSDK.EnvironmentCategories.SheetMetal))
 89        {
 190            return typeof(SheetMetalCommandConstants);
 91        }
 692        else if (categoryId.Equals(SolidEdgeSDK.EnvironmentCategories.DMSheetMetal))
 93        {
 194            return typeof(SheetMetalCommandConstants);
 95        }
 596        else if (categoryId.Equals(SolidEdgeSDK.EnvironmentCategories.Simplify))
 97        {
 198            return typeof(SimplifyCommandConstants);
 99        }
 4100        else if (categoryId.Equals(SolidEdgeSDK.EnvironmentCategories.Studio))
 101        {
 1102            return typeof(StudioCommandConstants);
 103        }
 3104        else if (categoryId.Equals(SolidEdgeSDK.EnvironmentCategories.XpresRoute))
 105        {
 1106            return typeof(TubingCommandConstants);
 107        }
 2108        else if (categoryId.Equals(SolidEdgeSDK.EnvironmentCategories.Weldment))
 109        {
 1110            return typeof(WeldmentCommandConstants);
 111        }
 112
 1113        return null;
 114    }
 115
 116    /// <summary>
 117    /// Returns a SolidEdgeFramework.Environment by name.
 118    /// </summary>
 119    public static Environment LookupByName(this Environments environments, string name)
 120    {
 6121        for (int i = 1; i <= environments.Count; i++)
 122        {
 2123            var environment = environments.Item(i);
 2124            if (environment.Name.Equals(name))
 125            {
 1126                return environment;
 127            }
 128        }
 129
 1130        return null;
 131    }
 132
 133    /// <summary>
 134    /// Returns a SolidEdgeFramework.Environment by category id..
 135    /// </summary>
 136    public static Environment LookupByCategoryId(this Environments environments, Guid categoryId)
 137    {
 2138        for (int i = 1; i <= environments.Count; i++)
 139        {
 1140            var environment = environments.Item(i);
 1141            if (environment.GetCategoryId().Equals(categoryId))
 142            {
 1143                return environment;
 144            }
 145        }
 146
 0147        return null;
 148    }
 149}