public void AddEvent(DateTime date, string title, string location) { Event newEvent = new Event(date, title, location); this.byTitle.Add(title.ToLower(), newEvent); this.byDate.Add(newEvent); Message.EventAdded(); }
public void TestEventCompareTo() { Event game = new Event(new DateTime(2013, 10, 10, 15, 50, 0), "Volley", "Beach"); Event lecture = new Event(new DateTime(2013, 06, 01, 21, 20, 0), "JS", "Telerik"); Assert.AreEqual(true, game.CompareTo(lecture) > 0); }
private static void AddEvent(string command) { var currentEvent = new Event(DateTime.Now, "title", "location"); ///GetParameters(command, "AddEvent", out date, out title, out location); var events = new MultiDictionary<string, Event>(true); ///added that to make it stop crashing too events.Add("title", currentEvent); }
/// <summary> /// Returns an Event from the Events table /// </summary> /// <param name="eventName"> Name of event </param> /// <param name="dbConnection"> Reuse dbConnection to save memory </param> /// <returns> An Event, passing it the dbconnection for it to fetch all information it needs </returns> public Events.Event GetEventByName(string eventName, IDbConnection dbConnection) { using (IDbCommand dbcmd = dbConnection.CreateCommand()) { dbcmd.CommandText = "SELECT * FROM Events WHERE Name = '" + eventName + "'"; using (IDataReader reader = dbcmd.ExecuteReader()) { Events.Event newEvent = null; string[] eventInteractions = new string[5]; string[] eventSprites = new string[3]; int[] possibleBackgrounds = new int[4]; if (reader.Read()) { eventInteractions[0] = reader.GetString(6); eventInteractions[1] = reader.GetString(7); eventInteractions[2] = reader.GetString(8); eventInteractions[3] = reader.GetString(9); eventInteractions[4] = reader.GetString(10); eventSprites[0] = reader.GetString(14); eventSprites[1] = reader.GetString(15); eventSprites[2] = reader.GetString(16); newEvent = new Events.Event(reader.GetString(1), reader.GetString(2), reader.GetInt32(3), reader.GetInt32(4), reader.GetString(5), eventInteractions, reader.GetBoolean(11), reader.GetString(12), reader.GetInt32(13), eventSprites, dbConnection); } return(newEvent); } } }
/// <summary> /// Adds the string representation of the <see cref="Event"/> /// to the message log. /// </summary> /// <param name="eventToAdd">The event which will be added in the log.</param> public void AddEvent(Event eventToAdd) { if (eventToAdd != null) { this.output.Append(eventToAdd + Environment.NewLine); } }
/// <summary> /// If there is a valid event print it to a new line. /// </summary> /// <param name="eventToPrint">An event given to check.</param> public static void PrintEvent(Event eventToPrint) { if (eventToPrint != null) { Output.Append(eventToPrint).AppendLine(); } }
public void PrintEvent(Event eventToPrint) { if (eventToPrint != null) { this.output.AppendLine(eventToPrint.ToString()); } }
public void TestEventCompareTo3() { Event seminar = new Event(new DateTime(2013, 5, 9, 9, 0, 0), "Humanware", "Enterprise Hall"); Event lecture = new Event(new DateTime(2013, 5, 9, 9, 0, 0), "Humanware", "Telerik Academy"); Assert.AreEqual(true, seminar.CompareTo(lecture) < 0); }
static void Main(string[] args) { Bus.Initialize(sbc => { sbc.UseMsmq(x => x.UseMulticastSubscriptionClient()); sbc.UseNLog(); sbc.ReceiveFrom("msmq://localhost/test.publisher"); }); Bus.Instance.Probe(); Bus.Instance.WriteIntrospectionToFile("publisher.txt"); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("----------WELCOME TO MESSAGE PUBLISHER---------"); Console.WriteLine("Type your message and press enter (this step will repeat until CTRL+C)"); while (true) { Console.ForegroundColor = ConsoleColor.DarkGreen; Console.Write("Message: "); Console.ForegroundColor = ConsoleColor.Gray; var msg = Console.ReadLine(); var evt = new Event(); evt.Message = msg; evt.EventDateTime = DateTime.Now; evt.EventId = Guid.NewGuid(); Bus.Instance.Publish(evt); } }
public static void PrintEvent(Event eventToPrint) { if (eventToPrint != null) { Program.output.Append(eventToPrint + "\n"); } }
public static void PrintEvent(Event eventToPrint, StringBuilder output) { if (eventToPrint != null) { output.Append(eventToPrint + "\n"); } }
public static void PrintEvent(Event eventToPrint) { if (eventToPrint != null) { output.Append(eventToPrint + Environment.NewLine); } }
public void OnEventRequest(Event externalEvent) { if (externalEvent == null) return; Log.Info("Got event " + externalEvent.Name); if (OnEvent != null) OnEvent(this, externalEvent); }
public void DispatchEvent(Event @event) { IEnumerable<dynamic> eventHandlers = factory.GetHandlersFor(@event); if (eventHandlers != null && eventHandlers.Any()) { Parallel.ForEach(eventHandlers, handler => handler.Handle((dynamic)@event)); } }
public void AddEvent(Event @event) { var snapshot = @event as Events.ParticipantSnapshottedEvent.Version1; if (snapshot == null) writeRepository.Do("INSERT INTO [Events] ([Id], [AggregateRootId], [Event]) VALUES (@Id, @AggregateRootId, @Event)", Pairs(@event)); else writeRepository.Do("INSERT INTO [Snapshots] ([Id], [AggregateRootId], [Snapshot]) VALUES (@Id, @AggregateRootId, @Event)", Pairs(@snapshot)); }
public static void PrintEvent(Event eventToPrint) { if (eventToPrint != null) { Output = eventToPrint + "\n"; } else { throw new ArgumentNullException("eventToPrint", "Parameter is null!"); } }
IEnumerable<KeyValuePair<string, object>> Pairs(Event @event) { yield return new KeyValuePair<string, object>("@Id", @event.Id); yield return new KeyValuePair<string, object>("@AggregateRootId", @event.AggregateRootId); var stream = new MemoryStream(); /* // this will convert the object to a byte array but there doesnt appear to be a way to convert the byte array back to an object var writer = new StreamWriter(stream); writer.Write(@event); writer.Flush(); var content = stream.GetBuffer(); */ new BinaryFormatter().Serialize(stream, @event); var content = stream.ToArray(); Console.WriteLine("content: " + content.Length + " | " + content); yield return new KeyValuePair<string, object>("@Event", content); }
/// <summary> /// Returns an Event from the Events table /// </summary> /// <param name="eventName"> Name of event </param> /// <param name="areaName"> Name of area event occurs in </param> /// <param name="eventChance"> Chance of event occuring </param> /// <param name="dbConnection"> Reuse dbConnection to save memory </param> /// <returns> An Event, passing it the dbconnection for it to fetch all information it needs </returns> public Events.Event GetEventByName(string eventName, string areaName, int eventChance, IDbConnection dbConnection) { using (IDbCommand dbcmd = dbConnection.CreateCommand()) { dbcmd.CommandText = "SELECT * FROM Events WHERE Name = '" + eventName + "'"; using (IDataReader reader = dbcmd.ExecuteReader()) { Events.Event newEvent = null; string[] eventInteractions = new string[5]; string[] eventSprites = new string[3]; string type = ""; string bgPackName = ""; int[] possibleBackgrounds = new int[4]; int progressAmount = 0; int specificBGSprite = -1; bool isLeavePossible = false; if (reader.Read()) { type = reader.GetString(3); progressAmount = reader.GetInt32(4); eventInteractions[0] = reader.GetString(5); eventInteractions[1] = reader.GetString(6); eventInteractions[2] = reader.GetString(7); eventInteractions[3] = reader.GetString(8); eventInteractions[4] = reader.GetString(9); isLeavePossible = reader.GetBoolean(10); bgPackName = reader.GetString(11); specificBGSprite = reader.GetInt32(12); eventSprites[0] = reader.GetString(13); eventSprites[1] = reader.GetString(14); eventSprites[2] = reader.GetString(15); newEvent = new Events.Event(eventName, areaName, type, eventChance, progressAmount, eventInteractions, isLeavePossible, bgPackName, specificBGSprite, eventSprites, dbConnection); } else { Debug.LogError("Event " + eventName + " does not exist in the DB"); } return(newEvent); } } }
public HandlerNotRegisteredException(AggregateRoot aggregateRoot, Event @event) : this(aggregateRoot.GetType(), @event.GetType()) { }
public void Send(Event iEvent) { _channel.SendMessageTo(iEvent.Serialize(), _sendingEndPoint); }
public void ReceiveEvent(Event @event) { dispatcher.DispatchEvent(@event); }
/// <summary> /// This method needs to be integrated into the main actor class. /// </summary> /// <param name="Event"></param> /// <returns>a bool value which tells the EventManager if the Event was successful or not!</returns> public virtual bool ProcessEvents(EventType EventType, Event Event) { List<string> methods = EventMethods[EventType]; bool Return = true; foreach (string method in methods) { object[] arguments = {Event}; Return = (bool)this.GetType().InvokeMember(method, System.Reflection.BindingFlags.InvokeMethod, null, this, arguments); } return Return; }
void HandleEvent(object sender, Event even) { Console.WriteLine("\nThis is how the event is handled:\n"); Console.WriteLine(this.name + " received this message: {0}", even.Message); }
public void TestEventToString2() { Event seminar = new Event(new DateTime(2013, 4, 9, 9, 0, 0), "Algorithms & Data Structures", string.Empty); Assert.AreEqual("2013-04-09T09:00:00 | Algorithms & Data Structures", seminar.ToString()); }
public void TestEventToString1() { Event seminar = new Event(new DateTime(2013, 4, 9, 10, 0, 0), "OOP", "Enterprise Hall"); Assert.AreEqual("2013-04-09T10:00:00 | OOP | Enterprise Hall", seminar.ToString()); }
public void TestEventConstructor3() { Event seminar = new Event(new DateTime(2013, 4, 9, 10, 0, 0), "JavaScript Part II", "Ultimate Hall"); Assert.AreEqual("Ultimate Hall", seminar.Location); }
public void TestEventConstructor2() { Event seminar = new Event(new DateTime(2013, 4, 9, 10, 0, 0), "Trees & Graphs", "Telerik Academy"); Assert.AreEqual("Trees & Graphs", seminar.Title); }
public void TestEventConstructor1() { Event seminar = new Event(new DateTime(2013, 4, 9, 10, 0, 0), "ASP.NET MVC", "Telerik Academy"); Assert.AreEqual("2013-04-09T10:00:00", seminar.DateAndTime.ToString("yyyy-MM-ddTHH:mm:ss")); }
public void TestEventConstructor() { Event game = new Event(new DateTime(2013, 04, 17, 18, 0, 0), "Football Game", "Stadium"); Assert.IsTrue(game.Location == "Stadium"); }
////TODO implement PrintEvent internal static void PrintEvent(Event eventToShow) { throw new NotImplementedException(); }
/// <summary> /// Hooks an event from any sender to the queue! /// </summary> /// <param name="EventType"></param> /// <param name="Event"></param> public void HookEvent(EventType EventType, Event Event) { if (Queue != null) { if (!Queue.ContainsKey(EventType)) Queue.Add(EventType, new List<Event>()); if (!Queue[EventType].Contains(Event)) Queue[EventType].Add(Event); } else { throw new Exception("Queue hasn't been initialized"); } }
internal void CallApply(Event @event) { Apply(@event); }