Esempio n. 1
0
 // #example: Referential integrity
 private static void ReferentialIntegrityCheck(object sender,
                                               CancellableObjectEventArgs eventArguments)
 {
     object toDelete = eventArguments.Object;
     if (toDelete is Pilot)
     {
         IObjectContainer container = eventArguments.ObjectContainer();
         IEnumerable<Car> cars = from Car c in container
                                 where c.Pilot == toDelete
                                 select c;
         if (cars.Count() > 0)
         {
             eventArguments.Cancel();
         }
     }
 }
Esempio n. 2
0
			void OnCreating(object sender, CancellableObjectEventArgs args)
			{
				_events.Add("Creating");
				Assert.IsFalse(args.IsCancelled);
				args.Cancel();
			}
Esempio n. 3
0
		private void OnActivating(object sender, CancellableObjectEventArgs args)
		{
			if (_doNotActivateTypes.Contains(sender.GetType()))
			{
				args.Cancel();
			}
		}