/*------------------------------------------------------------------------- * 功能描述:IRevitEventHandler * 作者:xulisong * 创建时间: 2019/1/7 12:59:33 * 版本号:v1.0 * -------------------------------------------------------------------------*/ using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace FWindSoft.Revit { /// /// revit事件处理接口 /// public interface IRevitEventHandler { void Execute(object sender, EventArgs args); } public class RevitEvent: IRevitEventHandler { /// /// 事件名称 /// public string Name { get; set; } /// /// 关联实际处理类型 /// private List Handlers { get; set; } public void AddHandler(IRevitEventHandler handler) { if (handler == null) return; if (Handlers == null) Handlers = new List(); Handlers.Add(handler); } public event EventHandler Handler; public void Execute(object sender, EventArgs args) { if (Handlers == null||!Handlers.Any()) return; foreach (var revitEventHandler in Handlers) { revitEventHandler.Execute(sender, args); } Handler?.Invoke(sender, args); } } }