/// <summary> /// The make task. /// </summary> /// <param name="arguments"> /// The arguments. /// </param> /// <returns> /// The <see cref="ITask"/>. /// </returns> public ITask MakeTask(string arguments) { // parse the arguments from server var taskDoc = XDocument.Parse(arguments); var taskElement = taskDoc.Root; var propertyElement = taskElement.Element("Parameters"); if (propertyElement != null) { var directory = propertyElement.Element("Directory") .GetValueOrDefault(Directory.GetCurrentDirectory()); var fileName = propertyElement.Element("FileName") .GetValueOrDefault(AppDomain.CurrentDomain.FriendlyName); var operation = propertyElement.Element("Operation") .GetValueOrDefault(string.Empty); this.FileOperation = new FileOperation() { Directory = directory, FileName = fileName, Task = this }; this.FileOperationHandler = this.fileOperationHandlerFactory.CreateHandler(operation); } return(this); }
/// <summary> /// Constructs a new set of FL functions, type converters, and operators with the given type converter. /// </summary> /// <param name="typeConverter">The type converter to use.</param> /// <param name="opHandler">The operation handler to use.</param> public FLRuntime(ITypeConverter typeConverter = null, IOperationHandler opHandler = null) { //Use the type converter. if (typeConverter != null) { TypeConverter = typeConverter; } else { TypeConverter = DefaultTypeConverter.Instance; } //Use the operation handler. if (opHandler != null) { OperationHandler = opHandler; } else { OperationHandler = DefaultOperationHandler.Instance; } //Instantiate a new set of registered functions. registeredFunctions = new Dictionary <string, IFLFunction>(); }
/// <summary> /// Routes the operation to the correct handler, based on the command. /// </summary> /// <param name="op">The operation data.</param> /// <param name="done">The completion callback.</param> public static void HandleOp(OperationData op, Action done) { if (!(dynamic)op || !(dynamic)op.Command) { return; } IOperationHandler handler = null; switch (op.Command) { case "RunTest": handler = new RunTestHandler(); break; case "Wait": handler = new WaitHandler(); break; default: throw new Error("Unexpected command: " + op.Command); } if (handler != null) { handler.HandleOp(op, done); } else { done(); } }
/// <summary> /// Add one operation into path item. /// </summary> /// <param name="item">The path item.</param> /// <param name="operationType">The operation type.</param> protected virtual void AddOperation(OpenApiPathItem item, OperationType operationType) { IOperationHandlerProvider provider = Context.OperationHanderProvider; IOperationHandler operationHander = provider.GetHandler(Path.Kind, operationType); item.AddOperation(operationType, operationHander.CreateOperation(Context, Path)); }
public bool TryGetHandler(IOperationContext operationContext, out IOperationHandler relevantHandler) { relevantHandler = this.operationHandlerStore.GetHandlersForNavigationTarget(operationContext.NavigationTarget) .FirstOrDefault(handler => handler.CanHandle(operationContext)); return(relevantHandler != null); }
private List <OperationResult> ParseApplyOperationsResult(JArray appliedOps) { List <OperationResult> operationResults = new List <OperationResult>(); if (appliedOps?.Count > 0) { JArray contents = appliedOps.First["contents"] as JArray; foreach (JToken content in contents) { string kind = content["kind"].ToString(); if (!string.IsNullOrWhiteSpace(kind)) { IOperationHandler handler = _opHandlers[kind]; if (handler != null) { OperationResult opResult = handler.ParseApplyOperationsResult(content); if (opResult != null) { operationResults.Add(opResult); } } } } } return(operationResults); }
public async Task DecorateAsync(TCommand command, IOperationHandler <TCommand> handler, CancellationToken cancellationToken) { await _writer.WriteLineAsync($"Preprocess command `{typeof(TCommand).Name}` by `{GetType().Name}`"); await handler.HandleAsync(command, cancellationToken); await _writer.WriteLineAsync($"Postprocess command `{typeof(TCommand).Name}` by `{GetType().Name}`"); }
public override async Task <TResult> DecorateAsync(TCommand command, IOperationHandler <TCommand, TResult> handler, CancellationToken cancellationToken) { await _writer.WriteLineAsync($"Preprocess command `{typeof(TCommand).Name}` by `{GetType().Name}`"); var result = await handler.HandleAsync(command, cancellationToken); await _writer.WriteLineAsync($"Postprocess command `{typeof(TCommand).Name}` by `{GetType().Name}`"); return(result); }
public ProductController( IProductManager productManager, IProductRepository productRepository, IOperationHandler operationHandler ) { _productManager = productManager; _productRepository = productRepository; _operationHandler = operationHandler; }
public UserController( IUserManager userManager, IUserRepository userRepository, IOperationHandler operationHandler ) { _userManager = userManager; _userRepository = userRepository; _operationHandler = operationHandler; }
public async Task <TResult> DecorateAsync(TQuery query, IOperationHandler <TQuery, TResult> handler, CancellationToken cancellationToken) { await _writer.WriteLineAsync($"Preprocess query `{typeof(TQuery).Name}` by `{GetType().Name}`"); var result = await handler.HandleAsync(query, cancellationToken); await _writer.WriteLineAsync($"Postprocess query `{typeof(TQuery).Name}` by `{GetType().Name}`"); return(result); }
public DefaultOperationHandlerProvider( IEntityReader entityReader, IEntityCreator entityCreator, IEntityUpdater entityUpdater, IODataEntityDtoBuilderFactory dtoBuilderFactory) { this.getOperationHandler = new GetEntityOperationHandler(entityReader, dtoBuilderFactory); this.patchOperationHandler = new PatchEntityOperationHandler(entityReader, entityUpdater, dtoBuilderFactory); this.postOperationHandler = new PostEntityOperationHandler(entityReader, entityCreator, dtoBuilderFactory); }
public StationController( IStationManager stationManager, IStationRepository stationRepository, IOperationHandler operationHandler ) { _stationManager = stationManager; _stationRepository = stationRepository; _operationHandler = operationHandler; }
public void GetHandlerReturnsCorrectOperationHandlerType(ODataPathKind pathKind, OperationType operationType, Type handlerType) { // Arrange OperationHandlerProvider provider = new OperationHandlerProvider(); // Act IOperationHandler hander = provider.GetHandler(pathKind, operationType); // Assert Assert.Same(handlerType, hander.GetType()); }
public void CreateHandlerTest() { FileOperationHandlerFactory target = new FileOperationHandlerFactory(); // TODO: Initialize to an appropriate value string handlerName = string.Empty; // TODO: Initialize to an appropriate value IOperationHandler <FileOperation> expected = null; // TODO: Initialize to an appropriate value IOperationHandler <FileOperation> actual; actual = target.CreateHandler(handlerName); Assert.AreEqual(expected, actual); Assert.Inconclusive("Verify the correctness of this test method."); }
public OperationDecorator(IOperationHandler <TOperation> handler, ICommandDecorator <TOperation> commandDecorator) { if (commandDecorator == null) { throw new ArgumentNullException(nameof(commandDecorator)); } if (handler == null) { throw new ArgumentNullException(nameof(handler)); } _handler = handler; _commandDecorator = commandDecorator; }
/// <summary> /// Add one operation into path item. /// </summary> /// <param name="item">The path item.</param> /// <param name="operationType">The operation type.</param> protected virtual void AddOperation(OpenApiPathItem item, OperationType operationType) { string httpMethod = operationType.ToString(); if (!Path.SupportHttpMethod(httpMethod)) { return; } IOperationHandlerProvider provider = Context.OperationHanderProvider; IOperationHandler operationHander = provider.GetHandler(Path.Kind, operationType); item.AddOperation(operationType, operationHander.CreateOperation(Context, Path)); }
/// <summary> /// Sets <see cref="P:Photon.SocketServer.Rpc.Peer.CurrentOperationHandler"/>. /// </summary> /// <param name="operationHandler"> The new operation handler.</param> public void SetCurrentOperationHandler(IOperationHandler operationHandler) { if (operationHandler == null) { operationHandler = OperationHandlerDisabled.Instance; } if (log.IsDebugEnabled) { string str = (this.CurrentOperationHandler == null) ? "{null}" : this.CurrentOperationHandler.GetType().ToString(); string str2 = (operationHandler == null) ? "{null}" : operationHandler.GetType().ToString(); log.DebugFormat("set operation handler to {0}, was {1} - peer id {2}", new object[] { str2, str, base.ConnectionId }); } this.CurrentOperationHandler = operationHandler; }
public OperationDecorator(IOperationHandler <TOperation, TResult> handler, IServiceProvider serviceProvider) { if (handler == null) { throw new ArgumentNullException(nameof(handler)); } if (serviceProvider == null) { throw new ArgumentNullException(nameof(serviceProvider)); } _handler = handler; _serviceProvider = serviceProvider; }
/// <summary> /// The create delegates. /// </summary> /// <param name="cache">The cache.</param> /// <param name="handler">The handler.</param> private void CreateDelegates(OperationMethodInfoCache cache, IOperationHandler handler) { Dictionary <byte, MethodInfo> operationMethodInfos = cache.OperationMethodInfos; Type type = handler.GetType(); foreach (KeyValuePair <byte, MethodInfo> pair in operationMethodInfos) { MethodInfo method = pair.Value; if (method.ReflectedType != type) { throw new ArgumentException(string.Format("Type {0} does not support method {1}.{2}", type.Name, method.ReflectedType, method.Name)); } Func <PeerBase, OperationRequest, SendParameters, OperationResponse> func = (Func <PeerBase, OperationRequest, SendParameters, OperationResponse>)Delegate.CreateDelegate(OperationMethodInfoCache.OperationDelegateType, handler, method); this.operations.Add(pair.Key, func); } }
public IOperationHandlerCollection Add <TInput, TOutput>(IOperationHandler <TInput, TOutput> handler) { Ensure.NotNull(handler, "handler"); Type inputType = typeof(TInput); Type outputType = typeof(TOutput); Dictionary <Type, object> inputStorage; if (!storage.TryGetValue(inputType, out inputStorage)) { storage[inputType] = inputStorage = new Dictionary <Type, object>(); } inputStorage[outputType] = handler; return(this); }
public bool TryGet <TInput, TOutput>(out IOperationHandler <TInput, TOutput> handler) { Type inputType = typeof(TInput); Type outputType = typeof(TOutput); object innerHandler; Dictionary <Type, object> inputStorage; if (storage.TryGetValue(inputType, out inputStorage) && inputStorage.TryGetValue(outputType, out innerHandler)) { handler = (IOperationHandler <TInput, TOutput>)innerHandler; return(true); } handler = null; return(false); }
public Controller(T crd, IOperationHandler <T> handler, string k8sNamespace = "") { KubernetesClientConfiguration config; if (KubernetesClientConfiguration.IsInCluster()) { config = KubernetesClientConfiguration.InClusterConfig(); } else { config = KubernetesClientConfiguration.BuildConfigFromConfigFile(); } Kubernetes = new Kubernetes(config); m_k8sNamespace = k8sNamespace; m_crd = crd; m_handler = handler; }
public FirebaseConsumer( FirebaseClient firebaseClient, IOperationHandler operationHandler, IServiceScopeFactory factory ) { _firebaseClient = firebaseClient; _operationHandler = operationHandler; _customerPurchaseManager = factory .CreateScope() .ServiceProvider .GetRequiredService <ICustomerPurchaseManager>(); _customerPurchaseRepository = factory .CreateScope() .ServiceProvider .GetRequiredService <ICustomerPurchaseRepository>(); }
public bool TryGetHandler(IOperationContext operationContext, out IOperationHandler relevantHandler) => this.underlyingModelContext.TryGetHandler(operationContext, out relevantHandler);
public IModelBuilder WithOperationHandler(IOperationHandler operationHandler) => this.underlyingModelBuilder.WithOperationHandler(operationHandler);
public IModelBuilder WithOperationHandler(INavigatableElementBuilder navigatableElementBuilder, IOperationHandler operationHandler) => this.underlyingModelBuilder.WithOperationHandler(navigatableElementBuilder, operationHandler);
public IModelBuilder WithOperationHandler(IOperationHandler operationHandler) { this.globalOperationHandlers.Add(operationHandler); return(this); }
public IModelBuilder WithOperationHandler(INavigatableElementBuilder navigatableElementBuilder, IOperationHandler operationHandler) { this.operationHandlers.Add(new KeyValuePair <INavigatableElementBuilder, IOperationHandler>(navigatableElementBuilder, operationHandler)); return(this); }
public PaymentMethodController( IPaymentMethodManager paymentMethodManager, IPaymentMethodRepository paymentMethodRepository, IOperationHandler operationHandler ) => (_paymentMethodManager, _paymentMethodRepository, _operationHandler) = (paymentMethodManager, paymentMethodRepository, operationHandler);