/// <summary> /// Конструктор /// </summary> /// <param name="remoteDocs"></param> /// <param name="httpClient"></param> /// <param name="executionContext"></param> internal RemoteJsCaller(ConcurrentDictionary <string, RemoteJsOpenApiDocs> remoteDocs, IServerJsHttpClient httpClient, JsExecutionContext executionContext) { RemoteDocs = remoteDocs; HttpClient = httpClient; ExecutionContext = executionContext; }
/// <summary> /// Creates a new <see cref="JsCallback"/> instance. /// </summary> public JsCallback(JsExecutionContext context, JsContextScope scope, JsInterop interop, JavaScriptValue callback) { _context = context; _scope = scope; _interop = interop; _callback = callback; _callback.AddRef(); }
/// <summary> /// Конструктор /// </summary> /// <param name="components"></param> /// <param name="serviceProvider"></param> /// <param name="executionContext"></param> /// <param name="logger"></param> internal HandleJsCallWorker(JsExecutorComponents components, IServiceProvider serviceProvider, JsExecutionContext executionContext, ILogger logger) { Components = components; ServiceProvider = serviceProvider; ExecutionContext = executionContext; Logger = logger; RemoteCaller = new RemoteJsCaller(Components.RemoteApiDocs, Components.HttpClient, ExecutionContext); }
public JsWorkerDocumentation GetJsWorker(string workerName, JsExecutionContext executionContext) { if (!JsWorkers.ContainsKey(workerName)) { var mes = string.Format(ExceptionTexts.NoWorkerWithNameRegisteredFormat, workerName); executionContext.ExecutionLogs.Add(new JsExecutionLog { EventIdName = EventIds.JsExecutorComponents.GetJsWorkerNotFound, Message = mes, }); throw new InvalidOperationException(mes); } executionContext.ExecutionLogs.Add(new JsExecutionLog { EventIdName = EventIds.JsExecutorComponents.GetJsWorkerFound, Message = $"Js рабочий найден по указанному названию '{workerName}'", }); return JsWorkers[workerName]; }
/// <summary> /// Creates a new <see cref="JsInterop"/> instance. /// </summary> /// <param name="scope"></param> public JsInterop(JsExecutionContext context, JsContextScope scope, JsBinder binder) { _context = context; _scope = scope; _binder = binder; }
/// <summary> /// Обработка вызова метода /// </summary> /// <param name="methodName"></param> /// <param name="serviceProvider"></param> /// <param name="parameters"></param> /// <param name="executionContext"></param> /// <param name="logger"></param> /// <returns></returns> internal JsWorkerMethodResult HandleCall(string methodName, IServiceProvider serviceProvider, IJsWorkerMethodCallParameters parameters, JsExecutionContext executionContext, ILogger logger) { if (!Methods.ContainsKey(methodName)) { throw new InvalidOperationException(string.Format(ExceptionTexts.MethodWithNameDoesNotExistInWorkerFormat, methodName, WorkerName)); } var method = Methods[methodName]; var countOfMethodParams = method.Description.Parameters?.Count ?? 0; var paramsInBag = parameters.GetParamsLength(); if (paramsInBag < countOfMethodParams) { var mes = string.Format(ExceptionTexts.MethodWasCalledWithLessParamsFormat, methodName, WorkerName, countOfMethodParams, paramsInBag); throw new InvalidOperationException(mes); } return(method.Method.HandleCall(parameters, serviceProvider, logger)); }
public async Task<ExternalJsComponent> GetExternalComponent(string componentName, JsExecutionContext executionContext) { if (!await ExternalComponents.ContainsKeyAsync(componentName)) { var mes = $"Компонент не найден по указанному названию '{componentName}'"; executionContext.ExecutionLogs.Add(new JsExecutionLog { EventIdName = EventIds.JsExecutorComponents.GetExternalComponentNotFound, Message = mes }); throw new InvalidOperationException(mes); } executionContext.ExecutionLogs.Add(new JsExecutionLog { EventIdName = EventIds.JsExecutorComponents.GetJsWorkerFound, Message = $"Компонент найден по указанному названию '{componentName}'", }); return await ExternalComponents.GetValueAsync(componentName); }