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

            return(_cache[CreateCacheKey(options)] = CreateScript(options));
        }
Exemple #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 SharePlatformException($"找不到具有给定名称的代理脚本生成器: {options.GeneratorType}");
            }

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