public string RegisterHost(Host host) { HashPass hashedPass = new HashPass(); string pass = HashPass.HashPassword(host.PASS); using (EventrixDBDataContext dbd = new EventrixDBDataContext()) { try { int MailChecker = (from eh in dbd.EventHosts where eh.Email.Equals(host.EMAIL) select eh).Count(); if (MailChecker == 0) { EventHost _host = new EventHost(); _host.Name = host.NAME; _host.Email = host.EMAIL; _host.Surname = host.SURNAME; _host.Password = pass; dbd.EventHosts.InsertOnSubmit(_host); dbd.SubmitChanges(); return("Registered " + _host.Name + "successfully"); } else { return("Error: Account already taken"); } } catch (Exception e) { return(e.GetBaseException().ToString()); } }; }
static CellView() { EventHost.MapEvent(WidgetEvent.KeyPressed, typeof(CellView), "OnKeyPressed"); EventHost.MapEvent(WidgetEvent.KeyReleased, typeof(CellView), "OnKeyReleased"); EventHost.MapEvent(WidgetEvent.MouseEntered, typeof(CellView), "OnMouseEntered"); EventHost.MapEvent(WidgetEvent.MouseExited, typeof(CellView), "OnMouseExited"); EventHost.MapEvent(WidgetEvent.ButtonPressed, typeof(CellView), "OnButtonPressed"); EventHost.MapEvent(WidgetEvent.ButtonReleased, typeof(CellView), "OnButtonReleased"); EventHost.MapEvent(WidgetEvent.MouseMoved, typeof(CellView), "OnMouseMoved"); }
public void can_listen_to_base_events() { var host = new EventHost(); host.Listen <BaseEvent>(typeof(BaseEventHandler)); var @event = new DerivedEvent(); host.Raise(@event, null); Assert.Equal(1, @event.Value); }
private EventHost <TEvent> GetOrAddSubject <TEvent>() where TEvent : IEvent { object subjectObj; if (!_subjects.TryGetValue(typeof(TEvent), out subjectObj)) { var subject = new EventHost <TEvent>(); _subjects.GetOrAdd(typeof(TEvent), subject); subjectObj = subject; } return((EventHost <TEvent>)subjectObj); }
public void can_listen_to_event_interfaces() { var host = new EventHost(); host.Listen <IEvent>(typeof(AllEventHandler)); var @event = new BaseEvent(); host.Raise(@event, null); Assert.Equal(5, @event.Value); @event = new DerivedEvent(); host.Raise(@event, null); Assert.Equal(5, @event.Value); }
public void can_register_hanlder_type() { var host = new EventHost(); host.Listen <MyEvent>(typeof(MyEventHandlerWithStaticValue)); host.Raise(new MyEvent { Value = 16 }, null); Assert.Equal(16, MyEventHandlerWithStaticValue.Value); host.Raise(new MyEvent { Value = 3 }, null); Assert.Equal(19, MyEventHandlerWithStaticValue.Value); }
public void TestAttachAndDetach() { var h = new EventHost (); Assert.IsFalse (h.HasStandardEvent, "#1"); var source = Observable.FromEventPattern<EventArgs> (h, "StandardEvent"); Assert.IsFalse (h.HasStandardEvent, "#2"); // not subscribed yet bool received = false; var dis = source.Subscribe (v => received = true); Assert.IsTrue (h.HasStandardEvent, "#3"); Assert.IsFalse (received, "#4"); h.FireStandardEvent (); Assert.IsTrue (received, "#5"); dis.Dispose (); // unsubscribe event handler Assert.IsFalse (h.HasStandardEvent, "#6"); }
public void TestAttachAndDetach3() { var h = new EventHost (); Assert.IsFalse (h.HasMyEvent2, "#1"); string value = null; // FromEvent<TDelegate,TEventArgs> (Func<TDelegate> addHandler, Func<TDelegate> removeHandler) var source = Observable.FromEvent<MyEventHandler2, MyEventArgs> ( ev => h.MyEvent2 += ev, ev => h.MyEvent2 -= ev); Assert.IsFalse (h.HasMyEvent2, "#2"); // not subscribed yet var dis = source.Subscribe (v => value = v.Value); Assert.IsTrue (h.HasMyEvent2, "#3"); h.FireMyEvent2 ("foo"); Assert.AreEqual ("foo", value, "#4"); dis.Dispose (); // unsubscribe event handler Assert.IsFalse (h.HasMyEvent2, "#6"); }
public void can_register_handler_instance() { var host = new EventHost(); var handler = new MyEventHandler(); host.Listen <MyEvent>(handler); host.Raise(new MyEvent { Value = 6 }, null); Assert.Equal(6, handler.Value); host.Raise(new MyEvent { Value = 7 }, null); Assert.Equal(13, handler.Value); }
public void TestAttachAndDetach() { var h = new EventHost(); Assert.IsFalse(h.HasStandardEvent, "#1"); var source = Observable.FromEventPattern <EventArgs> (h, "StandardEvent"); Assert.IsFalse(h.HasStandardEvent, "#2"); // not subscribed yet bool received = false; var dis = source.Subscribe(v => received = true); Assert.IsTrue(h.HasStandardEvent, "#3"); Assert.IsFalse(received, "#4"); h.FireStandardEvent(); Assert.IsTrue(received, "#5"); dis.Dispose(); // unsubscribe event handler Assert.IsFalse(h.HasStandardEvent, "#6"); }
public void TestAttachAndDetach3() { var h = new EventHost(); Assert.IsFalse(h.HasMyEvent2, "#1"); string value = null; // FromEvent<TDelegate,TEventArgs> (Func<TDelegate> addHandler, Func<TDelegate> removeHandler) var source = Observable.FromEvent <MyEventHandler2, MyEventArgs> ( ev => h.MyEvent2 += ev, ev => h.MyEvent2 -= ev); Assert.IsFalse(h.HasMyEvent2, "#2"); // not subscribed yet var dis = source.Subscribe(v => value = v.Value); Assert.IsTrue(h.HasMyEvent2, "#3"); h.FireMyEvent2("foo"); Assert.AreEqual("foo", value, "#4"); dis.Dispose(); // unsubscribe event handler Assert.IsFalse(h.HasMyEvent2, "#6"); }
public bool deleteHost(Host _host) { using (EventrixDBDataContext mde = new EventrixDBDataContext()) { try { int _id = Convert.ToInt32(_host.ID); EventHost pe = mde.EventHosts.Single(p => p.EH_ID == _id); //mde.EventHosts.Remove(pe); //mde.SaveChanges(); mde.EventHosts.DeleteOnSubmit(pe); mde.SubmitChanges(); return(true); } catch { return(false); } }; }
public bool editHost(Host _host) { using (EventrixDBDataContext mde = new EventrixDBDataContext()) { try { int _id = Convert.ToInt32(_host.ID); EventHost pe = mde.EventHosts.Single(p => p.EH_ID == _id); pe.Name = _host.NAME; pe.Surname = _host.SURNAME; pe.Email = _host.EMAIL; // mde.SaveChanges(); mde.EventHosts.InsertOnSubmit(pe); mde.SubmitChanges(); return(true); } catch { return(false); } }; }
public void can_register_action() { var host = new EventHost(); var value = 0; host.Listen <MyEvent>((@event, instance) => { value += @event.Value; }); Assert.Equal(0, value); host.Raise(new MyEvent { Value = 5 }, null); Assert.Equal(5, value); host.Raise(new MyEvent { Value = 3 }, null); Assert.Equal(8, value); }
public bool createHost(Host _host) { using (EventrixDBDataContext mde = new EventrixDBDataContext()) { try { EventHost pe = new EventHost(); pe.Name = _host.NAME; pe.Surname = _host.SURNAME; pe.Email = _host.EMAIL; pe.Password = _host.PASS; mde.EventHosts.InsertOnSubmit(pe); mde.SubmitChanges(); // mde.EventHosts.Add(pe); // mde.SaveChanges(); return(true); } catch { return(false); } }; }
public static void Raise <T>(T args) where T : IDomainEvent { EventHost <T> .DoRaise(args); }
private static void Initialize() { DataPortal.Dispose(); EventHost.EnableEvent("NodeEvent0"); }
/// <summary> /// Maps an event handler of an Xwt component to an event identifier. /// </summary> /// <param name="eventId">The event identifier (must be valid event enum value /// like <see cref="Xwt.Backends.WidgetEvent"/>, identifying component specific events).</param> /// <param name="type">The Xwt component type.</param> /// <param name="methodName">The <see cref="System.Reflection.MethodInfo.Name"/> of the event handler.</param> protected static void MapEvent(object eventId, Type type, string methodName) { EventHost.MapEvent(eventId, type, methodName); }
public ActionResult Edit([Bind(Include = "Id,InvitationFrom,Greeting,FullName,Email")] int Id, EventHost InvitationFrom, string Greeting, string FullName, string Email, string selections) { Guest guest = db.Guests.Include(i => i.Invitations).Single(i => i.Id == Id); try { if (ModelState.IsValid) { guest.UpdatedDate = DateTime.Now; guest.InvitationFrom = InvitationFrom; guest.Greeting = Greeting; guest.FullName = FullName; guest.Email = Email; if (!string.IsNullOrEmpty(selections)) { string[] invitationSelections = selections.Split(','); UpdateAssignedInvitations(guest, invitationSelections); } db.Guests.Attach(guest); db.Entry(guest).State = EntityState.Modified; db.SaveChanges(); PopulateAssignedInvitations(guest); return RedirectToAction("Index"); } } catch (Exception ex) { ModelState.AddModelError("", ex); } PopulateAssignedInvitations(guest); return View(guest); }
private static void Initialize() { EventHost.EnableEvent("NodeEvent4"); }
public void Raise <T>(T args) where T : IEvent { EventHost <T> .DoRaise(args); }