Beispiel #1
0
 static Window()
 {
     EventLookup.Register <Window>(c => c.OnClosed(null), ClosedEvent);
     EventLookup.Register <Window>(c => c.OnClosing(null), ClosingEvent);
     EventLookup.Register <Window>(c => c.OnLocationChanged(null), LocationChangedEvent);
     EventLookup.Register <Window>(c => c.OnWindowStateChanged(null), WindowStateChangedEvent);
 }
 public void SendMessage(EventLookup e, object obj)
 {
     _storage.Get().BasicPublish(exchange: _nameFactory.GetExchange(EventExchangeMapping.Dictionary[e]),
                                 routingKey: _nameFactory.GetRoutingKey(e),
                                 basicProperties: null,
                                 body: _serializer.Serialize(obj));
 }
 public static void ChatMessageReceived(object sender, Message e)
 {
     if (e.Text.Trim() == ("{costs}"))
     {
         MainPatcher.TextChannel.SendMessageAsync(EventLookup.getBitCosts(), MainPatcher.cts);
     }
 }
Beispiel #4
0
 static Splitter()
 {
     EventLookup.Register <Splitter>(c => c.OnPositionChanged(null), Splitter.PositionChangedEvent);
     EventLookup.Register <Splitter>(c => c.OnPositionChanging(null), Splitter.PositionChangingEvent);
     EventLookup.Register <Splitter>(c => c.OnPositionChangeStarted(null), Splitter.PositionChangingEvent);
     EventLookup.Register <Splitter>(c => c.OnPositionChangeCompleted(null), Splitter.PositionChangingEvent);
 }
Beispiel #5
0
        static async Task Main(string[] args)
        {
            var settings   = ConnectionSettings.Create();
            var connection = EventStoreConnection.Create(settings, new IPEndPoint(
                                                             IPAddress.Parse("127.0.0.1"), 1113));

            connection.ConnectAsync().Wait();

            var dbPath  = args[0];
            var options = new DbContextOptionsBuilder <DomainContext>()
                          .UseSqlite($"Data Source={dbPath}")
                          .Options;
            var context = new DomainContext(options);
            await context.Database.EnsureCreatedAsync();

            var events = new List <ResolvedEvent>();

            StreamEventsSlice currentSlice;
            var stream         = args[1];
            var nextSliceStart = (long)StreamPosition.Start;

            do
            {
                currentSlice = await connection.ReadStreamEventsForwardAsync(stream,
                                                                             nextSliceStart, 200, false);

                nextSliceStart = currentSlice.NextEventNumber;

                events.AddRange(currentSlice.Events);
            } while (!currentSlice.IsEndOfStream);

            var  eventLookup = new EventLookup();
            long id          = 1;

            foreach (var resolvedEvent in events)
            {
                var data      = Encoding.UTF8.GetString(resolvedEvent.Event.Data);
                var metaData  = Encoding.UTF8.GetString(resolvedEvent.Event.Metadata);
                var eventType = eventLookup.GetType(resolvedEvent.Event.EventType);
                if (eventType != null)
                {
                    var obj = (BaseEvent)JsonConvert.DeserializeObject(data, eventType);
                    obj.MetaData = JsonConvert.DeserializeObject <MetaData>(metaData);

                    await context.DomainEvents.AddAsync(new DomainEvent()
                    {
                        Id        = id,
                        CreatedOn = obj.MetaData.CreatedOn,
                        CreatedBy = obj.MetaData.ToString(),
                        EventType = obj.GetType().Name,
                        Content   = JsonConvert.SerializeObject(obj)
                    });

                    id++;
                }
            }

            await context.SaveChangesAsync();
        }
 public static void ChatMessageReceived(object sender, Message e)
 {
     Console.WriteLine("Received Chat Message");
     if (e.Text.Trim() == ("{bit-costs}"))
     {
         MainPatcher.TextChannel.SendMessageAsync(EventLookup.getBitCosts(), MainPatcher.cts);
     }
 }
Beispiel #7
0
 static Grid()
 {
     EventLookup.Register <Grid>(c => c.OnCellEdited(null), Grid.CellEditedEvent);
     EventLookup.Register <Grid>(c => c.OnCellEditing(null), Grid.CellEditingEvent);
     EventLookup.Register <Grid>(c => c.OnCellFormatting(null), Grid.CellFormattingEvent);
     EventLookup.Register <Grid>(c => c.OnSelectionChanged(null), Grid.SelectionChangedEvent);
     EventLookup.Register <Grid>(c => c.OnColumnHeaderClick(null), Grid.ColumnHeaderClickEvent);
 }
