本文整理匯總了C#中Activity.SetPropertyValue方法的典型用法代碼示例。如果您正苦於以下問題:C# Activity.SetPropertyValue方法的具體用法?C# Activity.SetPropertyValue怎麽用?C# Activity.SetPropertyValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Activity
的用法示例。
在下文中一共展示了Activity.SetPropertyValue方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: SafeAddActivity
///// <summary>
///// 添加或修改活動
///// </summary>
///// <param name="activity"></param>
//public void SafeAddActivity(Activity activity)
//{
// if (this.Activities == null)
// {
// this.Activities = new List<Activity>();
// }
// Activity old = Activities.FirstOrDefault(a => a.ID == activity.ID);
// if (old != null)
// {
// this.Activities.Remove(old);
// }
// //if (activity.Parent != this)
// //{
// // activity.Parent = this;
// //}
// this.Activities.Add(activity);
// this.Transitions.ForEach(a =>
// {
// if (a.SrcActivity.ID == activity.ID)
// {
// a.SrcActivity = activity;
// }
// if (a.DestActivity.ID == activity.ID)
// {
// a.DestActivity = activity;
// }
// });
//}
/// <summary>
/// 添加或修改活動
/// </summary>
/// <param name="oldActivityID"></param>
/// <param name="activity"></param>
public void SafeAddActivity(string oldActivityID, Activity activity)
{
if (this.Activities == null)
{
this.Activities = new List<Activity>();
}
ProcessDefine parent = activity.GetPropertyValue<ProcessDefine>("Parent");
if (parent == null)
{
activity.SetPropertyValue("Parent", this);
}
this.Transitions.ForEach(a =>
{
if (a.SrcActivity == oldActivityID)
{
a.SrcActivity = activity.ID;
}
if (a.DestActivity == oldActivityID)
{
a.DestActivity = activity.ID;
}
});
int index = -1;
for (int i = 0; i < Activities.Count; i++)
{
if (Activities[i].ID == oldActivityID)
{
index = i;
break;
}
}
if (index != -1)
{
activity.Style = Activities[index].Style;
Activities.RemoveAt(index);
Activities.Insert(index, activity);
}
else
{
Activities.Add(activity);
}
}