protected Element FindElement string id try if queueSearch Count Eleme

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
protected Element FindElement(string id)
{
try
{
if (queueSearch.Count > 0)
{
Element elem = queueSearch.Dequeue();
switch (elem.Type)
{
case ElementType.Partner:
Partner _partner = elem as Partner;
foreach (KeyValuePair<string, Element> pair in _partner.UnionCollection)
{
if (pair.Key.Equals(id)) return pair.Value;
// localQueueSearch.Enqueue(((Union)pair.Value).StepCollection);
queueSearch.Enqueue(pair.Value);
}
foreach (KeyValuePair<string, Element> pair in _partner.StepCollection)
{
if (pair.Key.Equals(id)) return pair.Value;
}
foreach (KeyValuePair<string, Element> pair in _partner.ScopeCollection)
{
if (pair.Key.Equals(id)) return pair.Value;
queueSearch.Enqueue(pair.Value);
}
break;
case ElementType.Union:
Union _union = elem as Union;
foreach (KeyValuePair<string, Element> pair in _union.StepCollection)
{
if (pair.Key.Equals(id)) return pair.Value;
}
foreach (KeyValuePair<string, Element> pair in _union.UnionCollection)
{
if (pair.Key.Equals(id)) return pair.Value;
queueSearch.Enqueue(pair.Value);
}
break;
case ElementType.Scope:
Scope _scope = elem as Scope;
foreach (KeyValuePair<string, Element> pair in _scope.DataCollection)
{
if (pair.Key.Equals(id)) return pair.Value;
}
foreach (KeyValuePair<string, Element> pair in _scope.ResourceCollection)
{
if (pair.Key.Equals(id)) return pair.Value;
}
break;
}
return FindElement(id);
}
}
catch (Exception ex)
{
ManageException.LogException(ex, "FindElement(...) in Element");
}
return null;
}