< 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_22190969454
Line coverage
91%
Covered lines: 34
Uncovered lines: 3
Coverable lines: 37
Total lines: 141
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>
 3012615        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>
 1463023        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>
 248231        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>
 1536        protected FieldValueProcessing()
 1537        {
 1538        }
 39
 239240        protected FieldValueProcessing(string name)
 239241        {
 239242            Name = name;
 239243        }
 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)
 7859        {
 7860            ArgumentOutOfRangeException.ThrowIfGreaterThan(index, CtorArguments.Count);
 7861            return (T1)CtorArguments[index];
 7862        }
 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)
 224283        {
 224284            return string.IsNullOrEmpty(fieldName)
 224285                ? null
 224286                : clazz.GetField(fieldName);
 224287        }
 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)
 366097        {
 366098            return string.IsNullOrEmpty(fieldName)
 366099                ? null
 3660100                : clazz.GetField<T1>(fieldName);
 3660101        }
 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        /// <returns><see cref="FieldDefinition{T}"/></returns>
 109        protected static FieldDefinition<T1>? ConvertFieldDefinition<T1>(IFieldDefinition fieldDefinition)
 0110        {
 0111            return fieldDefinition as FieldDefinition<T1>;
 0112        }
 113
 114        /// <summary>
 115        /// Gets a field from an instance.
 116        /// </summary>
 117        /// <param name="instance">The instance from which to get the field.</param>
 118        /// <param name="fieldName">Name of the field.</param>
 119        /// <returns><see cref="IField"/></returns>
 120        protected static IField? GetInstanceField(IInstance instance, string? fieldName)
 153121        {
 153122            return string.IsNullOrEmpty(fieldName)
 153123                ? null
 153124                : instance.GetField(fieldName);
 153125        }
 126
 127        /// <summary>
 128        /// Gets a field from an instance.
 129        /// </summary>
 130        /// <typeparam name="T1">The type of the field.</typeparam>
 131        /// <param name="instance">The instance from which to get the field.</param>
 132        /// <param name="fieldName">Name of the field.</param>
 133        /// <returns><see cref="Field{T}"/></returns>
 134        protected static Field<T1>? GetInstanceField<T1>(IInstance instance, string? fieldName)
 138135        {
 138136            return string.IsNullOrEmpty(fieldName)
 138137                ? null
 138138                : instance.GetField<T1>(fieldName);
 138139        }
 140    }
 141}