namespace HStation.Service
{
///
/// Revit组件拓展
///
internal static class RevitParterExtensions
{
///
/// 获取属性状态
///
public static HStation.Model.RevitPropStatus GetPropStatus(this HStation.Model.RevitParter parter, string propName)
{
if (string.IsNullOrEmpty(propName))
{
return default;
}
var propStatus = parter.PropStatusList?.Find(x => x.PropName == propName);
return propStatus;
}
///
/// 是否存在属性状态
///
public static bool IsExistPropStatus(this HStation.Model.RevitParter parter, string propName)
{
if (string.IsNullOrEmpty(propName))
{
return false;
}
if (parter.PropStatusList == null || parter.PropStatusList.Count < 1)
{
return false;
}
return parter.PropStatusList.Exists(x => x.PropName == propName);
}
///
/// 添加或者更新属性状态
///
public static bool AppendOrUpdatePropStatus(this HStation.Model.RevitParter parter, string propName, ePropStatus propStatus, string statusInfo)
{
if (parter == null)
{
return false;
}
if (string.IsNullOrEmpty(propName))
{
return false;
}
if (parter.PropStatusList == null)
{
parter.PropStatusList = new List();
}
var propStatusModel = parter.GetPropStatus(propName);
if (propStatusModel == null)
{
propStatusModel = new Model.RevitPropStatus() { PropName = propName };
parter.PropStatusList.Add(propStatusModel);
}
propStatusModel.PropStatus = propStatus;
propStatusModel.StatusInfo = statusInfo;
return true;
}
}
}