using HBLConsole.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HBLConsole.Attributes
{
[AttributeUsage(AttributeTargets.Property)]
public class CircuitAttribute : Attribute
{
///
/// 流程属性特性
///
/// 字符串数组格式,属于哪一个业务流程
/// 属性说明
/// 布尔数组,是否对结果取反
public CircuitAttribute(string[] classification, string propertyIllustrate, bool[] isNot)
{
Classifiaction = classification;
PropertyIllustrate = propertyIllustrate;
int index = -1;
foreach (var item in classification)
{
index++;
if (!ProcessData.GetInstance.Conditions.ContainsKey(item))
{
ProcessData.GetInstance.Conditions.TryAdd(item, new List());
}
if (ProcessData.GetInstance.Conditions[item].FirstOrDefault(p => p.propertyIllustrate == propertyIllustrate) == null)
{
ProcessData.GetInstance.Conditions[item].Add(new Condition() { propertyIllustrate = propertyIllustrate, IsNot = isNot[index] });
}
}
}
///
/// 流程属性特性
///
/// 字符串数组格式,属于哪一个业务流程
/// 属性说明
public CircuitAttribute(string[] classification, string propertyIllustrate)
{
Classifiaction = classification;
PropertyIllustrate = propertyIllustrate;
foreach (var item in classification)
{
if (!ProcessData.GetInstance.Conditions.ContainsKey(item))
{
ProcessData.GetInstance.Conditions.TryAdd(item, new List());
}
if (ProcessData.GetInstance.Conditions[item].FirstOrDefault(p => p.propertyIllustrate == propertyIllustrate) == null)
{
ProcessData.GetInstance.Conditions[item].Add(new Condition() { propertyIllustrate = propertyIllustrate });
}
}
}
///
/// 流程属性特性
///
/// 业务流程名称
/// 属性说明
/// 是否对结果取反
public CircuitAttribute(string classification, string propertyIllustrate, bool isNot = false)
{
Classifiaction = new string[1] { classification };
PropertyIllustrate = propertyIllustrate;
if (!ProcessData.GetInstance.Conditions.ContainsKey(classification))
{
ProcessData.GetInstance.Conditions.TryAdd(classification, new List());
}
if (ProcessData.GetInstance.Conditions[classification].FirstOrDefault(p => p.propertyIllustrate == propertyIllustrate) == null)
{
ProcessData.GetInstance.Conditions[classification].Add(new Condition() { propertyIllustrate = propertyIllustrate, IsNot = isNot });
}
}
///
/// 分类主题集合
///
public string[] Classifiaction { get; set; } = new string[0];
///
/// 属性说明
///
public string PropertyIllustrate { get; set; }
}
}