public DynamicIconOptions Build()
        {
            DynamicIconOptions options = new DynamicIconOptions()
            {
                Route             = useRoute ?? DynamicIconMiddleware.DEFAULT_ROUTE,
                MaximumSize       = maximumSize ?? DynamicIconMiddleware.MAXIMUM_SIZE,
                MinimumSize       = minimumSize ?? DynamicIconMiddleware.MINIMUM_SIZE,
                Format            = iconFormat ?? DynamicIconMiddleware.DEFAULT_FORMAT,
                DefaultBackground = defaultBackground ?? DynamicIconMiddleware.DEFAULT_BACKGROUND,
                DefaultForeground = defaultForeground ?? DynamicIconMiddleware.DEFAULT_FOREGROUND,
                DefaultSize       = defaultSize ?? DynamicIconMiddleware.DEFAULT_SIZE,
                FontName          = fontName ?? DynamicIconMiddleware.DEFAULT_FONT,
                CacheFor          = cacheFor ?? new TimeSpan(DynamicIconMiddleware.DEFAULT_CACHE)
            };

            if (options.MinimumSize > options.MinimumSize)
            {
                throw new InvalidOperationException("Minimum size is greater than Maximum size.");
            }

            if (options.DefaultSize < options.MinimumSize)
            {
                throw new InvalidOperationException("Default size is less than Minimum size.");
            }

            if (options.DefaultSize > options.MaximumSize)
            {
                throw new InvalidOperationException("Default size is greater than Maximum size.");
            }

            return(options);
        }
        public static IApplicationBuilder UseDynamicIcon(this IApplicationBuilder app, Func <DynamicIconOptionsBuilder, DynamicIconOptionsBuilder> buildOptions)
        {
            DynamicIconOptionsBuilder builder = new DynamicIconOptionsBuilder();
            DynamicIconOptions        options = buildOptions(builder).Build();

            return(app.UseMiddleware <DynamicIconMiddleware>(options));
        }
 public DynamicIconMiddleware(RequestDelegate next, DynamicIconOptions options)
 {
     _next    = next;
     _options = options;
 }
 public static IApplicationBuilder UseDynamicIcon(this IApplicationBuilder app, DynamicIconOptions options)
 {
     return(app.UseMiddleware <DynamicIconMiddleware>(options));
 }