123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- /*-------------------------------------------------------------------------
- * 功能描述: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
- {
- /// <summary>
- /// revit事件处理接口
- /// </summary>
- public interface IRevitEventHandler
- {
- void Execute(object sender, EventArgs args);
- }
- public class RevitEvent: IRevitEventHandler
- {
- /// <summary>
- /// 事件名称
- /// </summary>
- public string Name { get; set; }
- /// <summary>
- /// 关联实际处理类型
- /// </summary>
- private List<IRevitEventHandler> Handlers { get; set; }
- public void AddHandler(IRevitEventHandler handler)
- {
- if (handler == null)
- return;
- if (Handlers == null)
- Handlers = new List<IRevitEventHandler>();
- Handlers.Add(handler);
- }
- public event EventHandler<EventArgs> 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);
- }
- }
- }
|