public void Should_Return_Did_Change_Text_Document_Descriptor() { // Given var textDocumentSyncHandler = TextDocumentSyncHandlerExtensions.With(DocumentSelector.ForPattern("**/*.cs")); var collection = new HandlerCollection(SupportedCapabilitiesFixture.AlwaysTrue) { textDocumentSyncHandler }; AutoSubstitute.Provide <IHandlerCollection>(collection); var handlerMatcher = AutoSubstitute.Resolve <TextDocumentMatcher>(); // When var result = handlerMatcher.FindHandler(new DidChangeTextDocumentParams() { TextDocument = new VersionedTextDocumentIdentifier { Uri = new Uri("file:///abc/123/d.cs"), Version = 1 } }, collection.Where(x => x.Method == DocumentNames.DidChange)); // Then result.Should().NotBeNullOrEmpty(); result.Should().Contain(x => x.Method == DocumentNames.DidChange); }
public void Should_Contain_AllDefinedMethods(Type requestHandler, string key) { var handler = new HandlerCollection(); handler.Add((IJsonRpcHandler)Substitute.For(new Type[] { requestHandler }, new object[0])); handler._handlers.Should().Contain(x => x.Method == key); }
public void Should_Return_Did_Open_Text_Document_Handler_Descriptor_With_Sepcial_Character() { // Given var textDocumentSyncHandler = TextDocumentSyncHandlerExtensions.With(DocumentSelector.ForPattern("**/*.cshtml")); var collection = new HandlerCollection(SupportedCapabilitiesFixture.AlwaysTrue) { textDocumentSyncHandler }; AutoSubstitute.Provide <IHandlerCollection>(collection); AutoSubstitute.Provide <IEnumerable <ILspHandlerDescriptor> >(collection); var handlerMatcher = AutoSubstitute.Resolve <TextDocumentMatcher>(); // When var result = handlerMatcher.FindHandler(new DidOpenTextDocumentParams() { TextDocument = new TextDocumentItem { Uri = new Uri("file://c:/users/myøasdf/d.cshtml") } }, collection.Where(x => x.Method == DocumentNames.DidOpen)); // Then result.Should().NotBeNullOrEmpty(); result.Should().Contain(x => x.Method == DocumentNames.DidOpen); }
public void Should_Have_CorrectParams(Type requestHandler, string key, Type expected) { var handler = new HandlerCollection(); handler.Add((IJsonRpcHandler)Substitute.For(new Type[] { requestHandler }, new object[0])); handler.First(x => x.Method == key).Params.Should().IsSameOrEqualTo(expected); }
public RuntimeContext(string childContextName, IContext parentContext) { m_UnityContainer = parentContext.Get <IUnityContainer>().CreateChildContainer(); m_HandlerCollection = new HandlerCollection(); m_Children = new Dictionary <string, IContext>(); parentContext.AddChildContext(childContextName, parentContext); }
public XcapServer() { this.genericHandlers = new HandlerCollection <IGenericAuidHandler>(); this.usersHandlers = new HandlerCollection <IUsersAuidHandler>(); this.xcapCapsHander = new XcapCapsHandler(); AddHandler(this.xcapCapsHander); }
public int AddListener(Type listenerType, Handler listenerObject) { int listenerId = mHandlerOffset++; HandlerCollection rCol = new HandlerCollection(listenerType, listenerObject); mHandlers.Add(listenerId, rCol); return(listenerId); }
public RuntimeContext() { m_UnityContainer = new UnityContainer(); this.ResisterInstance <IUnityContainer>(m_UnityContainer); m_HandlerCollection = new HandlerCollection(); m_Children = new Dictionary <string, IContext>(); }
public void PostMessage <TMessage>(TMessage message) where TMessage : struct { if (mTypeLookup.TryGetValue(typeof(TMessage), out int typeIndex)) { HandlerCollection <TMessage> collection = (HandlerCollection <TMessage>)mHandlers[typeIndex]; collection.Handle(message); } }
public void Should_Contain_AllDefinedMethods(Type requestHandler, string key) { var handler = new HandlerCollection(Substitute.For <IResolverContext>(), new HandlerTypeDescriptorProvider(new [] { typeof(HandlerTypeDescriptorProvider).Assembly, typeof(HandlerResolverTests).Assembly })) { (IJsonRpcHandler)Substitute.For(new[] { requestHandler }, new object[0]) }; handler.Should().Contain(x => x.Method == key); }
public void Should_Have_CorrectParams(Type requestHandler, string key, Type expected) { var handler = new HandlerCollection(Substitute.For <IResolverContext>(), new HandlerTypeDescriptorProvider(new [] { typeof(HandlerTypeDescriptorProvider).Assembly, typeof(HandlerResolverTests).Assembly })) { (IJsonRpcHandler)Substitute.For(new[] { requestHandler }, new object[0]) }; handler.First(x => x.Method == key).Params.Should().IsSameOrEqualTo(expected); }
public void Should_Have_CorrectParams(Type requestHandler, string key, Type expected) { var handler = new HandlerCollection(new ServiceCollection().BuildServiceProvider()) { (IJsonRpcHandler)Substitute.For(new[] { requestHandler }, new object[0]) }; handler.First(x => x.Method == key).Params.Should().IsSameOrEqualTo(expected); }
public void Should_Contain_AllDefinedMethods(Type requestHandler, string key) { var handler = new HandlerCollection(new ServiceCollection().BuildServiceProvider()) { (IJsonRpcHandler)Substitute.For(new[] { requestHandler }, new object[0]) }; handler.Should().Contain(x => x.Method == key); }
private void RegisterDefaultHandler() { mHandlers.Clear(); HandlerCollection rCol = new HandlerCollection(typeof(login), new login()); mHandlers.Add(0, rCol); rCol = new HandlerCollection(typeof(ping), new ping()); mHandlers.Add(1, rCol); mHandlerOffset = 2; }
public JistHook(JistEngine engine, HandlerCollection <T> collection, JsValue func) { this.HookID = new Guid(); this.enabled = true; this.collection = collection; this.pluginInstance = engine.PluginInstance; this.handler = (args) => engine.CallFunction(func, this, args); collection.Register(engine.PluginInstance, handler); }
public ClientCapabilityProviderFixture() { handler = Substitute.For <IExecuteCommandHandler>(); handler.GetRegistrationOptions().Returns(new ExecuteCommandRegistrationOptions()); var handlerCollection = new HandlerCollection { handler }; var capabilityProvider = new ClientCapabilityProvider(handlerCollection); Provider = capabilityProvider; }
public void Should_Return_Code_Lens_Descriptor() { // Given var textDocumentSyncHandler = TextDocumentSyncHandlerExtensions.With(DocumentSelector.ForPattern("**/*.cs"), "csharp"); var textDocumentIdentifiers = new TextDocumentIdentifiers(); AutoSubstitute.Provide(textDocumentIdentifiers); var collection = new HandlerCollection(SupportedCapabilitiesFixture.AlwaysTrue, textDocumentIdentifiers) { textDocumentSyncHandler }; AutoSubstitute.Provide <IHandlerCollection>(collection); AutoSubstitute.Provide <IEnumerable <ILspHandlerDescriptor> >(collection); var handlerMatcher = AutoSubstitute.Resolve <TextDocumentMatcher>(); var codeLensHandler = Substitute.For(new Type[] { typeof(ICodeLensHandler), typeof(ICodeLensResolveHandler) }, new object[0]) as ICodeLensHandler; codeLensHandler.GetRegistrationOptions() .Returns(new CodeLensRegistrationOptions() { DocumentSelector = new DocumentSelector(new DocumentFilter { Pattern = "**/*.cs" }) }); var codeLensHandler2 = Substitute.For(new Type[] { typeof(ICodeLensHandler), typeof(ICodeLensResolveHandler) }, new object[0]) as ICodeLensHandler; codeLensHandler2.GetRegistrationOptions() .Returns(new CodeLensRegistrationOptions() { DocumentSelector = new DocumentSelector(new DocumentFilter { Pattern = "**/*.cake" }) }); collection.Add(codeLensHandler, codeLensHandler2); // When var result = handlerMatcher.FindHandler(new CodeLensParams() { TextDocument = new VersionedTextDocumentIdentifier { Uri = new Uri("file:///abc/123/d.cs"), Version = 1 } }, collection.Where(x => x.Method == DocumentNames.CodeLens)); // Then result.Should().NotBeNullOrEmpty(); result.Should().Contain(x => x.Method == DocumentNames.CodeLens); result.Should().Contain(x => ((HandlerDescriptor)x).Key == "[**/*.cs]"); }
public void SessionAuthenticated(userInfo userInfo) { mUser = userInfo; HandlerCollection rCol = new HandlerCollection(typeof(flowerpower), new flowerpower()); mHandlers.Add(mHandlerOffset++, rCol); rCol = new HandlerCollection(typeof(bPad), new bPad()); mHandlers.Add(mHandlerOffset++, rCol); rCol = new HandlerCollection(typeof(areas), new areas()); mHandlers.Add(mHandlerOffset++, rCol); rCol = new HandlerCollection(typeof(catalogo), new catalogo()); mHandlers.Add(mHandlerOffset++, rCol); }
private void Initialize() { CommandExceptionHandlers = new DefaultExceptionHandlerCollection(); DispatcherExceptionHandlers = new DefaultExceptionHandlerCollection(); descriptorProvider = new HandlerDescriptorProvider( typeof(ICommandHandler <>), null, TypeHelper.MethodName <ICommandHandler <object>, object, Task>(h => h.HandleAsync), CommandExceptionHandlers, DispatcherExceptionHandlers ); handlers = new HandlerCollection(log.Factory, descriptorProvider); }
public async Task ExecutesHandler() { var exitHandler = Substitute.For <IExitHandler>(); var collection = new HandlerCollection { exitHandler }; IRequestRouter mediator = new RequestRouter(collection, new Serializer()); var notification = new Notification("exit", null); await mediator.RouteNotification(notification); await exitHandler.Received(1).Handle(); }
public DiffParser() { schema = new HandlerCollection { { @"^diff\s", Start }, { @"^new file mode \d+$", NewFile }, { @"^deleted file mode \d+$", DeletedFile }, { @"^index\s[\da-zA-Z]+\.\.[\da-zA-Z]+(\s(\d+))?$", Index }, { @"^---\s", FromFile }, { @"^\+\+\+\s", ToFile }, { @"^@@\s+\-(\d+),?(\d+)?\s+\+(\d+),?(\d+)?\s@@", Chunk }, { @"^-", DeleteLine }, { @"^\+", AddLine } }; }
internal DialogExpectation(System.Windows.Forms.Form HostingForm) { this.m_Handers = new HandlerCollection(); this.m_Callback = null; this.m_HanderToHook = IntPtr.Zero; this.m_hWndList = new List <IntPtr>(); this.m_Listening = false; this.m_ExpectAllDialog = false; this.m_ExpectAllMessageBox = false; this.m_UnexpectedCalllback = DefaultUnexpectedCallback; this.m_HostingForm = HostingForm; this.BeginListening(); }
public void AddMessageReceiver <TMessage>(Action <TMessage> action) where TMessage : struct { HandlerCollection <TMessage> handlerCollection; if (!mTypeLookup.TryGetValue(typeof(TMessage), out int typeIndex)) { typeIndex = mHandlers.Count; mTypeLookup.Add(typeof(TMessage), typeIndex); handlerCollection = new HandlerCollection <TMessage>(); mHandlers.Add(handlerCollection); } else { handlerCollection = (HandlerCollection <TMessage>)mHandlers[typeIndex]; } handlerCollection.Add(action); }
public async Task ExecutesHandler() { var exitHandler = Substitute.For <IExitHandler>(); var collection = new HandlerCollection { exitHandler }; AutoSubstitute.Provide(collection); var router = AutoSubstitute.Resolve <RequestRouter>(); var notification = new Notification("exit", null); await router.RouteNotification(router.GetDescriptor(notification), notification, CancellationToken.None); await exitHandler.Received(1).Handle(Arg.Any <EmptyRequest>(), CancellationToken.None); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public void start() throws Exception public override void Start() { if (_jetty == null) { VerifyAddressConfiguration(); JettyThreadCalculator jettyThreadCalculator = new JettyThreadCalculator(_jettyMaxThreads); _jetty = new Server(CreateQueuedThreadPool(jettyThreadCalculator)); if (_httpAddress != null) { _httpConnector = _connectorFactory.createConnector(_jetty, _httpAddress, jettyThreadCalculator); _jetty.addConnector(_httpConnector); } if (_httpsAddress != null) { if (_sslPolicy == null) { throw new Exception("HTTPS set to enabled, but no SSL policy provided"); } _httpsConnector = _sslSocketFactory.createConnector(_jetty, _sslPolicy, _httpsAddress, jettyThreadCalculator); _jetty.addConnector(_httpsConnector); } if (_jettyCreatedCallback != null) { _jettyCreatedCallback.accept(_jetty); } } _handlers = new HandlerList(); _jetty.Handler = _handlers; _handlers.addHandler(new MovedContextHandler()); LoadAllMounts(); if (_requestLog != null) { LoadRequestLogging(); } StartJetty(); }
public async Task ExecutesHandler() { var cancelRequestHandler = Substitute.For <ICancelRequestHandler>(); var collection = new HandlerCollection { cancelRequestHandler }; IRequestRouter mediator = new RequestRouter(collection); var @params = new CancelParams() { Id = Guid.NewGuid() }; var notification = new Notification("$/cancelRequest", JObject.Parse(JsonConvert.SerializeObject(@params))); await mediator.RouteNotification(notification); await cancelRequestHandler.Received(1).Handle(Arg.Any <CancelParams>()); }
public async Task ExecutesHandler() { var executeCommandHandler = Substitute.For <IExecuteCommandHandler>(); var collection = new HandlerCollection { executeCommandHandler }; IRequestRouter mediator = new RequestRouter(collection, new Serializer()); var id = Guid.NewGuid().ToString(); var @params = new ExecuteCommandParams() { Command = "123" }; var request = new Request(id, "workspace/executeCommand", JObject.Parse(JsonConvert.SerializeObject(@params))); var response = await mediator.RouteRequest(request); await executeCommandHandler.Received(1).Handle(Arg.Any <ExecuteCommandParams>(), Arg.Any <CancellationToken>()); }
internal KernelContext(IWechatContext wechatContext, KernelSetting setting, HandlerCollection handlerCollection) { if (wechatContext == null) { throw new ArgumentNullException("wechatContext"); } if (setting == null) { throw new ArgumentNullException("setting"); } if (handlerCollection == null) { throw new ArgumentNullException("handlerCollection"); } WechatContext = wechatContext; Setting = setting; MessageHandlers = new ReadOnlyCollection <IMessageHandler>(handlerCollection); RawBody = wechatContext.RawBody; }
/// <summary> /// Creates new instance. /// </summary> /// <param name="store">The publishing store for command persistent delivery.</param> /// <param name="schedulingProvider">The provider of a delay computation for delayed events.</param> public PersistentEventDispatcher(IEventPublishingStore store, ISchedulingProvider schedulingProvider) { Ensure.NotNull(store, "store"); Ensure.NotNull(schedulingProvider, "schedulingProvider"); this.store = store; this.schedulingProvider = schedulingProvider; EventExceptionHandlers = new DefaultExceptionHandlerCollection(); DispatcherExceptionHandlers = new DefaultExceptionHandlerCollection(); this.descriptorProvider = new HandlerDescriptorProvider( typeof(IEventHandler <>), typeof(IEventHandlerContext <>), TypeHelper.MethodName <IEventHandler <object>, object, Task>(h => h.HandleAsync), EventExceptionHandlers, DispatcherExceptionHandlers ); Handlers = new HandlerCollection(storage, descriptorProvider); }
public async Task ExecutesHandler() { var codeActionHandler = Substitute.For <ICodeActionHandler>(); var collection = new HandlerCollection { codeActionHandler }; IRequestRouter mediator = new RequestRouter(collection, new Serializer()); var id = Guid.NewGuid().ToString(); var @params = new CodeActionParams() { TextDocument = "TextDocument", Range = "Range", Context = "Context" }; var request = new Request(id, "textDocument/codeAction", JObject.Parse(JsonConvert.SerializeObject(@params))); var response = await mediator.RouteRequest(request); await codeActionHandler.Received(1).Handle(Arg.Any <CodeActionParams>(), Arg.Any <CancellationToken>()); }
public static IEventFeedSubscription AsASubscriber(string endpoint, string connectionStringName, Type[] eventTypes, Type[] handlerTypes) { var handlerCollection = new HandlerCollection(); handlerCollection.AddRange(handlerTypes); var deserializer = new SimpleXmlMessageSerializaion { MessageTypes = eventTypes }; var subscriberPersistance = new Subscriber.Persistance.SqlPersistance(connectionStringName); var failureChannel = new FailureChannel(subscriberPersistance) { PollingInterval = new TimeSpan(0, 1, 0) }; var processingChannel = new ProcessingChannel(deserializer, handlerCollection); var subscription = new EventFeedObserver(new Uri(endpoint), new AtomFormatter(), new FeedChainFactory(), subscriberPersistance) { PollingInterval = new TimeSpan(0, 1, 0) }; //deadletter messages when they fail processingChannel.MessageFailed += (sender, args) => failureChannel.DeadLetter(args.Message, args.Exception); //process messages in handlers when they're picked up from the feed subscription.EventReceived += processingChannel.ProcessEvent; //process failed messages again when they're reader failureChannel.MessageReadyForRetry += processingChannel.ProcessEvent; //remove failed messages once they're successfully processed processingChannel.MessageProcessed += (sender, message) => failureChannel.ClearFailure(message); failureChannel.Poll(); return subscription; }
public void SetUp() { target = new HandlerCollection(); }