コード例 #1
0
 public static void TryCheckTooManyParameters(TransformRouteValidationContext context, IReadOnlyDictionary <string, string> rawTransform, int expected)
 {
     if (rawTransform.Count > expected)
     {
         context.Errors.Add(new InvalidOperationException("The transform contains more parameters than expected: " + string.Join(';', rawTransform.Keys)));
     }
 }
コード例 #2
0
        /// <inheritdoc/>
        public IReadOnlyList <Exception> ValidateRoute(RouteConfig route)
        {
            var context = new TransformRouteValidationContext()
            {
                Services = _services,
                Route    = route,
            };

            var rawTransforms = route?.Transforms;

            if (rawTransforms?.Count > 0)
            {
                foreach (var rawTransform in rawTransforms)
                {
                    var handled = false;
                    foreach (var factory in _factories)
                    {
                        if (factory.Validate(context, rawTransform))
                        {
                            handled = true;
                            break;
                        }
                    }

                    if (!handled)
                    {
                        context.Errors.Add(new ArgumentException($"Unknown transform: {string.Join(';', rawTransform.Keys)}"));
                    }
                }
            }

            // Let the app add any more validation it wants.
            foreach (var transformProvider in _providers)
            {
                transformProvider.ValidateRoute(context);
            }

            // We promise not to modify the list after we return it.
            return((IReadOnlyList <Exception>)context.Errors);
        }
コード例 #3
0
 public void ValidateRoute(TransformRouteValidationContext context)
 {
 }