Example #1
0
        public TraitCollection(TraitContext traitContext)
        {
            this.traitContext = traitContext;

            Stats  = new EventDictionary <StatIdentifier, StatInstance>();
            States = new EventDictionary <StateIdentifier, StateInstance>();
        }
Example #2
0
 public void RemoveEventListener(Event e)
 {
     if (EventDictionary.ContainsKey(e))
     {
         EventDictionary.Remove(e);
     }
 }
Example #3
0
 public void AddEventListener(Event e, EventHandler handler)
 {
     if (!EventDictionary.ContainsKey(e))
     {
         EventDictionary.Add(e, handler);
     }
 }
Example #4
0
        public virtual void TrackTrace(string message, SeverityLevel severity, EventDictionary eventId, IDictionary <string, string> properties = null)
        {
            //TelemetryClient client = new TelemetryClient();
            properties = InitializeProperties(properties);
            properties.AddEventId((int)eventId);

            aiClient.TrackTrace(message, severity, properties);
        }
Example #5
0
        public Equipment()
        {
            EquipmentList = new EventDictionary<EquipmentSlot, Armor>();

            foreach (EquipmentSlot slot in EnumUtils.GetValues<EquipmentSlot>())
            {
                EquipmentList.Add(slot, null);
            }
        }
Example #6
0
        public void StartService()
        {
            if (ServiceStarted)
            {
                return;
            }
            ServiceStarted = true;
            MDNS.Start();
            SD.ServiceInstanceDiscovered += (s, e) => MDNS.SendQuery(e.ServiceInstanceName, type: DnsType.SRV);

            MDNS.AnswerReceived += (s, e) =>
            {
                var servers = e.Message.Answers.OfType <SRVRecord>();
                foreach (var server in servers)
                {
                    var target = server.Target.ToString();
                    var name   = string.Join(".", server.Name.Labels.TakeLast(3));
                    lock (_dictLock)
                    {
                        if (TargetDictionary.ContainsKey(target))
                        {
                            if (!TargetDictionary[target].Contains(name))
                            {
                                TargetDictionary[target].Add(name);
                            }
                        }
                        else
                        {
                            TargetDictionary.Add(target, new HashSet <string> {
                                name
                            });
                        }
                    }

                    Logger.LogInformation($"Receive service record: {name} = {target}");
                    MDNS.SendQuery(server.Target, type: DnsType.A);
                }

                var addresses = e.Message.Answers.OfType <AddressRecord>();
                foreach (var address in addresses)
                {
                    if (!DomainNameDictionary.TryAdd(address.Name.ToString(), address.Address))
                    {
                        DomainNameDictionary[address.Name.ToString()] = address.Address;
                    }
                    Logger.LogInformation($"Receive address record: {address.Name} = {address.Address}");
                    if (TargetDictionary.ContainsKey(address.Name.ToString()))
                    {
                        TargetDictionary[address.Name.ToString()]
                        .Where(t => EventDictionary.ContainsKey(t))
                        .Foreach(t => EventDictionary[t].Invoke(this, new IPAddressEventArgs(address.Address)));
                    }
                }
            };

            Logger.LogInformation("Service discovery started");
        }
Example #7
0
        public EventProxy <IPAddressEventArgs> DiscoverService(string serviceName)
        {
            MDNS.SendQuery(serviceName, type: DnsType.PTR);
            lock (_dictLock)
            {
                EventDictionary.TryAdd(serviceName, new EventProxy <IPAddressEventArgs>());
            }

            return(EventDictionary[serviceName]);
        }
Example #8
0
 public MainForm()
 {
     InitializeComponent();
     searcher = new RegSearcher();
     searcher.SearchComplete += new EventHandler <SearchCompleteEventArgs>(searcher_SearchComplete);
     searcher.MatchFound     += new EventHandler <MatchFoundEventArgs>(searcher_MatchFound);
     favorites              = new EventDictionary <string, string>();
     favorites.ItemAdded   += new EventHandler <ItemEventArgs <string, string> >(favorites_ItemAdded);
     favorites.ItemRemoved += new EventHandler <ItemEventArgs <string, string> >(favorites_ItemRemoved);
 }
 private void FireEventHandlers(List <RawEvent> finalEvents)
 {
     foreach (RawEvent rawEvent in finalEvents)
     {
         if (EventDictionary.ContainsKey(rawEvent.@event))
         {
             AmeisenBotLogger.Instance.Log($"[{WowActionExecutor.ProcessId.ToString("X", CultureInfo.InvariantCulture.NumberFormat)}]\t{EventDictionary[rawEvent.@event].Method.Name}({rawEvent.time}, {JsonConvert.SerializeObject(rawEvent.args)})");
             EventDictionary[rawEvent.@event].Invoke(rawEvent.time, rawEvent.args);
         }
     }
 }
        private void SetEvent(BinaryReader br)
        {
            Guid key = new Guid(br.ReadBytes(16));
            var  res = WorkVariants.GetObject(br, this);
            WrapperObjectWithEvents value;

            if (EventDictionary.TryGetValue(key, out value))
            {
                value.RaiseEvent(key, res);
            }
        }
