public string GetScript(ApiProxyGenerationOptions options)
        {
            if (options.UseCache)
            {
                return(_cache.GetOrAdd(CreateCacheKey(options), (key) => CreateScript(options)));
            }

            return(_cache[CreateCacheKey(options)] = CreateScript(options));
        }
        private string CreateScript(ApiProxyGenerationOptions options)
        {
            var model = _modelProvider.CreateModel();

            if (options.IsPartialRequest())
            {
                model = model.CreateSubModel(options.Modules, options.Controllers, options.Actions);
            }

            using (var scope = _iocResolver.CreateScope())
            {
                var generator = scope.ServiceProvider.GetRequiredService <JQueryProxyScriptGenerator>();
                return(generator.CreateScript(model));
            }
        }
        private static string CreateCacheKey(ApiProxyGenerationOptions options)
        {
            var str = JsonConvert.SerializeObject(options);

            using (var md5 = MD5.Create())
            {
                var inputBytes = Encoding.UTF8.GetBytes(str);
                var hashBytes  = md5.ComputeHash(inputBytes);

                var sb = new StringBuilder();
                foreach (var hashByte in hashBytes)
                {
                    sb.Append(hashByte.ToString("X2"));
                }

                return(sb.ToString());
            }
        }