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

            return(_cache[CreateCacheKey(options)] = CreateScript(options));
        }
Example #2
0
        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 AbpException($"Could not find a proxy script generator with given name: {options.GeneratorType}");
            }

            using (var generator = _iocResolver.ResolveAsDisposable <IProxyScriptGenerator>(generatorType))
            {
                return(generator.Object.CreateScript(model));
            }
        }
Example #3
0
 private static string CreateCacheKey(ApiProxyGenerationOptions options)
 {
     return(options.ToJsonString().ToMd5());
 }