< Summary - Jellyfin

Information
Class: Emby.Server.Implementations.Data.TypeMapper
Assembly: Emby.Server.Implementations
File(s): /srv/git/jellyfin/Emby.Server.Implementations/Data/TypeMapper.cs
Line coverage
100%
Covered lines: 5
Uncovered lines: 0
Coverable lines: 5
Total lines: 33
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor()100%11100%
GetType(...)100%11100%

File(s)

/srv/git/jellyfin/Emby.Server.Implementations/Data/TypeMapper.cs

#LineLine coverage
 1using System;
 2using System.Collections.Concurrent;
 3using System.Linq;
 4
 5namespace Emby.Server.Implementations.Data
 6{
 7    /// <summary>
 8    /// Class TypeMapper.
 9    /// </summary>
 10    public class TypeMapper
 11    {
 12        /// <summary>
 13        /// This holds all the types in the running assemblies
 14        /// so that we can de-serialize properly when we don't have strong types.
 15        /// </summary>
 4616        private readonly ConcurrentDictionary<string, Type?> _typeMap = new ConcurrentDictionary<string, Type?>();
 17
 18        /// <summary>
 19        /// Gets the type.
 20        /// </summary>
 21        /// <param name="typeName">Name of the type.</param>
 22        /// <returns>Type.</returns>
 23        /// <exception cref="ArgumentNullException"><c>typeName</c> is null.</exception>
 24        public Type? GetType(string typeName)
 25        {
 8626            ArgumentException.ThrowIfNullOrEmpty(typeName);
 27
 8628            return _typeMap.GetOrAdd(typeName, k => AppDomain.CurrentDomain.GetAssemblies()
 8629                .Select(a => a.GetType(k))
 8630                .FirstOrDefault(t => t is not null));
 31        }
 32    }
 33}

Methods/Properties

.ctor()
GetType(System.String)