< Summary - pva.SuperV

Information
Class: pva.SuperV.Engine.Processing.FieldValueProcessing<T>
Assembly: pva.SuperV.Engine
File(s): /home/runner/work/pva.SuperV/pva.SuperV/pva.SuperV.Engine/Processing/FieldValueProcessing.cs
Tag: dotnet-ubuntu_18869653307
Line coverage
91%
Covered lines: 34
Uncovered lines: 3
Coverable lines: 37
Total lines: 142
Line coverage: 91.8%
Branch coverage
75%
Covered branches: 6
Total branches: 8
Branch coverage: 75%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_Name()100%11100%
get_CtorArguments()100%11100%
get_TrigerringFieldDefinition()100%11100%
.ctor()100%11100%
.ctor(...)100%11100%
GetCtorArgument(...)100%11100%
GetFieldDefinition(...)50%22100%
GetFieldDefinition(...)100%22100%
ConvertFieldDefinition(...)100%210%
GetInstanceField(...)50%22100%
GetInstanceField(...)100%22100%

File(s)

/home/runner/work/pva.SuperV/pva.SuperV/pva.SuperV.Engine/Processing/FieldValueProcessing.cs

#LineLine coverage
 1namespace pva.SuperV.Engine.Processing
 2{
 3    /// <summary>
 4    /// Base class for value processing of a <see cref="Field{T}"/> trigerring field
 5    /// </summary>
 6    /// <typeparam name="T"></typeparam>
 7    public abstract class FieldValueProcessing<T> : IFieldValueProcessing
 8    {
 9        /// <summary>
 10        /// Gets or sets the name.
 11        /// </summary>
 12        /// <value>
 13        /// The name.
 14        /// </value>
 96015        public string Name { get; set; } = String.Empty;
 16
 17        /// <summary>
 18        /// Gets or sets the constructor arguments.
 19        /// </summary>
 20        /// <value>
 21        /// The constructor arguments.
 22        /// </value>
 475423        public List<object> CtorArguments { get; set; } = [];
 24
 25        /// <summary>
 26        /// Gets the field definition which triggers the processing.
 27        /// </summary>
 28        /// <value>
 29        /// The trigerring field definition.
 30        /// </value>
 47031        public IFieldDefinition? TrigerringFieldDefinition { get; set; }
 32
 33        /// <summary>
 34        /// Initializes a new instance of the <see cref="FieldValueProcessing{T}"/> class. Ctor used for deserialization
 35        /// </summary>
 336        protected FieldValueProcessing()
 337        {
 338        }
 39
 44740        protected FieldValueProcessing(string name)
 44741        {
 44742            Name = name;
 44743        }
 44
 45        /// <summary>
 46        /// Builds the field value processing from the <see cref="CtorArguments" /> after deserialization.
 47        /// </summary>
 48        /// <param name="clazz">The clazz.</param>
 49        public abstract void BuildAfterDeserialization(Project project, Class clazz);
 50
 51        /// <summary>
 52        /// Gets a ctor argument.
 53        /// </summary>
 54        /// <typeparam name="T1">The type of the argument.</typeparam>
 55        /// <param name="index">The index of argument.</param>
 56        /// <returns></returns>
 57        /// <exception cref="ArgumentOutOfRangeException">index</exception>
 58        public T1 GetCtorArgument<T1>(int index)
 2959        {
 2960            ArgumentOutOfRangeException.ThrowIfGreaterThan(index, CtorArguments.Count);
 2961            return (T1)CtorArguments[index];
 2962        }
 63
 64        /// <summary>
 65        /// Processes the value change.
 66        /// </summary>
 67        /// <param name="instance">Instance on which the triggering field changed.</param>
 68        /// <param name="changedField">The <see cref="Field{T}"/> which changed.</param>
 69        /// <param name="valueChanged">If <c>true</c>, indicates that the trigerring field value changed.</param>
 70        /// <param name="previousValue">The previous value of field.</param>
 71        /// <param name="currentValue">The current value of field.</param>
 72        public abstract void ProcessValue(IInstance instance, Field<T> changedField, bool valueChanged, T previousValue,
 73
 74        public abstract bool IsFieldUsed(string fieldName);
 75
 76        /// <summary>
 77        /// Gets a field definition from a class.
 78        /// </summary>
 79        /// <param name="clazz">The class from which to get field definition.</param>
 80        /// <param name="fieldName">Name of the field.</param>
 81        /// <returns><see cref="IFieldDefinition"/></returns>
 82        protected static IFieldDefinition? GetFieldDefinition(Class clazz, string? fieldName)
 190883        {
 190884            return string.IsNullOrEmpty(fieldName)
 190885                ? null
 190886                : clazz.GetField(fieldName);
 190887        }
 88
 89        /// <summary>
 90        /// Gets a field definition from a class.
 91        /// </summary>
 92        /// <typeparam name="T1">The type of the field definition.</typeparam>
 93        /// <param name="clazz">The class from which to get field definition.</param>
 94        /// <param name="fieldName">Name of the field.</param>
 95        /// <returns><see cref="FieldDefinition{T}"/></returns>
 96        protected static FieldDefinition<T1>? GetFieldDefinition<T1>(Class clazz, string? fieldName)
 151497        {
 151498            return string.IsNullOrEmpty(fieldName)
 151499                ? null
 1514100                : clazz.GetField<T1>(fieldName);
 1514101        }
 102
 103        /// <summary>
 104        /// Converts a field definition to a specific type.
 105        /// </summary>
 106        /// <typeparam name="T1">The type of the field definition.</typeparam>
 107        /// <param name="fieldDefinition">The field definition to convert.</param>
 108        /// <param name="fieldName">Name of the field.</param>
 109        /// <returns><see cref="FieldDefinition{T}"/></returns>
 110        protected static FieldDefinition<T1>? ConvertFieldDefinition<T1>(IFieldDefinition fieldDefinition)
 0111        {
 0112            return fieldDefinition as FieldDefinition<T1>;
 0113        }
 114
 115        /// <summary>
 116        /// Gets a field from an instance.
 117        /// </summary>
 118        /// <param name="instance">The instance from which to get the field.</param>
 119        /// <param name="fieldName">Name of the field.</param>
 120        /// <returns><see cref="IField"/></returns>
 121        protected static IField? GetInstanceField(IInstance instance, string? fieldName)
 118122        {
 118123            return string.IsNullOrEmpty(fieldName)
 118124                ? null
 118125                : instance.GetField(fieldName);
 118126        }
 127
 128        /// <summary>
 129        /// Gets a field from an instance.
 130        /// </summary>
 131        /// <typeparam name="T1">The type of the field.</typeparam>
 132        /// <param name="instance">The instance from which to get the field.</param>
 133        /// <param name="fieldName">Name of the field.</param>
 134        /// <returns><see cref="Field{T}"/></returns>
 135        protected static Field<T1>? GetInstanceField<T1>(IInstance instance, string? fieldName)
 120136        {
 120137            return string.IsNullOrEmpty(fieldName)
 120138                ? null
 120139                : instance.GetField<T1>(fieldName);
 120140        }
 141    }
 142}