UtilJsonApiSerializer.Conventions.Impl.DefaultPropertyScanningConvention.ShouldIgnore C# (CSharp) Method

ShouldIgnore() public method

Determines if the property should be ignored during scanning.
public ShouldIgnore ( PropertyInfo pi ) : bool
pi System.Reflection.PropertyInfo
return bool
        public virtual bool ShouldIgnore(PropertyInfo pi)
        {
            return pi.GetCustomAttribute<JsonIgnoreAttribute>() != null;
        }

Usage Example

        public void Distinguishes_ignored_properties()
        {
            // Arrange
            var convention = new DefaultPropertyScanningConvention();
            var titlePi = typeof(Post).GetProperty("Title");
            var internalNumberPi = typeof(Post).GetProperty("InternalNumber");

            // Act
            var shouldIgnoreTitle = convention.ShouldIgnore(titlePi);
            var shouldIgnoreInternalNumber = convention.ShouldIgnore(internalNumberPi);

            // Assert
            shouldIgnoreTitle.ShouldBeFalse();
            shouldIgnoreInternalNumber.ShouldBeTrue();
        }