private bool OnRequestEntangle(IRequestWrapper request) { var req = (EntangleRequest)request.Request; Guid?eid = null; if (Interfaces.TryGetValue(req.InterfaceId, out var ie)) { if (req.Eid.HasValue) { if (ie.Access == EntanglementAccess.Manual || ie.Access == EntanglementAccess.Global) { AddClient(request.Connection, req.Eid.Value); eid = req.Eid; } } else { eid = GetInstance(ie, request.Connection); if (eid.HasValue) { AddClient(request.Connection, eid.Value); } } } request.TrySendResponse(new EntangleResult { Eid = eid }, out _); return(true); }
public BaseController() { sessionWrapper = new SessionCacheWrapper(System.Web.HttpContext.Current.Session); requestWrapper = new RequestWrapper(System.Web.HttpContext.Current.Request); applicationCache = new ApplicationCache(System.Web.HttpContext.Current.Application); memoryCache = new MemoryCache(); }
public BaseController(ICacheWrapper sessionWrapper, ICacheWrapper applicationCache, ICacheWrapper memoryCache, IRequestWrapper requestWrapper) { this.sessionWrapper = sessionWrapper; this.requestWrapper = requestWrapper; this.applicationCache = applicationCache; this.memoryCache = memoryCache; }
public IResponse GetResponse(IRequestWrapper request) { Log.DebugFormat("Received request. Uri: [{0}].", request.Uri.AbsoluteUri); try { IRepositoryCommand command = routes.CreateCommand(request.Uri); IRepresentation representation = command.Execute(repository); return request.Condition.CreateResponse(representation); } catch (ServerException ex) { Log.ErrorFormat("Server exception. {0}", ex.Message); return Response.InternalServerError(); } catch (InvalidUriException ex) { Log.WarnFormat("Invalid request. {0}", ex.Message); return Response.NotFound(); } catch (NotFoundException ex) { Log.WarnFormat("Invalid request. {0}", ex.Message); return Response.NotFound(); } }
public void Execute(IRequestWrapper req) { var cmd = (ExecuteMethod)req.Request; //find the best overload Task.Factory.StartNew(ExecuteAsync, req, CancellationToken.None, TaskCreationOptions.PreferFairness, TaskScheduler.Default); }
public void Dispose() { _requestWrapper = null; IsAthorized = false; LoginResult = null; ClientId = null; GrantPermissionType = null; }
public void SendState(IRequestWrapper request) { request.TrySendResponse(_Context.All.ContainsClient(request.Connection) ? GetAllProperties(request.Connection) : new UpdateProperties() { Eid = _Eid, Updates = null }, out _); }
/*public void RegisterScoped<TBase, T>() where TBase : class, IEntangledObject where T : EntangledHostedObjectBase, TBase * { * Register<TBase, T>(EntanglementAccess.Scoped); * } * * public void RegisterGlobal<TBase, T>() where TBase : class, IEntangledObject where T : EntangledHostedObjectBase, TBase * { * Register<TBase, T>(EntanglementAccess.Global); * }*/ protected bool OnRequestExecuteMethodResult(IRequestWrapper wrapper) { var cmd = (ExecuteMethod)wrapper.Request; if (Objects.TryGetValue(cmd.Eid, out var obj)) { obj.Execute(wrapper); } return(true); }
public ControllerContext( ISessionWrapper session, IApplicationWrapper application, IRequestWrapper request, IResponseWrapper response) { Session = session; Application = application; Request = request; Response = response; }
public virtual async Task HandleRequest(HttpContext httpContext, IRequestWrapper requestWrapper, Encoding requestEncoding, RequestDelegate next) { var context = new HandlingContext(httpContext, requestEncoding, next); try { log.LogTrace($"RequestWrapper is {requestWrapper?.GetType().Name}, encoding is {requestEncoding.EncodingName}"); var responseWrapper = await HandleRequestWrapper(requestWrapper, context); await responseWrapper.Write(context, headerJsonRpcSerializer); } catch (Exception e) { // paranoid safeguard against unexpected errors log.LogWarning(e, $"{nameof(HandleRequest)} failed, write error response"); await HandleException(context, e); } }
public void SetUp() { _defaultResponce = new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent("{\"property\": \"0\"}") }; _moqHttpClientHandler = new Mock <HttpMessageHandler>(); _moqHttpClientHandler.Protected().As <IHttpClientHandlerProtectedMembers>() .Setup(handler => handler.SendAsync(It.IsAny <HttpRequestMessage>(), It.IsAny <CancellationToken>())) .ReturnsAsync(_defaultResponce); var httpclient = new HttpClient(_moqHttpClientHandler.Object); var wrappermoq = new Mock <RequestWrapper> { CallBase = true }; wrappermoq.SetupGet(wrapper => wrapper.AmSpaceHttpClient).Returns(httpclient); _requestWrapper = wrappermoq.Object; }
public FieldAnnotationConverter(IRequestWrapper requestWrapper) : base(requestWrapper) { }
public FieldConverter(IRequestWrapper requestWrapper) : base(requestWrapper) { }
public FormConfigurationService(IFormConfigurationRepository configurationRepository, IRequestWrapper requestWrapper) { this.configurationRepository = configurationRepository; this.requestWrapper = requestWrapper; }
public ValidatorConverter(IRequestWrapper requestWrapper) : base(requestWrapper) { }
public StepModelBinder(IApplicationFormContextService applicationFormContextService, IRequestWrapper requestWrapper) { this.applicationFormContextService = applicationFormContextService; this.requestWrapper = requestWrapper; }
public ConfigurationConverter(IRequestWrapper requestWrapper) : base(requestWrapper) { }
public PartsController(IRequestWrapper requestWrapper, IConfigurationRepository configurationRepository) { this.requestWrapper = requestWrapper; this.configurationRepository = configurationRepository; }
public JsonConverterBase(IRequestWrapper requestWrapper) { this.requestWrapper = requestWrapper; }
public BlockConverter(IRequestWrapper requestWrapper) : base(requestWrapper) { }
protected internal virtual async Task <Models.Response.IServerResponseWrapper> HandleRequestWrapper(IRequestWrapper requestWrapper, HandlingContext context) { try { switch (requestWrapper) { case BadRequestWrapper badRequestWrapper: return(HandleBad(badRequestWrapper, context)); case BatchRequestWrapper batchRequestWrapper: return(await HandleBatch(batchRequestWrapper, options.BatchHandling, context)); case SingleRequestWrapper singleRequestWrapper: return(await HandleSingle(singleRequestWrapper, context)); default: throw new ArgumentOutOfRangeException(nameof(requestWrapper), requestWrapper?.GetType().Name); } } catch (Exception e) { // If the batch rpc call itself fails to be recognized as an valid JSON or as an Array with at least one value, the response from the Server MUST be a single Response object // i think even if we failed parsing and don't know if this is a notification, this is right context.WriteResponse = true; log.LogWarning(e, $"{nameof(HandleRequestWrapper)} failed, set writeResponse [{context.WriteResponse}], convert exception to error response"); var response = errorFactory.ConvertExceptionToResponse(e, headerJsonRpcSerializer); return(GetResponseWrapper(response)); } }
public ApplicationFormContextService(IRequestWrapper requestWrapper, IConfigurationRepository configurationRepository, IApplicationRepository applicationRepository) { this.requestWrapper = requestWrapper; this.configurationRepository = configurationRepository; this.applicationRepository = applicationRepository; }