Beispiel #8
0
 static TreeGridView()
 {
     EventLookup.Register <TreeGridView>(c => c.OnExpanding(null), TreeGridView.ExpandingEvent);
     EventLookup.Register <TreeGridView>(c => c.OnExpanded(null), TreeGridView.ExpandedEvent);
     EventLookup.Register <TreeGridView>(c => c.OnCollapsing(null), TreeGridView.CollapsingEvent);
     EventLookup.Register <TreeGridView>(c => c.OnCollapsed(null), TreeGridView.CollapsedEvent);
     EventLookup.Register <TreeGridView>(c => c.OnSelectedItemChanged(null), TreeGridView.SelectedItemChangedEvent);
 }
Beispiel #9
0
 static WebView()
 {
     EventLookup.Register <WebView>(c => c.OnNavigated(null), WebView.NavigatedEvent);
     EventLookup.Register <WebView>(c => c.OnDocumentLoaded(null), WebView.DocumentLoadedEvent);
     EventLookup.Register <WebView>(c => c.OnDocumentLoading(null), WebView.DocumentLoadingEvent);
     EventLookup.Register <WebView>(c => c.OnDocumentTitleChanged(null), WebView.DocumentTitleChangedEvent);
     EventLookup.Register <WebView>(c => c.OnOpenNewWindow(null), WebView.OpenNewWindowEvent);
 }
Beispiel #10
0
 static SegmentedButton()
 {
     EventLookup.Register <SegmentedButton>(c => c.OnSelectedItemsChanged(null), SelectedIndexesChangedEvent);
     EventLookup.Register <SegmentedButton>(c => c.OnSelectedItemChanged(null), SelectedIndexesChangedEvent);
     EventLookup.Register <SegmentedButton>(c => c.OnSelectedIndexChanged(null), SelectedIndexesChangedEvent);
     EventLookup.Register <SegmentedButton>(c => c.OnSelectedIndexesChanged(null), SelectedIndexesChangedEvent);
     EventLookup.Register <SegmentedButton>(c => c.OnItemClicked(null), ItemClickEvent);
 }
Beispiel #11
0
 public Controller(Secrets secrets, ManualLogSource log)
 {
     _instance    = this;
     _secrets     = secrets;
     _log         = log;
     eventLookup  = new EventLookup(this);
     eventManager = new TwitchEventManager(this);
     timer        = new TimerCooldown(this);
 }
        public TwitchController(Secrets secrets, ManualLogSource log)
        {
            _secrets     = secrets;
            _log         = log;
            eventLookup  = new EventLookup(this);
            eventManager = new TwitchEventManager(this);
            timer        = new TimerCooldown(this);

            // Customize event configuration
            eventLookup.ConfigureEventCosts(secrets.eventConfigList);
        }
 public static void PubSubMessageReceived(object sender, Message e)
 {
     if (e.Host == ChannelPointsHost())
     {
         EventLookup.Lookup(e.Text, e.User);
     }
     if (e.Host == BitsHost())
     {
         EventLookup.Lookup(e.Text, e.User, Int32.Parse(e.Text.Split(':')[0]));
     }
 }
 public static void PubSubMessageReceived(object sender, Message e)
 {
     Console.WriteLine("Received Pub Sub Message:");
     if (e.Host == ChannelPointsHost())
     {
         EventLookup.Lookup(e.Text);
     }
     if (e.Host == BitsHost())
     {
         EventLookup.Lookup(e.Text, Int32.Parse(e.Text.Split(':')[0]));
     }
 }
Beispiel #15
0
 static TreeView()
 {
     EventLookup.Register <TreeView>(c => c.OnActivated(null), TreeView.ActivatedEvent);
     EventLookup.Register <TreeView>(c => c.OnSelectionChanged(null), TreeView.SelectionChangedEvent);
     EventLookup.Register <TreeView>(c => c.OnExpanding(null), TreeView.ExpandingEvent);
     EventLookup.Register <TreeView>(c => c.OnExpanded(null), TreeView.ExpandedEvent);
     EventLookup.Register <TreeView>(c => c.OnCollapsing(null), TreeView.CollapsingEvent);
     EventLookup.Register <TreeView>(c => c.OnCollapsed(null), TreeView.CollapsedEvent);
     EventLookup.Register <TreeView>(c => c.OnLabelEdited(null), TreeView.LabelEditedEvent);
     EventLookup.Register <TreeView>(c => c.OnLabelEditing(null), TreeView.LabelEditingEvent);
     EventLookup.Register <TreeView>(c => c.OnNodeMouseClick(null), TreeView.NodeMouseClickEvent);
 }
