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); } var generatorType = _configuration.Generators.GetOrDefault(options.GeneratorType); if (generatorType == null) { throw new BaseException($"Could not find a proxy script generator with given name: {options.GeneratorType}"); } using (var generator = _iocResolver.ResolveAsDisposable <IProxyScriptGenerator>(generatorType)) { return(generator.Object.CreateScript(model)); } }
private static string CreateCacheKey(ApiProxyGenerationOptions options) { return(options.ToJsonString().ToMd5()); }