public void UnregisterEvents <T>(T obj) where T : class { foreach (var kv in RegisteredEvents.ToArray()) { kv.Value.Clear(obj); } }
/// <summary> /// Unregisters all <see cref="EventHandlerAttribute"/> from the specified <see cref="IEventHandler"/> implementation from the current EventDispatcher /// After UnRegistering, the class will no longer get invoked when an event gets dispatched. /// </summary> /// <param name="obj">The implementation to unregister the eventhandlers for</param> public void UnregisterEvents(IEventHandler obj) { foreach (var kv in RegisteredEvents.ToArray()) { kv.Value.Clear(obj); } }
/// <summary> /// Spusti sekvencne vsetky fazy - az po skonceni ich volanych metod sa spusti dalsia faza. /// </summary> public void RunTests() { bool result; // Initialization RegisteredEvents.Initialize(); // Creating Model Model.Instance.Buildings.Add(new BaseCenter(PlaceType.NearBase)); Model.Instance.Units.Add(new Worker(PlaceType.NearBase)); Log.i(null, "----------------------------------"); Log.i(null, ">> Starting a new Test Round. <<"); Log.i(null, "----------------------------------"); var battleStage = new NextStageStarter(() => { Log.i(this, "Starting Battle Stage"); var battle = new BattleTest(); result = Battle(battle, () => { }); Log.i(battle, "End of Battle Stage: " + SuccessString(result)); }); var buildingStage = new NextStageStarter(() => { Log.i(this, "Starting Building Stage"); var building = new BuildingTest(); result = Building(building, battleStage); Log.i(building, "End of Building Stage: " + SuccessString(result)); }); var economyStage = new NextStageStarter(() => { Log.i(this, "Starting Economy Stage"); var economy = new EconomyTest(); result = Economy(economy, buildingStage); Log.i(economy, "End of Economy Stage: " + SuccessString(result)); }); economyStage(); Log.i(null, ""); Log.i(null, ">> End of a Planning Phase. <<"); Log.i(null, ""); var gameTimer = new GameTimer(); gameTimer.RunGame(() => { if (gameTimer.Cycle >= 500) { return(true); } return(false); }); Log.i(null, ""); Log.i(null, ">> End of Game. <<"); Log.i(null, ""); }
/// <summary> /// Initializes a new instance of the <see cref="PreEscalationCreateDuplicateDetection"/> class. /// </summary> public PreEscalationCreateDuplicateDetection() : base(typeof(PreEscalationCreateDuplicateDetection)) { RegisteredEvents.Add(new Tuple <int, string, string, Action <LocalPluginContext> >(20, "Create", "smp_escalation", new Action <LocalPluginContext>(this.ExecutePreEscalationCreateDuplicateDetection))); // Note : you can register for more events here if this plugin is not specific to an individual entity and message combination. // You may also need to update your RegisterFile.crmregister plug-in registration file to reflect any change. }
/// <summary> /// Initializes a new instance of the <see cref="PostProviderCreateTeam"/> class. /// </summary> public PostProviderCreateTeam() : base(typeof(PostProviderCreateTeam)) { RegisteredEvents.Add(new Tuple <int, string, string, Action <LocalPluginContext> >(40, Constants.Create, Constants.AccountEntityName, new Action <LocalPluginContext>(this.ExecutePostProviderCreateTeam))); // Note : you can register for more events here if this plugin is not specific to an individual entity and message combination. // You may also need to update your RegisterFile.crmregister plug-in registration file to reflect any change. }
/// <summary> /// Initializes a new instance of the <see cref="PostServiceRequestsmp_CopySR"/> class. /// </summary> public PostServiceRequestsmp_CopySR() : base(typeof(PostServiceRequestsmp_CopySR)) { RegisteredEvents.Add(new Tuple <int, string, string, Action <LocalPluginContext> >(40, "smp_CopySR", "incident", new Action <LocalPluginContext>(this.ExecutePostServiceRequestsmp_CopySR))); // Note : you can register for more events here if this plugin is not specific to an individual entity and message combination. // You may also need to update your RegisterFile.crmregister plug-in registration file to reflect any change. }
public void Reset() { var registered = RegisteredEvents.ToArray(); foreach (var reg in registered) { reg.Value.ClearAll(); } }
private bool TryRegisterEvent(string eventName, ulong eventHandlerId) { if (RegisteredEvents.TryGetValue(eventName, out var eventRegistration)) { Renderer.RegisterEvent(eventHandlerId, eventRegistration.ClearId); eventRegistration.SetId(eventHandlerId); return(true); } return(false); }
public override void RegisterEvents() { RegisteredEvents.AddRange(new RegisteredEventBuilder(PipelineStage.PreOperation, MessageType.Create). ForEntities(dlab_AutoNumbering.EntityLogicalName). WithExecuteAction(RegisterIncrementor).Build()); RegisteredEvents.AddRange(new RegisteredEventBuilder(PipelineStage.PreOperation, MessageType.Delete). ForEntities(dlab_AutoNumbering.EntityLogicalName). WithExecuteAction(UnregisterIncrementor).Build()); RegisteredEvents.AddRange(new RegisteredEventBuilder(PipelineStage.PreOperation, MessageType.Update). ForEntities(dlab_AutoNumbering.EntityLogicalName). WithExecuteAction(ProcessStateChange).Build()); }
public Event RegisterForEvent(int userID, string eventID) { RegisteredEvents re = new RegisteredEvents() { UserID = userID, EventID = eventID }; dbContext.RegisteredEvents.Add(re); dbContext.SaveChanges(); return((from e in dbContext.RegisteredEvents where e.EventID == eventID select e.Event).FirstOrDefault()); }
public override void RegisterEvents() { RegisteredEvents.AddRange( new RegisteredEventBuilder(PipelineStage.PreOperation, MessageType.Create, MessageType.Update). ForEntities(Account.EntityLogicalName, Contact.EntityLogicalName, Lead.EntityLogicalName). WithExecuteAction(ExecuteCrmPhoneNumber).Build()); RegisteredEvents.AddRange( new RegisteredEventBuilder(PipelineStage.PreOperation, MessageType.Create, MessageType.Update). ForEntities(BusinessUnit.EntityLogicalName, Competitor.EntityLogicalName, Site.EntityLogicalName, SystemUser.EntityLogicalName). WithExecuteAction(ExecuteCrmAddresses).Build()); }
/// <summary> /// Registers a new <see cref="Event"/> /// </summary> /// <param name="type">The type of the <see cref="Event"/> to register</param> /// <returns>Whether the event was succesfully registered.</returns> public bool RegisterEventType(Type type) { if (RegisteredEvents.ContainsKey(type) || !EventTypes.TryAdd(type)) { return(false); } else { RegisteredEvents.Add(type, new EventDispatcherValues()); Log.Info($"Registered event type \"{type.Name}\""); return(true); } }
/// <summary> /// Registers all EventHandler methods with the current EventDispatcher. /// </summary> /// <param name="obj">The class to scan for EventHandlers</param> public void RegisterEvents(IEventHandler obj) { int count = 0; var type = typeof(Event); Type objType = obj.GetType(); foreach (var method in objType.GetMethods(BindingFlags.Public | BindingFlags.Instance)) { EventHandlerAttribute attribute = method.GetCustomAttribute <EventHandlerAttribute>(false); if (attribute == null) { continue; } var parameters = method.GetParameters(); if (parameters.Length != 1 || !type.IsAssignableFrom(parameters[0].ParameterType)) { continue; } var paramType = parameters[0].ParameterType; EventDispatcherValues e = null; if (!RegisteredEvents.TryGetValue(paramType, out e)) { if (EventTypes.TryAdd(paramType)) { e = new EventDispatcherValues(); RegisteredEvents.Add(paramType, e); } } if (!e.RegisterEventHandler(attribute, obj, method)) { Log.Warn($"Duplicate found for class \"{obj.GetType()}\" of type \"{paramType}\""); } else { count++; } } Log.Info($"Registered {count} event handlers for \"{obj}\""); }
/// <summary> /// Unloads all <see cref="Event"/>'s that were registered by specified assembly /// </summary> /// <param name="assembly">The assembly containing the types to be unloaded.</param> public void Unload(Assembly assembly) { int count = 0; foreach (var eventType in (from eventType in EventTypes where eventType.Assembly == assembly select eventType)) { if (EventTypes.Remove(eventType)) { count++; } RegisteredEvents.Remove(eventType); } Log.Info($"Unloaded {count} event types from assembly {assembly.ToString()}"); }
private async Task DispatchPrivate(Event e) { try { Type type = e.GetType(); if (RegisteredEvents.TryGetValue(type, out EventDispatcherValues v)) { await v.DispatchAsync(e); } else { Log.Warn($"Unknown event type found! \"{type}\""); } } catch (Exception ex) { Log.Error("Error while dispatching event!", ex); } }
private void DispatchPrivate(Event e) { try { Type type = e.GetType(); if (RegisteredEvents.TryGetValue(type, out EventDispatcherValues v)) { v.Dispatch(e); } else { Log.Warn($"Unknown event type found! \"{type}\""); } } catch (Exception ex) { Log.Error(ex, $"Error while dispatching event: {ex.ToString()}"); } }
public RegisteredEventsdetails RegisteredEventbind(int studentcode) { RegisteredEventsdetails Detail = new RegisteredEventsdetails(); List <RegisteredEvents> RegEventlist = new List <RegisteredEvents>(); using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["con"].ConnectionString)) { using (SqlCommand cmd = new SqlCommand("selectpaidevents", con)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@Studentcode", SqlDbType.Int).Value = studentcode; SqlDataAdapter sda = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); sda.Fill(dt); if (dt.Rows.Count > 0) { foreach (DataRow dtrow in dt.Rows) { var slist = new RegisteredEvents(); slist.refcode = Convert.ToInt32(dtrow["Code"]); slist.eventname = Convert.ToString(dtrow["EventName"]); slist.eventdetaillink = Convert.ToString(dtrow["Hyperlink"]); slist.eventdate = Convert.ToString(dtrow["edate"]); slist.maxmarks = Convert.ToString(dtrow["Maxmarks"]); slist.Amount = Convert.ToInt32(dtrow["Amount"]); RegEventlist.Add(slist); } Detail.RegisteredEventsdetail = RegEventlist; } else { throw new HttpResponseException(HttpStatusCode.NoContent); } } } return(Detail); }
/// <summary> /// Initializes a new instance of the <see cref="PreCharityRegistrationUpdateSubgridValidation"/> class. /// </summary> public PreCharityRegistrationUpdateSubgridValidation() : base(typeof(PreCharityRegistrationUpdate)) { RegisteredEvents.Add(new Tuple <int, string, string, Action <LocalPluginContext> >(20, "Update", "crs_charityinitialregistration", new Action <LocalPluginContext>(this.ExecutePreCharityRegistrationUpdateSubgridValidation))); }
public PreSRUpdatePriorityEscalationNotes() : base(typeof(PreSRUpdatePriorityEscalationNotes)) { RegisteredEvents.Add(new Tuple<int, string, string, Action<LocalPluginContext>>(20, Constants.Update, Constants.IncidentEntityaName, new Action<LocalPluginContext>(this.ExecutePriorityNotes))); }
//public AccountSetTerritories() //{ //} public AccountSetTerritories(string unsecureConfig, string secureConfig) : base(unsecureConfig, secureConfig) { RegisteredEvents.Add(new PluginEvent(eStage.PreOperation, "Create", "account", ExecutePluginLogic)); RegisteredEvents.Add(new PluginEvent(eStage.PreOperation, "Update", "account", ExecutePluginLogic)); }
/// <summary> /// Initializes a new instance of the <see cref="PrePFRRegistrationUpdate"/> class. /// </summary> public PrePFRRegistrationUpdate() : base(typeof(PrePFRRegistrationUpdate)) { RegisteredEvents.Add(new Tuple <int, string, string, Action <LocalPluginContext> >(20, "Update", "crs_pfrrenewal", new Action <LocalPluginContext>(this.ExecutePrePFRRegistrationUpdate))); }
public PreServiceRequestUpdateCompletedDate() : base(typeof(PreServiceRequestUpdateCompletedDate)) { RegisteredEvents.Add(new Tuple <int, string, string, Action <LocalPluginContext> >(20, "Update", "incident", new Action <LocalPluginContext>(this.ExecuteCompletedDatebyBuildingTimeZone))); }
public override void RegisterEvents() { RegisteredEvents.AddRange(new RegisteredEventBuilder(PipelineStage.PostOperation, MessageType.Create, MessageType.Update). ForEntities(Contact.EntityLogicalName).Build()); }
private void _connection_UnhandledEvent(object sender, ManagerEvent e) { string name = e.GetType().Name; if (AsteriskEvent != null && (RegisteredEvents == null || RegisteredEvents.Count == 0 || RegisteredEvents.Contains(name))) { if (!String.IsNullOrEmpty(Filter)) { Regex regex = new Regex(Filter); if (regex.IsMatch(e.ToString())) { AsteriskEvent(this, new AsteriskEventArgs(name, convert(e))); } } else { AsteriskEvent(this, new AsteriskEventArgs(name, convert(e))); } } }
public override void RegisterEvents() { RegisteredEvents.AddRange(new RegisteredEventBuilder(PipelineStage.PreOperation, MessageType.Create).Build()); }