예제 #1
0
        private string CreateScript(ProxyScriptingModel scriptingModel)
        {
            var apiModel = _modelProvider.CreateApiModel(new ApplicationApiDescriptionModelRequestDto {
                IncludeTypes = false
            });

            if (scriptingModel.IsPartialRequest())
            {
                apiModel = apiModel.CreateSubModel(scriptingModel.Modules, scriptingModel.Controllers, scriptingModel.Actions);
            }

            var generatorType = _options.Generators.GetOrDefault(scriptingModel.GeneratorType);

            if (generatorType == null)
            {
                throw new AbpException($"Could not find a proxy script generator with given name: {scriptingModel.GeneratorType}");
            }

            using (var scope = _serviceProvider.CreateScope())
            {
                return(scope.ServiceProvider
                       .GetRequiredService(generatorType)
                       .As <IProxyScriptGenerator>()
                       .CreateScript(apiModel));
            }
        }
예제 #2
0
        private string CreateScript(ProxyScriptingModel scriptingModel)
        {
            var apiModel = _modelProvider.CreateApiModel();

            if (scriptingModel.IsPartialRequest())
            {
                apiModel = apiModel.CreateSubModel(scriptingModel.Modules, scriptingModel.Controllers, scriptingModel.Actions);
            }

            var generatorType = _options.Generators.GetOrDefault(scriptingModel.GeneratorType);

            if (generatorType == null)
            {
                throw new AbpException($"Could not find a proxy script generator with given name: {scriptingModel.GeneratorType}");
            }

            using (var scope = _serviceProvider.CreateScope())
            {
                var script = scope.ServiceProvider.GetRequiredService(generatorType).As <IProxyScriptGenerator>().CreateScript(apiModel);
                return(scriptingModel.Minify ? _javascriptMinifier.Minify(script) : script);
            }
        }