/// <summary>
        /// Determines whether the specified ApiCop rule is valid.
        /// </summary>
        /// <param name="apiCop">The ApiCop.</param>
        /// <param name="tag">The tag.</param>
        /// <returns><c>true</c> if the specified ApiCop is valid; otherwise, <c>false</c>.</returns>
        /// <exception cref="System.NotImplementedException"></exception>
        public override bool IsValid(IApiCop apiCop, string tag)
        {
            var propertyBag = GetPropertyBagForTag(tag);
            var actualInitializationMode = propertyBag.GetPropertyValue("ActualInitializationMode", InitializationMode.Lazy);

            return(actualInitializationMode == RecommendedInitializationMode);
        }
        /// <summary>
        /// Determines whether the specified ApiCop rule is valid.
        /// </summary>
        /// <param name="apiCop">The ApiCop.</param>
        /// <param name="tag">The tag.</param>
        /// <returns><c>true</c> if the specified ApiCop is valid; otherwise, <c>false</c>.</returns>
        /// <exception cref="System.NotImplementedException"></exception>
        public override bool IsValid(IApiCop apiCop, string tag)
        {
            var propertyBag = GetPropertyBagForTag(tag);
            var actualInitializationMode = propertyBag.GetPropertyValue("ActualInitializationMode", InitializationMode.Lazy);

            return actualInitializationMode == RecommendedInitializationMode;
        }
        /// <summary>
        /// Determines whether the specified ApiCop rule is valid.
        /// </summary>
        /// <param name="apiCop">The ApiCop.</param>
        /// <param name="tag">The tag.</param>
        /// <returns><c>true</c> if the specified ApiCop is valid; otherwise, <c>false</c>.</returns>
        public override bool IsValid(IApiCop apiCop, string tag)
        {
            if (!_dependenciesPerType.TryGetValue(tag, out var maxDependencies))
            {
                maxDependencies = 0;
            }

            return(maxDependencies <= MaxDependencies);
        }
Exemple #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ApiCopResult"/> class.
        /// </summary>
        /// <param name="cop">The API cop.</param>
        /// <param name="rule">The rule.</param>
        /// <param name="tag">The tag.</param>
        /// <exception cref="ArgumentNullException">The <paramref name="cop"/> is <c>null</c>.</exception>
        /// <exception cref="ArgumentNullException">The <paramref name="rule"/> is <c>null</c>.</exception>
        /// <exception cref="ArgumentException">The <paramref name="tag"/> is <c>null</c> or whitespace.</exception>
        public ApiCopResult(IApiCop cop, IApiCopRule rule, string tag)
        {
            Argument.IsNotNull("cop", cop);
            Argument.IsNotNull("rule", rule);
            Argument.IsNotNullOrWhitespace("tag", tag);

            Cop  = cop;
            Rule = rule;
            Tag  = tag;
        }
Exemple #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ApiCopResult"/> class.
        /// </summary>
        /// <param name="cop">The API cop.</param>
        /// <param name="rule">The rule.</param>
        /// <param name="tag">The tag.</param>
        /// <exception cref="ArgumentNullException">The <paramref name="cop"/> is <c>null</c>.</exception>
        /// <exception cref="ArgumentNullException">The <paramref name="rule"/> is <c>null</c>.</exception>
        /// <exception cref="ArgumentException">The <paramref name="tag"/> is <c>null</c> or whitespace.</exception>
        public ApiCopResult(IApiCop cop, IApiCopRule rule, string tag)
        {
            Argument.IsNotNull("cop", cop);
            Argument.IsNotNull("rule", rule);
            Argument.IsNotNullOrWhitespace("tag", tag);

            Cop = cop;
            Rule = rule;
            Tag = tag;
        }
        /// <summary>
        /// Determines whether the specified ApiCop rule is valid.
        /// </summary>
        /// <param name="apiCop">The ApiCop.</param>
        /// <param name="tag">The tag.</param>
        /// <returns><c>true</c> if the specified ApiCop is valid; otherwise, <c>false</c>.</returns>
        public override bool IsValid(IApiCop apiCop, string tag)
        {
            int maxDependencies = 0;

            if (_dependenciesPerType.ContainsKey(tag))
            {
                maxDependencies = _dependenciesPerType[tag];
            }

            return(maxDependencies <= MaxDependencies);
        }
        /// <summary>
        /// Determines whether the specified ApiCop rule is valid.
        /// </summary>
        /// <param name="apiCop">The ApiCop.</param>
        /// <param name="tag">The tag.</param>
        /// <returns><c>true</c> if the specified ApiCop is valid; otherwise, <c>false</c>.</returns>
        public override bool IsValid(IApiCop apiCop, string tag)
        {
            Argument.IsNotNullOrWhitespace("tag", tag);

            lock (_lock)
            {
                var propertyBag = GetPropertyBagForTag(tag);
                if (propertyBag.GetAllProperties().Count == 0)
                {
                    return(true);
                }

                var totalCount = propertyBag.GetValue <int>("TotalCount");
                var usedCount  = propertyBag.GetValue <int>("UsedCount");

                return(usedCount == totalCount);
            }
        }
        /// <summary>
        /// Determines whether the specified ApiCop rule is valid.
        /// </summary>
        /// <param name="apiCop">The ApiCop.</param>
        /// <param name="tag">The tag.</param>
        /// <returns><c>true</c> if the specified ApiCop is valid; otherwise, <c>false</c>.</returns>
        public override bool IsValid(IApiCop apiCop, string tag)
        {
            Argument.IsNotNullOrWhitespace("tag", tag);

            lock (_lock)
            {
                var propertyBag = GetPropertyBagForTag(tag);
                if (propertyBag.GetAllProperties().Count == 0)
                {
                    return true;
                }

                var totalCount = propertyBag.GetPropertyValue<int>("TotalCount");
                var usedCount = propertyBag.GetPropertyValue<int>("UsedCount");
                //var unusedCount = propertyBag.GetPropertyValue<int>("UnusedCount");

                return usedCount == totalCount;
            }
        }
        /// <summary>
        /// Determines whether the specified ApiCop rule is valid.
        /// </summary>
        /// <param name="apiCop">The ApiCop.</param>
        /// <param name="tag">The tag.</param>
        /// <returns><c>true</c> if the specified ApiCop is valid; otherwise, <c>false</c>.</returns>
        public override bool IsValid(IApiCop apiCop, string tag)
        {
            int maxDependencies = 0;
            if (_dependenciesPerType.ContainsKey(tag))
            {
                maxDependencies = _dependenciesPerType[tag];
            }

            return maxDependencies <= MaxDependencies;
        }
Exemple #10
0
 /// <summary>
 /// Determines whether the specified ApiCop rule is valid.
 /// </summary>
 /// <param name="apiCop">The ApiCop.</param>
 /// <param name="tag">The tag.</param>
 /// <returns><c>true</c> if the specified ApiCop is valid; otherwise, <c>false</c>.</returns>
 public abstract bool IsValid(IApiCop apiCop, string tag);
Exemple #11
0
 /// <summary>
 /// Determines whether the specified ApiCop rule is valid.
 /// </summary>
 /// <param name="apiCop">The ApiCop.</param>
 /// <param name="tag">The tag.</param>
 /// <returns><c>true</c> if the specified ApiCop is valid; otherwise, <c>false</c>.</returns>
 public abstract bool IsValid(IApiCop apiCop, string tag);