public HandlerDescription(Type inputType, Type outputType, object handler, HandlerType type) { InputType = inputType; OutputType = outputType; Handler = handler; Type = type; }
public IList<ComplexHandler> GetHandlers(HandlerType type) { if (_handlers.ContainsKey(type)) { return _handlers[type].ToList(); } return new List<ComplexHandler>(); }
public TcpByteAgentHandler(ITransport<byte[]> packethand, HandlerType handType = HandlerType.Balanced) { m_PacketHandler = packethand; blockingOutboundQueue = new Queue<byte[]>(); lockingOutbound = new object(); lockingInbound = new object(); m_buffers = new Queue<byte[]>(); m_items = new Queue<ArraySegment<byte>>(); chunkList = new List<byte>(MAX_SENDBUFFER); int sendTimerInterval = 250; int recvTimerInterval = 250; CommandList = CallContext.LogicalGetData("CommandProviders") as Dictionary<int, Interfaces.ICommand<byte>>; cmdListLock = new object(); StringList = new Dictionary<long, string>(); FunctionList = new Dictionary<long, string>(); ThreadDepth = new Dictionary<long, long>(); // Thread Id, sequence, threadid ThreadEntryPoint = new Dictionary<long, List<Tuple<long, long>>>(); switch (handType) { case HandlerType.SendHeavy: sendTimerInterval /= 2; recvTimerInterval *= 2; break; case HandlerType.ReceiveHeavy: recvTimerInterval /= 2; sendTimerInterval *= 2; break; default: break; } sendTimer = new System.Threading.Timer(new System.Threading.TimerCallback(async (object o) => { if (!inSend) { inSend = true; await SendData(); inSend = false; } }), null, sendTimerInterval, sendTimerInterval); recvTimer = new System.Threading.Timer(new System.Threading.TimerCallback(async (object o) => { if (!inRecv) { inRecv = true; await RecvData(); ExtractData(); inRecv = false; } }), null, recvTimerInterval, recvTimerInterval); }
public EventHandlerWrapper(Type eventType) { HandlerType = typeof(IEventHandler <>).MakeGenericType(eventType); _handleMethod = HandlerType.GetMethod(nameof(IEventHandler <IEvent> .Handle)); }
void registerHandler( EventDelegate startDlg, HandlerType hType, Renderer r, Camera c, Vector2 topLeft, Vector2 widthHeight, GameState gs ) { if (hType == HandlerType.FullScreen) eventHandlers.Add(new EventHandler() { eventDelegate = startDlg, handlerType = hType, fingerTouching = -1, gameState = gs }); else if (hType == HandlerType.RendererBased) eventHandlers.Add(new EventHandler() { eventDelegate = startDlg, handlerType = hType, renderer = r, camera = c, fingerTouching = -1, gameState = gs }); else if (hType == HandlerType.RectBased) { eventHandlers.Add(new EventHandler() { eventDelegate = startDlg, handlerType = hType, touchArea = new Rect(topLeft.x, topLeft.y, widthHeight.x, widthHeight.y), fingerTouching = -1, gameState = gs}); } setActiveHandlers(); }
/// <summary> /// stsd /// </summary> /// <param name="handlerType"></param> /// <param name="version"></param> /// <param name="flags"></param> public SampleDescriptionBox(HandlerType handlerType, byte version = 0, uint flags = 0) : base("stsd", version, flags) { HandlerType = handlerType; }
public void ForAttributes <T>(Action <T> action) where T : Attribute { HandlerType.ForAttribute(action); Method.ForAttribute(action); }
public BaseHandler(HandlerType type, ServerMain agent) { this.HType = type; this.agent = agent; init(); }
public GuardActionInfo(string methodName, HandlerType handlerType, object target) { _methodName = methodName; _handlerType = handlerType; _handler = CreateDelegateFromInstance <StateChangeGuardHandler <TState> >(target, _methodName); }
public static Cursor getCursor( HandlerType handleType) { switch ( handleType ) { case HandlerType.Top: case HandlerType.Bottom: return Cursors.SizeNS; case HandlerType.Left: case HandlerType.Right: return Cursors.SizeWE; case HandlerType.TopLeft: case HandlerType.BottomRight: return Cursors.SizeNWSE; case HandlerType.TopRight: case HandlerType.BottomLeft: return Cursors.SizeNESW; default: return Cursors.Default; } }
private async Task <HandlerType> HandleException(Request request, Response response, HandlerType status, Exception e) { var path = request.AspNetRequest.Path.ToString(); var method = request.AspNetRequest.Method; OnHandlerException?.Invoke(this, new HandlerExceptionEventArgs(method, path, e)); if (status != HandlerType.Continue) { return(HandlerType.Error); } if (RespondWithExceptionDetails) { await response.SendString(e.ToString(), status : HttpStatusCode.InternalServerError); } else { await response.SendStatus(HttpStatusCode.InternalServerError); } return(HandlerType.Error); }
public ALocationHandler getHandler(HandlerType type) { return(handlers[type]); }
public HandlerBuilder Required(HandlerType type) { _patternParts.Add(new HandlerTypePattern(type, false)); return(this); }
public HandlerClassAttribute(HandlerType handlerType) { HandlerType = handlerType; }
public void GivenSingleValidatorDefined() { _handlerType = HandlerType.SampleHandler; SetPermissionForHandler(); }
public void GivenValidatorIsNotDefined() { _handlerType = HandlerType.NoValidationHandler; SetPermissionForHandler(); }
public override int GetHashCode() { return(HandlerType.GetHashCode() ^ MessageHandlerType.GetHashCode()); }
public HandlerRegistry Add(HandlerType type, IEnumerable<ComplexHandler> handlers) { _handlers.Add(type, handlers.ToList()); return this; }
public void resetHandler(HandlerType type) { Type originalType = handlers[type].GetType(); handlers.Remove(type); handlers.Add(type, (ALocationHandler)Activator.CreateInstance(originalType)); }
public HandlerId(HandlerType handlerType, object subType = null) { this.HandlerType = handlerType; this.SubType = subType; }
private static void ThrowForUnboundParameter(HttpOperationHandler handler, HttpParameter parameter, HandlerType handlerType, string operationName) { Fx.Assert(handler != null, "The 'handler' parameter should not be null."); Fx.Assert(parameter != null, "The 'parameter' parameter should not be null."); Fx.Assert(operationName != null, "The 'operationName' parameter should not be null."); if (handler == responseMessageSinkHandler) { throw Fx.Exception.AsError( new InvalidOperationException( SR.ResponseSinkHandlerWithNoHttpResponseMessageSource( HttpOperationHandler.HttpOperationHandlerType.Name, HttpTypeHelper.HttpResponseMessageType.Name, operationName))); } switch (handlerType) { case HandlerType.Request: ThrowForUnboundRequestHandler(handler, parameter, operationName); break; case HandlerType.ServiceOperation: ThrowForUnboundServiceOperation(parameter, operationName); break; case HandlerType.Response: ThrowForUnboundResponseHandler(handler, parameter, operationName); break; default: Fx.Assert("The handlerType should have been one of the above cases."); break; } }
public override int GetHashCode() { return(HandlerType.GetHashCode() ^ SubType.GetHashCode()); }
public HandlerBuilder Optional(HandlerType type) { _patternParts.Add(new HandlerTypePattern(type, true)); return(this); }
public HandlerTypePattern(HandlerType type, bool optional) : base(optional) { Type = type; }
public bool HasAttribute <T>() where T : Attribute { return(HandlerType.HasAttribute <T>() || Method.HasAttribute <T>() || (HasInput && InputType().HasAttribute <T>())); }
public HandlerTypePattern(HandlerType type) : this(type, false) { }
public void Resize(HandlerType handleType, int deltaX, int deltaY) { ResizeTool.ResizeRect(ref _clientRect, handleType, deltaX, deltaY, 0); ParentLayout.RefreshControlPosition(this); }
public HandlerRegistry Add(HandlerType type, IEnumerable <ComplexHandler> handlers) { _handlers.Add(type, handlers.ToList()); return(this); }
public bool HasAttribute <T>() where T : Attribute { return(HandlerType.HasAttribute <T>() || Method.HasAttribute <T>()); }
public InfoEventData(EventTypes eventType, HandlerType handlerType) { this.eventType = eventType; this.handlerType = handlerType; }
public RegistryFunc(HandlerType _type) { type = _type; }
private static List <HttpParameterBinding> BindHandlers(List <HttpOperationHandler> handlers, string operationName, int serviceOperationIndex) { Fx.Assert(handlers != null, "The 'handlers' parameter should not be null."); Fx.Assert(operationName != null, "The 'operationName' parameter should not be null."); List <HttpParameterBinding> pipelineBindings = new List <HttpParameterBinding>(); for (int inHandlerIndex = handlers.Count - 1; inHandlerIndex >= 1; inHandlerIndex--) { HttpOperationHandler inHandler = handlers[inHandlerIndex]; HandlerType inHandlerType = GetHandlerType(inHandlerIndex, serviceOperationIndex); for (int inParamIndex = 0; inParamIndex < inHandler.InputParameters.Count; inParamIndex++) { HttpParameter inParam = inHandler.InputParameters[inParamIndex]; List <HttpParameterBinding> bindings = new List <HttpParameterBinding>(); List <HttpParameterBinding> tentativeBindings = new List <HttpParameterBinding>(); for (int outHandlerIndex = inHandlerIndex - 1; outHandlerIndex >= 0; outHandlerIndex--) { HttpOperationHandler outHandler = handlers[outHandlerIndex]; HandlerType outHandlerType = GetHandlerType(outHandlerIndex, serviceOperationIndex); for (int outParamIndex = 0; outParamIndex < outHandler.OutputParameters.Count; outParamIndex++) { HttpParameter outParam = outHandler.OutputParameters[outParamIndex]; if (inParam.IsAssignableFromParameter(outParam.Type)) { HttpParameterBinding binding = new HttpParameterBinding(); binding.InputHandler = inHandler; binding.InputHandlerIndex = inHandlerIndex; binding.InputParameter = inParam; binding.InputParameterIndex = inParamIndex; binding.InputHandlerType = inHandlerType; binding.OutputHandler = outHandler; binding.OutputHandlerIndex = outHandlerIndex; binding.OutputParameter = outParam; binding.OutputParameterIndex = outParamIndex; binding.OutputHandlerType = outHandlerType; // If their names match or the input is either HttpRequesMessage, // HttpResponseMessage, or HttpContent, then go ahead and bind if (string.Equals(outParam.Name, inParam.Name, StringComparison.OrdinalIgnoreCase) || HttpTypeHelper.IsHttp(inParam.Type)) { bindings.Add(binding); } else { // Otherwise we will tentatively bind if this is // not a string conversion assignment if (outParam.Type != TypeHelper.StringType || !inParam.ValueConverter.CanConvertFromString) { tentativeBindings.Add(binding); } } } } } if (bindings.Count > 0) { pipelineBindings.AddRange(bindings); } else if (tentativeBindings.Count == 1) { pipelineBindings.AddRange(tentativeBindings); } else if (tentativeBindings.Count > 1) { ThrowForMulitpleTypeOnlyBindings(tentativeBindings, operationName); } else { ThrowForUnboundParameter(inHandler, inParam, inHandlerType, operationName); } } } return(pipelineBindings); }
public virtual HandlerPriority GetPriority(HandlerType type) { return(HandlerPriority.Default); }
private static void ThrowForMulitpleTypeOnlyBindings(List <HttpParameterBinding> tentativeBindings, string operationName) { Fx.Assert(tentativeBindings != null, "The 'tentativeBindings' parameter should not be null."); Fx.Assert(tentativeBindings.Count > 0, "The 'tentativeBindings' list should not be empty."); Fx.Assert(operationName != null, "The 'operationName' parameter should not be null."); string exceptionMessage = null; HandlerType inHandlerType = tentativeBindings[0].InputHandlerType; HttpOperationHandler inHandler = tentativeBindings[0].InputHandler; HttpParameter inParameter = tentativeBindings[0].InputParameter; switch (inHandlerType) { case HandlerType.Request: exceptionMessage = SR.RequestHandlerWithMultipleTypeOnlyBindings( HttpOperationHandler.HttpOperationHandlerType.Name, inHandler.ToString(), operationName, inParameter.Name, inParameter.Type.Name); break; case HandlerType.ServiceOperation: exceptionMessage = SR.ServiceOperationWithMultipleTypeOnlyBindings( operationName, inParameter.Name, inParameter.Type.Name, HttpOperationHandler.HttpOperationHandlerType.Name); break; case HandlerType.Response: exceptionMessage = SR.ResponseHandlerWithMultipleTypeOnlyBindings( HttpOperationHandler.HttpOperationHandlerType.Name, inHandler.ToString(), operationName, inParameter.Name, inParameter.Type.Name); break; default: Fx.Assert("The handlerType should have been one of the above cases."); break; } StringBuilder stringBuilder = new StringBuilder(exceptionMessage); foreach (HttpParameterBinding binding in tentativeBindings) { string parameterMessage = null; HandlerType outHandlerType = binding.OutputHandlerType; HttpOperationHandler outHandler = binding.OutputHandler; HttpParameter outParameter = binding.OutputParameter; switch (outHandlerType) { case HandlerType.Request: parameterMessage = SR.RequestHandlerTypeOnlyOutputParameter( HttpOperationHandler.HttpOperationHandlerType.Name, outHandler.ToString(), outParameter.Name, outParameter.Type.Name); break; case HandlerType.ServiceOperation: parameterMessage = SR.ServiceOperationTypeOnlyOutputParameter( outParameter.Name, outParameter.Type.Name); break; case HandlerType.Response: parameterMessage = SR.ResponseHandlerTypeOnlyOutputParameter( HttpOperationHandler.HttpOperationHandlerType.Name, outHandler.ToString(), outParameter.Name, outParameter.Type.Name); break; default: Fx.Assert("The handlerType should have been one of the above cases."); break; } stringBuilder.Append(Environment.NewLine); stringBuilder.Append(parameterMessage); } throw Fx.Exception.AsError(new InvalidOperationException(stringBuilder.ToString())); }
public ALocationHandler getHandler(HandlerType type) { return handlers[type]; }
public static void ResizeRect(ref Rectangle rect, HandlerType handleType, int deltaX, int deltaY, int gs) { Point position = rect.Location; Size size = rect.Size; switch (handleType) { case HandlerType.Top: case HandlerType.TopLeft: case HandlerType.TopRight: int origPos = position.Y; position.Y += deltaY; if (gs > 1) position.Y = (position.Y / gs) * gs; if (position.Y > origPos + size.Height - 1) { position.Y = origPos + size.Height - 1; } size.Height -= position.Y - origPos; break; case HandlerType.Bottom: case HandlerType.BottomLeft: case HandlerType.BottomRight: size.Height += deltaY; if ( gs >1 ) size.Height -= ( position.Y + size.Height ) % gs; break; default: break; } switch (handleType) { case HandlerType.Left: case HandlerType.TopLeft: case HandlerType.BottomLeft: int origPos = position.X; position.X += deltaX; if (position.X > origPos + size.Width - 1) { position.X = origPos + size.Width - 1; } if (gs > 1) position.X = (position.X / gs) * gs; size.Width -= position.X - origPos; break; case HandlerType.Right: case HandlerType.TopRight: case HandlerType.BottomRight: size.Width += deltaX; if (gs > 1) size.Width -= (position.X + size.Width) % gs; break; default: break; } if (size.Width <= 1) size.Width = 1; if (size.Height <= 1) size.Height = 1; rect.Location = position; rect.Size = size; }
public static IPaymentHandler GetHandler(HandlerType type) { Func<IBindingMetadata, bool> func = (metadata) => { return metadata.Has(Constants.HandlerTypeString) && metadata.Get<HandlerType>(Constants.HandlerTypeString) == type; }; return (IPaymentHandler)_Kernel.Get(typeof(IPaymentHandler), func); }
/// <summary> /// Create and returns an instanced Handler of the specified type /// </summary> /// <param name="Handle"></param> /// <returns></returns> public Handler CreateHandler(HandlerType Handle) { switch (Handle) { case HandlerType.Immobile: this.HandlerMenu.AddItem( new MenuItem("Immobile", "[Auto] Enable use on Immobilized champions").SetValue<bool>(false)); return new Handler( this.Instance, (Spell spell) => { foreach (var unit in ObjectManager.Get<Obj_AI_Hero>().Where(unit => unit.IsValidTarget(this.Range))) { spell.CastIfHitchanceEquals(unit, HitChance.Immobile); break; } }, (Spell spell) => this.Instance.IsReady() && this.HandlerMenu.Item("Immobile").GetValue<bool>()); case HandlerType.Dash: this.HandlerMenu.AddItem( new MenuItem("Dashing", "[Auto] Enable use on Dashing champions").SetValue<bool>(false)); return new Handler( this.Instance, (Spell spell) => { foreach (var unit in ObjectManager.Get<Obj_AI_Hero>().Where(unit => unit.IsValidTarget(this.Range))) { spell.CastIfHitchanceEquals(unit, HitChance.Dashing); break; } }, (Spell spell) => this.Instance.IsReady() && this.HandlerMenu.Item("Dashing").GetValue<bool>()); case HandlerType.Killable: this.HandlerMenu.AddItem(new MenuItem("Killsteal", "[Auto] Enable use on kill-able champions (KS)")) .SetValue<bool>(false); return new Handler( this.Instance, (Spell spell) => { foreach (var unit in ObjectManager.Get<Obj_AI_Hero>() .Where( unit => unit.IsValidTarget(this.Range) && HealthPrediction.GetHealthPrediction( unit, (int)(this.Speed / unit.Distance(ObjectManager.Player, false)), (int)this.Delay) <= this.GetDamage(unit))) { var prediction = spell.GetPrediction(unit); if (prediction != null && prediction.Hitchance >= HitChance.Medium) { spell.Cast(prediction.CastPosition); } } }, (Spell spell) => this.Instance.IsReady() && this.HandlerMenu.Item("Killsteal").GetValue<bool>()); case HandlerType.OnMinimumHit: this.HandlerMenu.AddItem(new MenuItem("MinimumHit", "[Auto] Enable casting on minimum hit")) .SetValue<bool>(false); this.HandlerMenu.AddItem(new MenuItem("MinimumHitAmount", "-> Amount needed for Minimum Hit")) .SetValue<Slider>(new Slider(1, 0, 5)); return new Handler( this.Instance, (Spell spell) => { foreach (var unit in ObjectManager.Get<Obj_AI_Hero>().Where(unit => unit.IsValidTarget(this.Range))) { spell.CastIfWillHit( unit, this.HandlerMenu.Item("MinimumHitAmount").GetValue<Slider>().Value - 1); break; } }, (Spell spell) => this.Instance.IsReady() && this.HandlerMenu.Item("MinimumHit").GetValue<bool>()); case HandlerType.Farm: this.HandlerMenu.AddItem(new MenuItem("Farm", "[Auto] Enable AFK farming")).SetValue<bool>(false); return new Handler( this.Instance, (Spell spell) => { foreach (var unit in ObjectManager.Get<Obj_AI_Minion>() .Where( unit => unit.IsValidTarget(this.Range) && HealthPrediction.GetHealthPrediction( unit, (int)(this.Speed / unit.Distance(ObjectManager.Player, false)), (int)this.Delay) <= this.GetDamage(unit))) { if (this.CastingType == CastType.Linear || this.CastingType == CastType.Cone || this.CastingType == CastType.Circle) { this.LaneClear(); } else { this.Cast(unit); } break; } }, (Spell spell) => this.Instance.IsReady() && this.HandlerMenu.Item("Farm").GetValue<bool>()); case HandlerType.OnSelfHealthBelow: this.HandlerMenu.AddItem(new MenuItem("SelfHeal", "[Auto] Enable (self) Heal")) .SetValue<bool>(false); this.HandlerMenu.AddItem(new MenuItem("HealPercent", "-> Health Percent")) .SetValue<Slider>(new Slider(40, 0, 100)); this.HandlerMenu.AddItem(new MenuItem("ManaPercent", "-> Min Mana Percent")) .SetValue<Slider>(new Slider(30, 0, 100)); return new Handler( this.Instance, (Spell spell) => { var HealthPercent = this.HandlerMenu.Item("HealPercent").GetValue<Slider>().Value; var ManaPercent = this.HandlerMenu.Item("ManaPercent").GetValue<Slider>().Value; if (HealthPercent < ObjectManager.Player.HealthPercent && ManaPercent < ObjectManager.Player.ManaPercent) { spell.Cast(); } }, (Spell spell) => this.Instance.IsReady() && this.HandlerMenu.Item("SelfHeal").GetValue<bool>()); case HandlerType.OnImportantCast: this.HandlerMenu.AddItem(new MenuItem("Interrupt", "[Auto] Enable Interrupting")) .SetValue<bool>(false); return new Handler( this.Instance, (Spell spell) => { var units = ObjectManager.Get<Obj_AI_Hero>() .Where( s => s.IsCastingInterruptableSpell() && s.ServerPosition.Distance(ObjectManager.Player.ServerPosition) < this.Range); foreach (var unit in units.OrderBy(s => s.ServerPosition.Distance(ObjectManager.Player.ServerPosition))) { this.Cast(unit); } }, (Spell spell) => this.Instance.IsReady() && this.HandlerMenu.Item("Interrupt").GetValue<bool>() && ObjectManager.Get<Obj_AI_Hero>() .Any( s => s.IsEnemy && s.ServerPosition.Distance(ObjectManager.Player.ServerPosition) < this.Range && s.IsCastingInterruptableSpell(true))); } return null; }
public static void TraceLog(MsgType mt, SenderType sender, HandlerType handler, string handlerDetails = null) { string slashName = string.IsNullOrEmpty(handlerDetails) ? string.Empty : $"/{handlerDetails}"; Trace.WriteLine($"{mt}Msg from {sender} to {handler}{slashName} was received in {Clock.Timer.ElapsedMilliseconds}ms ({Clock.Timer.Elapsed.ToMicroseconds()}μs)"); }
public MsgHandlerBase(HandlerType handler, string name, bool messaging) { HandlerType = handler; Name = name; IsMessagingEnabled = messaging; }
public override HandlerPriority GetPriority(HandlerType type) { return(HandlerPriority.First); }