internal FunctionalEvent(string name, FunctionalStrategy functionalStretegy, Type handlerType, Type ownerType) { Name = name; FunctionalStretegy = functionalStretegy; HandlerType = handlerType; OwnerType = ownerType; EventTracer = new FunctionalEventTracer(); }
public static FunctionalEvent RegisterEvent(string name, FunctionalStrategy functionalStrategy, Type handlerType, Type ownerType) { return Instance.RegisterEventInternal(name, functionalStrategy, handlerType, ownerType); }
/// <summary> /// Registers a new functional event. /// </summary> /// <param name="name">The name of the functional event. The name must be unique within the owner type and cannot be null or an empty string.</param> /// <param name="functionalStretegy">The functional strategy of the event as a value of the enumeration.</param> /// <param name="handlerType">The type of the event handler. This must be a delegate type and cannot be null.</param> /// <param name="ownerType">The owner class type of the routed event. This cannot be null.</param> private FunctionalEvent RegisterEventInternal(string name, FunctionalStrategy functionalStrategy, Type handlerType, Type ownerType) { if (String.IsNullOrEmpty(name)) throw new ArgumentNullException("name", "name is null."); if (handlerType == null) throw new ArgumentNullException("handlerType", "handlerType is null."); if (ownerType == null) throw new ArgumentNullException("ownerType", "ownerType is null."); if (FunctionalEventsInternal.ContainsKey(ownerType)) { if (FunctionalEventsInternal[ownerType].Any(cur => cur.Name == name)) throw new ArgumentException(String.Format("RoutedEvent Name '{0}' for OwnerType '{1}' already used.", name, ownerType)); } FunctionalEvent functionalEvent = new FunctionalEvent(name, functionalStrategy, handlerType, ownerType); if (!FunctionalEventsInternal.ContainsKey(ownerType)) FunctionalEventsInternal[ownerType] = new List<FunctionalEvent>(); FunctionalEventsInternal[ownerType].Add(functionalEvent); return functionalEvent; }
public void RaiseEvent(FunctionalStrategy eventStrategy) { if (eventStrategy == FunctionalStrategy.Bubble) this.RaiseFunctionalEvent(new FunctionalEventArgs(BubblingTestEvent)); else if (eventStrategy == FunctionalStrategy.Tunnel) this.RaiseFunctionalEvent(new FunctionalEventArgs(TunnelingTestEvent)); else if (eventStrategy == FunctionalStrategy.Parent) this.RaiseFunctionalEvent(new FunctionalEventArgs(ParentTestEvent)); else if (eventStrategy == FunctionalStrategy.Children) this.RaiseFunctionalEvent(new FunctionalEventArgs(ChildrenTestEvent)); else if (eventStrategy == FunctionalStrategy.Siblings) this.RaiseFunctionalEvent(new FunctionalEventArgs(SiblingsTestEvent)); else if (eventStrategy == FunctionalStrategy.Descendents) this.RaiseFunctionalEvent(new FunctionalEventArgs(DescendentsTestEvent)); else if (eventStrategy == FunctionalStrategy.Spread) this.RaiseFunctionalEvent(new FunctionalEventArgs(SpreadTestEvent)); }