< Summary

Information
Class: MyNet.UI.Locators.Conventions.TypeNamingConventionBase
Assembly: MyNet.UI
File(s): https://raw.githubusercontent.com/sandre58/MyNet/85372080fe102cd9ee155ceab49ae000e7f66103/src/MyNet.UI/Locators/Conventions/TypeNamingConventionBase.cs
Tag: 323_28699572109
Line coverage
100%
Covered lines: 8
Uncovered lines: 0
Coverable lines: 8
Total lines: 48
Line coverage: 100%
Branch coverage
100%
Covered branches: 4
Total branches: 4
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
Resolve(...)100%44100%
GetType(...)100%11100%
GetFirstMatchingType(...)100%11100%

File(s)

https://raw.githubusercontent.com/sandre58/MyNet/85372080fe102cd9ee155ceab49ae000e7f66103/src/MyNet.UI/Locators/Conventions/TypeNamingConventionBase.cs

#LineLine coverage
 1// -----------------------------------------------------------------------
 2// <copyright file="TypeNamingConventionBase.cs" company="Stéphane ANDRE">
 3// Copyright (c) Stéphane ANDRE. All rights reserved.
 4// </copyright>
 5// -----------------------------------------------------------------------
 6
 7using System;
 8using System.Collections.Generic;
 9using System.Linq;
 10
 11namespace MyNet.UI.Locators.Conventions;
 12
 13/// <summary>
 14/// Base class for view model ↔ view naming conventions. Subclass and override the two resolve methods.
 15/// </summary>
 16public abstract class TypeNamingConventionBase : ITypeNamingConvention
 17{
 18    /// <inheritdoc />
 4819    public Type? Resolve(Type source) => NamingConventionHelpers.IsViewModelType(source)
 4820        ? ResolveViewFromViewModel(source)
 4821        : NamingConventionHelpers.IsViewType(source) ? ResolveViewModelFromView(source) : null;
 22
 23    /// <summary>
 24    /// Loads a type from the same assembly as <paramref name="source"/>.
 25    /// </summary>
 26    protected static Type? GetType(Type source, string fullTypeName) =>
 4227        NamingConventionHelpers.GetAssemblyType(source, fullTypeName);
 28
 29    /// <summary>
 30    /// Returns the first type that exists for the given fully qualified names.
 31    /// </summary>
 32    protected static Type? GetFirstMatchingType(Type source, IEnumerable<string> fullTypeNames) =>
 1533        fullTypeNames
 1534            .Select(fullName => GetType(source, fullName))
 1535            .OfType<Type>()
 1536            .FirstOrDefault();
 37
 38    /// <summary>
 39    /// Resolves a view type from a view model type.
 40    /// </summary>
 41    protected abstract Type? ResolveViewFromViewModel(Type source);
 42
 43    /// <summary>
 44    /// Resolves a view model type from a view type.
 45    /// </summary>
 46    protected abstract Type? ResolveViewModelFromView(Type source);
 47}
 48