Beispiel #16
0
        public void Subscribe <T>(EventLookup e, Action <T> handler)
        {
            var channel  = _storage.Get();
            var consumer = new EventingBasicConsumer(channel);

            consumer.Received += (model, ea) =>
            {
                handler((T)_serializer.Deserialize(ea.Body));
            };
            channel.BasicConsume(queue: _nameFactory.GetQueue(_serviceBusClientSettings.ApplicationName, e),
                                 autoAck: true,
                                 consumer: consumer);
        }
        internal static void ClientMessageReceived(CrowdControlClient c, string raw)
        {
            try {
                Console.WriteLine("Message received: " + raw);
                // Decode the message from CC
                // { "id":1,"code":"kill","viewer":"sdk","type":1}
                var request = JsonSerializer.Deserialize <CrowdControlRequest>(raw);

                // Do the thing
                var eventName = EventNameDict[request.Code];
                var status    = 0;

                if (TimerCooldown.IsInitialised())
                {
                    try
                    {
                        EventLookup.Lookup(eventName, request.Viewer);
                    }
                    catch (Exception)
                    {
                        // On exception set failed flag
                        status = 1;
                    }
                }
                else
                {
                    // Game is not yet ready for events, retry until it is.
                    status = 3;
                }


                // Send the result to CC
                var response = new CrowdControlResponse();
                response.Id      = request.Id;
                response.Status  = status;
                response.Message = "Effect: " + request.Code + ": " + response.Status;

                var resJson = JsonSerializer.Serialize <CrowdControlResponse>(response);
                Console.WriteLine("Sending response: " + resJson);

                c.Send(resJson, false);
            } catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Beispiel #18
0
 static Control()
 {
     EventLookup.Register <Control>(c => c.OnGotFocus(null), Control.GotFocusEvent);
     EventLookup.Register <Control>(c => c.OnKeyDown(null), Control.KeyDownEvent);
     EventLookup.Register <Control>(c => c.OnKeyUp(null), Control.KeyUpEvent);
     EventLookup.Register <Control>(c => c.OnLostFocus(null), Control.LostFocusEvent);
     EventLookup.Register <Control>(c => c.OnMouseDoubleClick(null), Control.MouseDoubleClickEvent);
     EventLookup.Register <Control>(c => c.OnMouseDown(null), Control.MouseDownEvent);
     EventLookup.Register <Control>(c => c.OnMouseEnter(null), Control.MouseEnterEvent);
     EventLookup.Register <Control>(c => c.OnMouseLeave(null), Control.MouseLeaveEvent);
     EventLookup.Register <Control>(c => c.OnMouseMove(null), Control.MouseMoveEvent);
     EventLookup.Register <Control>(c => c.OnMouseUp(null), Control.MouseUpEvent);
     EventLookup.Register <Control>(c => c.OnMouseWheel(null), Control.MouseWheelEvent);
     EventLookup.Register <Control>(c => c.OnShown(null), Control.ShownEvent);
     EventLookup.Register <Control>(c => c.OnSizeChanged(null), Control.SizeChangedEvent);
     EventLookup.Register <Control>(c => c.OnTextInput(null), Control.TextInputEvent);
 }
Beispiel #19
0
        public static void Patch()
        {
            secrets = new Secrets();

            // Customize event configuration
            EventLookup.ConfigureEventCost(secrets.eventConfigList);

            if (secrets.client == "crowdcontrol")
            {
                Console.WriteLine("CrowdControl client active");
                StartCrowdControlServer();
            }
            else
            {
                Console.WriteLine("Twitch client active");
                //StartTwitchChatClient(); Turned off cause the ping pong doesnt work and when it disconnects it crashes the game
                StartTwitchPubSubClient();
            }

            Harmony.CreateAndPatchAll(myAssembly, "subnautica.mod.twitchinteraction");
        }
Beispiel #20
0
 static PrintDocument()
 {
     EventLookup.Register <PrintDocument>(c => c.OnPrinting(null), PrintDocument.PrintingEvent);
     EventLookup.Register <PrintDocument>(c => c.OnPrinted(null), PrintDocument.PrintedEvent);
     EventLookup.Register <PrintDocument>(c => c.OnPrintPage(null), PrintDocument.PrintPageEvent);
 }
Beispiel #21
0
 static Splitter()
 {
     EventLookup.Register <Splitter>(c => c.OnPositionChanged(null), Splitter.PositionChangedEvent);
 }
Beispiel #22
0
 static MenuItem()
 {
     EventLookup.Register <MenuItem>(c => c.OnValidate(null), MenuItem.ValidateEvent);
 }
Beispiel #23
0
 static Scrollable()
 {
     EventLookup.Register <Scrollable>(c => c.OnScroll(null), Scrollable.ScrollEvent);
 }
Beispiel #24
0
 static TextBox()
 {
     EventLookup.Register <TextBox>(c => c.OnTextChanging(null), TextBox.TextChangingEvent);
 }
Beispiel #25
0
 static Application()
 {
     EventLookup.Register <Application>(c => c.OnTerminating(null), Application.TerminatingEvent);
 }
Beispiel #26
0
 static TextArea()
 {
     EventLookup.Register <TextArea>(c => c.OnSelectionChanged(null), TextArea.SelectionChangedEvent);
     EventLookup.Register <TextArea>(c => c.OnCaretIndexChanged(null), TextArea.CaretIndexChangedEvent);
 }
        /// <summary>
        /// Transform the JSON structure given by Planepoly (using EventService class) to our own JSON structure.
        /// </summary>
        /// <param name="eventPlanepolyServiceList">List of records to map.</param>
        /// <returns>A list of our own JSON structure (using EventLookup) class)</returns>
        private List <EventLookup> TransformEventServiceToEventLookup(List <EventService> eventPlanepolyServiceList)
        {
            // Creates now a list of all events mapped to our structure, given
            // the Planepoly JSON structure.
            List <EventLookup> eventLookupList = new List <EventLookup>();

            foreach (var service in eventPlanepolyServiceList)
            {
                EventLookup eventLookup = new EventLookup();
                eventLookup.name      = service.nombre.Trim();
                eventLookup.img       = service.img;
                eventLookup.url       = service.url;
                eventLookup.premiere  = service.estr;
                eventLookup.genre     = service.genero;
                eventLookup.type      = service.tipo;
                eventLookup.typeName  = GetTypeName(eventLookup.type);
                eventLookup.locations = new List <EventLookupLocation>();
                foreach (var location in service.ptos)
                {
                    EventLookupLocation elLocation = new EventLookupLocation();
                    elLocation.name    = location.nombre;
                    elLocation.address = location.direccion;

                    List <EventLookupShow>   elShowList = new List <EventLookupShow>();
                    Dictionary <int, string> shows      = new Dictionary <int, string>();
                    shows.Add(0, "");
                    shows.Add(1, "");
                    shows.Add(2, "");
                    shows.Add(3, "");
                    shows.Add(4, "");
                    shows.Add(5, "");
                    shows.Add(6, "");
                    shows.Add(7, "");
                    foreach (var show in location.funcs)
                    {
                        if (shows.ContainsKey(show.dia))
                        {
                            var valDay = shows[show.dia];
                            valDay         += show.hora + " ";
                            shows[show.dia] = valDay;
                        }
                    }
                    foreach (var it in shows)
                    {
                        if (it.Value.Trim() != "")
                        {
                            EventLookupShow mls = new EventLookupShow();
                            mls.frequency = it.Key;
                            mls.hours     = it.Value.Trim();
                            switch (mls.frequency)
                            {
                            case 0:
                                mls.name = "Diario";
                                break;

                            case 1:
                                mls.name = "Lunes";
                                break;

                            case 2:
                                mls.name = "Martes";
                                break;

                            case 3:
                                mls.name = "Miércoles";
                                break;

                            case 4:
                                mls.name = "Jueves";
                                break;

                            case 5:
                                mls.name = "Viernes";
                                break;

                            case 6:
                                mls.name = "Sábado";
                                break;

                            case 7:
                                mls.name = "Domingo";
                                break;

                            default:
                                break;
                            }
                            elShowList.Add(mls);
                        }
                    }
                    elLocation.schedule = elShowList;
                    eventLookup.locations.Add(elLocation);
                }
                eventLookupList.Add(eventLookup);
            }
            return(eventLookupList);
        }
Beispiel #28
0
 static FontDialog()
 {
     EventLookup.Register <FontDialog>(c => c.OnFontChanged(null), FontDialog.FontChangedEvent);
 }
Beispiel #29
0
 static TextControl()
 {
     EventLookup.Register <TextControl>(c => c.OnTextChanged(null), TextControl.TextChangedEvent);
 }
Beispiel #30
0
 static SegmentedItem()
 {
     EventLookup.Register <SegmentedItem>(c => c.OnClick(null), ClickEvent);
 }