Ejemplo n.º 1
0
        /// <summary>
        /// This rule passes if the paths contain reference to exactly one of the namespace resources
        /// </summary>
        /// <param name="paths"></param>
        /// <returns></returns>
        public override bool IsValid(Dictionary <string, Dictionary <string, Operation> > paths, RuleContext context, out object[] formatParameters)
        {
            IEnumerable <string> resourceProviders = ValidationUtilities.GetResourceProviders(paths);
            string resourceProviderNamespace       = ValidationUtilities.GetRPNamespaceFromFilePath(context.File.ToString());

            formatParameters = new[] { string.Join(", ", resourceProviders) };
            string lastResourceProvider = resourceProviders?.ToList().Count() > 0 ? resourceProviders.Last() : null;

            return(resourceProviders.ToList().Count <= 1 || lastResourceProvider == resourceProviderNamespace);
        }