예제 #1
0
    public void Should_Get_Defined_Features()
    {
        _featureDefinitionManager.GetOrNull("BooleanTestFeature1").ShouldNotBeNull();
        _featureDefinitionManager.Get("BooleanTestFeature1").Name.ShouldBe("BooleanTestFeature1");

        _featureDefinitionManager.GetOrNull("IntegerTestFeature1").ShouldNotBeNull();
        _featureDefinitionManager.Get("IntegerTestFeature1").Name.ShouldBe("IntegerTestFeature1");
    }
        protected virtual RequiresLimitFeatureAttribute GetRequiresLimitFeature(MethodInfo methodInfo)
        {
            var limitFeature = methodInfo.GetCustomAttribute <RequiresLimitFeatureAttribute>(false);

            if (limitFeature != null)
            {
                // 限制次数定义的不是范围参数,则不参与限制功能
                var featureLimitDefinition = _featureDefinitionManager.GetOrNull(limitFeature.LimitFeature);
                if (featureLimitDefinition == null ||
                    !typeof(NumericValueValidator).IsAssignableFrom(featureLimitDefinition.ValueType.Validator.GetType()))
                {
                    return(null);
                }
                // 时长刻度定义的不是范围参数,则不参与限制功能
                var featureIntervalDefinition = _featureDefinitionManager.GetOrNull(limitFeature.IntervalFeature);
                if (featureIntervalDefinition == null ||
                    !typeof(NumericValueValidator).IsAssignableFrom(featureIntervalDefinition.ValueType.Validator.GetType()))
                {
                    return(null);
                }
            }
            return(limitFeature);
        }