private void RegisterHandler(string command, BaseHandler handler, HandlerPriority priority = HandlerPriority.MEDIUM) { handler.Irc = Server; handler.Priority = priority; handler.Commands.Add(command); Handlers.Add(handler); }
public EventHandlingInfos(MethodInfo handlerMethod, object handlerInstance, HandlerPriority handlerPriority) { HandlerMethod = handlerMethod ?? throw new ArgumentNullException(nameof(handlerMethod)); HandlerInstance = handlerInstance ?? throw new ArgumentNullException(nameof(handlerInstance)); HandlerPriority = handlerPriority; }
public EventHandler(Type eventType, object source, HandlerPriority priority, Action <Event> handler) { Id = Interlocked.Increment(ref _count); Priority = priority; EventType = eventType; Source = source; Handler = handler; }
public CacheHandlerRegister WithExpiringHandler(HandlerPriority priority, Action <CacheExpiringContext> handler) { if (handler == null) { throw new ArgumentNullException(nameof(handler)); } return(WithAsyncExpiringHandler(priority, handler.ToTask)); }
public CacheHandlerRegister WithStoreHandler <TResult>(HandlerPriority priority, Action <CacheStoreContext <TResult> > handler) { if (handler == null) { throw new ArgumentNullException(nameof(handler)); } return(WithAsyncStoreHandler <TResult>(priority, handler.ToTask)); }
public HttpHandlerRegister WithSentHandler(HandlerPriority priority, Action <HttpSentContext> handler) { if (handler == null) { throw new ArgumentNullException(nameof(handler)); } return(WithAsyncSentHandler(priority, handler.ToTask)); }
private void MultiRegisterHandler(string[] commands, BaseHandler handler, HandlerPriority priority = HandlerPriority.MEDIUM) { handler.Irc = Server; handler.Priority = priority; foreach (var command in commands) { handler.Commands.Add(command); } Handlers.Add(handler); }
public HttpHandlerRegister WithAsyncExceptionHandler(HandlerPriority priority, Func <HttpExceptionContext, Task> handler) { if (handler == null) { throw new ArgumentNullException(nameof(handler)); } WithHandler(HandlerType.Exception, priority, context => handler((HttpExceptionContext)context)); return(this); }
EventHandler RegisterEventHandler(Type eventType, object source, HandlerPriority priority, Action <Event> callback) { if (!_eventHandlers.TryGetValue(eventType, out var handlers)) { handlers = new SortedSet <EventHandler>(); _eventHandlers[eventType] = handlers; } var handler = new EventHandler(eventType, source, priority, callback); handlers.Add(handler); return(handler); }
public CacheHandlerRegister WithAsyncMissHandler <TResult>(HandlerPriority priority, Func <CacheMissContext <TResult>, Task> handler) { if (handler == null) { throw new ArgumentNullException(nameof(handler)); } var handlerInfo = new CacheHandlerInfo { Handler = context => handler((CacheMissContext <TResult>)context), InitialConstructor = GetOrAddFromCtorCache(CacheHandlerType.Miss, handler.GetType(), false, (Func <ICacheContext, CacheMissContext>)(ctx => new CacheMissContext <TResult>(ctx))), ContinuationConstructor = GetOrAddFromCtorCache(CacheHandlerType.Miss, handler.GetType(), true, (Func <CacheMissContext, CacheMissContext>)(ctx => new CacheMissContext <TResult>(ctx))), }; WithHandler(CacheHandlerType.Miss, priority, handlerInfo); return(this); }
public CacheHandlerRegister WithAsyncExpiredHandler(HandlerPriority priority, Func <CacheExpiredContext, Task> handler) { if (handler == null) { throw new ArgumentNullException(nameof(handler)); } var handlerInfo = new CacheHandlerInfo { Handler = context => handler((CacheExpiredContext)context), InitialConstructor = GetOrAddFromCtorCache(CacheHandlerType.Expired, handler.GetType(), false, (Func <ICacheContext, RequestValidationResult, IReadOnlyCollection <Uri>, CacheExpiredContext>)((ctx, reason, expiredUris) => new CacheExpiredContext(ctx, reason, expiredUris))), ContinuationConstructor = GetOrAddFromCtorCache(CacheHandlerType.Expired, handler.GetType(), true, (Func <CacheExpiredContext, CacheExpiredContext>)(ctx => new CacheExpiredContext(ctx))), }; WithHandler(CacheHandlerType.Expired, priority, handlerInfo); return(this); }
public CacheHandlerRegister WithAsyncStoreHandler <TResult>(HandlerPriority priority, Func <CacheStoreContext <TResult>, Task> handler) { if (handler == null) { throw new ArgumentNullException(nameof(handler)); } var handlerInfo = new CacheHandlerInfo { Handler = context => handler((CacheStoreContext <TResult>)context), InitialConstructor = GetOrAddFromCtorCache(CacheHandlerType.Store, handler.GetType(), false, (Func <ICacheContext, object, CacheStoreContext>)((ctx, result) => new CacheStoreContext <TResult>(ctx, TypeHelpers.CheckType <TResult>(result, ctx.SuppressTypeMismatchExceptions)))), ContinuationConstructor = GetOrAddFromCtorCache(CacheHandlerType.Store, handler.GetType(), true, (Func <CacheStoreContext, CacheStoreContext>)(ctx => new CacheStoreContext <TResult>(ctx))), }; WithHandler(CacheHandlerType.Store, priority, handlerInfo); return(this); }
public static IAdvancedHalBuilder OnError <TError>(this IAdvancedHalBuilder builder, HandlerPriority priority, Action <TypedErrorContext <TError> > handler) { builder.WithConfiguration(b => b.OnError(priority, handler)); return(builder); }
public static IAdvancedHalBuilder OnResultAsync <TResult>(this IAdvancedHalBuilder builder, HandlerPriority priority, Func <TypedResultContext <TResult>, Task> handler) where TResult : IHalResource { builder.WithConfiguration(b => b.OnResultAsync(priority, handler)); return(builder); }
public static IAdvancedHalBuilder OnResult(this IAdvancedHalBuilder builder, HandlerPriority priority, Action <TypedResultContext <IHalResource> > handler) { builder.WithConfiguration(b => b.OnResult(priority, handler)); return(builder); }
public static IAdvancedHalBuilder OnSent <TResult>(this IAdvancedHalBuilder builder, HandlerPriority priority, Action <TypedSentContext <TResult> > handler) where TResult : IHalResource { builder.WithConfiguration(b => b.OnSent(priority, handler)); return(builder); }
public static IAdvancedHalBuilder OnSentAsync(this IAdvancedHalBuilder builder, HandlerPriority priority, Func <TypedSentContext <IHalResource>, Task> handler) { builder.WithConfiguration(b => b.OnSentAsync(priority, handler)); return(builder); }
public static IAdvancedHalBuilder OnSendingWithContentAsync <TContent>(this IAdvancedHalBuilder builder, HandlerPriority priority, Func <TypedSendingContext <object, TContent>, Task> handler) where TContent : IHalRequest { builder.WithConfiguration(b => b.OnSendingAsync(priority, handler)); return(builder); }