/*------------------------------------------------------------------------- * 功能描述:ExportInstance * 作者:xulisong * 创建时间: 2019/6/13 14:46:48 * 版本号:v1.0 * -------------------------------------------------------------------------*/ using System; using System.Collections.Generic; namespace RevitExport.Export { /* * 使用event形式,将Export和Parse关联断开 */ /// /// 导出实例 /// public class ExportInstance { public ExportInstance(List elements) { ExportElements = elements ?? new List(); } /// /// 待导出元素 /// private List ExportElements { get; set; } #region 导出逻辑相关 public bool Export() { if (ExportElements == null) return false; for (int i = 0; i < ExportElements.Count; i++) { if (IsCancel) return false; ElementWrapper revitElementWrapper = ExportElements[i]; ParseElement?.Invoke(this, new ExportArgs(revitElementWrapper)); ProcessChanged?.Invoke(i + 1); } return true; } /// /// 是否取消 /// public bool IsCancel { get; set; } public event EventHandler ParseElement; public event Action ProcessChanged; #endregion } public class ExportArgs : EventArgs { public ExportArgs(ElementWrapper elementWrapper) { ElementWrapper = elementWrapper; } public ElementWrapper ElementWrapper { get; private set; } } }