Example #11
0
        private void ReadEvents()
        {
            while (IsActive)
            {
                if (AmeisenCore.IsInLoadingScreen())
                {
                    Thread.Sleep(50);
                    continue;
                }

                // Unminified lua code can be found im my github repo "WowLuaStuff"
                string eventJson = AmeisenCore.GetLocalizedText("abEventJson='['for a,b in pairs(abEventTable)do abEventJson=abEventJson..'{'for c,d in pairs(b)do if type(d)==\"table\"then abEventJson=abEventJson..'\"args\": ['for e,f in pairs(d)do abEventJson=abEventJson..'\"'..f..'\"'if e<=table.getn(d)then abEventJson=abEventJson..','end end;abEventJson=abEventJson..']}'if a<table.getn(abEventTable)then abEventJson=abEventJson..','end else if type(d)==\"string\"then abEventJson=abEventJson..'\"event\": \"'..d..'\",'else abEventJson=abEventJson..'\"time\": \"'..d..'\",'end end end end;abEventJson=abEventJson..']'abEventTable={}", "abEventJson");
                AmeisenLogger.Instance.Log(LogLevel.VERBOSE, $"LUA Events Json: {eventJson}", this);

                List <RawEvent> rawEvents = new List <RawEvent>();
                try
                {
                    // parse the events from JSON
                    List <RawEvent> finalEvents = new List <RawEvent>();
                    rawEvents = JsonConvert.DeserializeObject <List <RawEvent> >(eventJson);

                    foreach (RawEvent rawEvent in rawEvents)
                    {
                        if (!finalEvents.Contains(rawEvent))
                        {
                            finalEvents.Add(rawEvent);
                        }
                    }

                    // Fire the events
                    AmeisenLogger.Instance.Log(LogLevel.VERBOSE, $"Parsed {finalEvents.Count} events", this);
                    if (finalEvents.Count > 0)
                    {
                        foreach (RawEvent rawEvent in finalEvents)
                        {
                            if (EventDictionary.ContainsKey(rawEvent.@event))
                            {
                                EventDictionary[rawEvent.@event].Invoke(rawEvent.time, rawEvent.args);
                                AmeisenLogger.Instance.Log(LogLevel.VERBOSE, $"Fired OnEventFired: {rawEvent.@event}", this);
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    AmeisenLogger.Instance.Log(LogLevel.ERROR, $"Failed to parse events Json: {e}", this);
                }

                Thread.Sleep(1000);
            }
        }
Example #12
0
        public virtual void Update(GameTime gameTime)
        {
            foreach (var i in ChildList.OrderBy(_ => _.Index).Reverse())
            {
                i.Update(gameTime);
            }

            if (IsEventApplicable)
            {
                EventsManager.TrySet(this);
            }

            foreach (var i in EventDictionary.Where(_ => EventsHandler.HandleMouse(this, _.Key)))
            {
                if (i.Key == Event.CLICKOUTLEFT || i.Key == Event.MOUSEOVER ||
                    i.Key == Event.MOUSEOUT || EventsManager.IsValid(this))
                {
                    i.Value?.Invoke(this, new EventArgs());
                }
            }
        }
 public RemoveFavoritesDialog(EventDictionary <string, string> favorites)
 {
     InitializeComponent();
     this.favorites = favorites;
 }
Example #14
0
 public void RemoveAllEvent() => EventDictionary.Clear();
 public void Subscribe(string eventName, OnEventFired onEventFired)
 {
     AmeisenBotLogger.Instance.Log($"[{WowActionExecutor.ProcessId.ToString("X", CultureInfo.InvariantCulture.NumberFormat)}]\tSubscribed to \"{eventName}\"");
     WowActionExecutor.LuaDoString($"abFrame:RegisterEvent(\"{eventName}\");");
     EventDictionary.Add(eventName, onEventFired);
 }
 public void Unsubscribe(string eventName)
 {
     AmeisenBotLogger.Instance.Log($"[{WowActionExecutor.ProcessId.ToString("X", CultureInfo.InvariantCulture.NumberFormat)}]\tUnsubscribed from \"{eventName}\"");
     WowActionExecutor.LuaDoString($"abFrame:UnregisterEvent(\"{eventName}\");");
     EventDictionary.Remove(eventName);
 }
Example #17
0
 /// <summary>
 /// Subscribe to an event
 /// </summary>
 /// <param name="eventName">event name</param>
 /// <param name="onEventFired">method to fire when the event appered in WoW</param>
 public void Subscribe(string eventName, OnEventFired onEventFired)
 {
     AmeisenCore.LuaDoString($"abFrame:RegisterEvent(\"{eventName}\");");
     EventDictionary.Add(eventName, onEventFired);
 }
Example #18
0
 public EventDictionary(IntermediateFullMemberDictionary master, IntermediateGenericSegmentableInstantiableType <TCtor, TIntermediateCtor, TEvent, TIntermediateEvent, TIntermediateEventMethod, TField, TIntermediateField, TIndexer, TIntermediateIndexer, TIntermediateIndexerMethod, TMethod, TIntermediateMethod, TProperty, TIntermediateProperty, TIntermediatePropertyMethod, TType, TIntermediateType, TInstanceIntermediateType> parent, EventDictionary root)
     : base(master, ((TIntermediateType)((object)(parent))), root)
 {
 }
Example #19
0
 /// <summary>
 /// Unsubscribe from an event
 /// </summary>
 /// <param name="eventName">event name</param>
 public void Unsubscribe(string eventName)
 {
     AmeisenCore.LuaDoString($"abFrame:UnregisterEvent(\"{eventName}\");");
     EventDictionary.Remove(eventName);
 }