summaryrefslogtreecommitdiff
path: root/Gestor.Common/Gestor.Common.Helpers/FindVisualChildren.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Gestor.Common/Gestor.Common.Helpers/FindVisualChildren.cs')
-rw-r--r--Gestor.Common/Gestor.Common.Helpers/FindVisualChildren.cs195
1 files changed, 195 insertions, 0 deletions
diff --git a/Gestor.Common/Gestor.Common.Helpers/FindVisualChildren.cs b/Gestor.Common/Gestor.Common.Helpers/FindVisualChildren.cs
new file mode 100644
index 0000000..5b88c0d
--- /dev/null
+++ b/Gestor.Common/Gestor.Common.Helpers/FindVisualChildren.cs
@@ -0,0 +1,195 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Runtime.CompilerServices;
+using System.Windows;
+using System.Windows.Media;
+
+namespace Gestor.Common.Helpers;
+
+public class FindVisualChildren
+{
+ [CompilerGenerated]
+ private sealed class _003CFind_003Ed__0<T> : IEnumerable<T>, IEnumerable, IEnumerator<T>, IDisposable, IEnumerator where T : DependencyObject
+ {
+ private int _003C_003E1__state;
+
+ private T _003C_003E2__current;
+
+ private int _003C_003El__initialThreadId;
+
+ private DependencyObject depObj;
+
+ public DependencyObject _003C_003E3__depObj;
+
+ private int _003Ci_003E5__2;
+
+ private DependencyObject _003Cchild_003E5__3;
+
+ private IEnumerator<T> _003C_003E7__wrap3;
+
+ T IEnumerator<T>.Current
+ {
+ [DebuggerHidden]
+ get
+ {
+ return _003C_003E2__current;
+ }
+ }
+
+ object IEnumerator.Current
+ {
+ [DebuggerHidden]
+ get
+ {
+ return _003C_003E2__current;
+ }
+ }
+
+ [DebuggerHidden]
+ public _003CFind_003Ed__0(int _003C_003E1__state)
+ {
+ this._003C_003E1__state = _003C_003E1__state;
+ _003C_003El__initialThreadId = Environment.CurrentManagedThreadId;
+ }
+
+ [DebuggerHidden]
+ void IDisposable.Dispose()
+ {
+ int num = _003C_003E1__state;
+ if (num == -3 || num == 2)
+ {
+ try
+ {
+ }
+ finally
+ {
+ _003C_003Em__Finally1();
+ }
+ }
+ _003Cchild_003E5__3 = null;
+ _003C_003E7__wrap3 = null;
+ _003C_003E1__state = -2;
+ }
+
+ private bool MoveNext()
+ {
+ try
+ {
+ switch (_003C_003E1__state)
+ {
+ default:
+ return false;
+ case 0:
+ _003C_003E1__state = -1;
+ if (depObj == null)
+ {
+ break;
+ }
+ _003Ci_003E5__2 = 0;
+ goto IL_0107;
+ case 1:
+ _003C_003E1__state = -1;
+ goto IL_0090;
+ case 2:
+ {
+ _003C_003E1__state = -3;
+ goto IL_00d6;
+ }
+ IL_0107:
+ if (_003Ci_003E5__2 >= VisualTreeHelper.GetChildrenCount(depObj))
+ {
+ break;
+ }
+ _003Cchild_003E5__3 = VisualTreeHelper.GetChild(depObj, _003Ci_003E5__2);
+ if (_003Cchild_003E5__3 != null && _003Cchild_003E5__3 is T)
+ {
+ _003C_003E2__current = (T)(object)_003Cchild_003E5__3;
+ _003C_003E1__state = 1;
+ return true;
+ }
+ goto IL_0090;
+ IL_0090:
+ _003C_003E7__wrap3 = Find<T>(_003Cchild_003E5__3).GetEnumerator();
+ _003C_003E1__state = -3;
+ goto IL_00d6;
+ IL_00d6:
+ if (_003C_003E7__wrap3.MoveNext())
+ {
+ T current = _003C_003E7__wrap3.Current;
+ _003C_003E2__current = current;
+ _003C_003E1__state = 2;
+ return true;
+ }
+ _003C_003Em__Finally1();
+ _003C_003E7__wrap3 = null;
+ _003Cchild_003E5__3 = null;
+ _003Ci_003E5__2++;
+ goto IL_0107;
+ }
+ return false;
+ }
+ catch
+ {
+ //try-fault
+ ((IDisposable)this).Dispose();
+ throw;
+ }
+ }
+
+ bool IEnumerator.MoveNext()
+ {
+ //ILSpy generated this explicit interface implementation from .override directive in MoveNext
+ return this.MoveNext();
+ }
+
+ private void _003C_003Em__Finally1()
+ {
+ _003C_003E1__state = -1;
+ if (_003C_003E7__wrap3 != null)
+ {
+ _003C_003E7__wrap3.Dispose();
+ }
+ }
+
+ [DebuggerHidden]
+ void IEnumerator.Reset()
+ {
+ throw new NotSupportedException();
+ }
+
+ [DebuggerHidden]
+ IEnumerator<T> IEnumerable<T>.GetEnumerator()
+ {
+ _003CFind_003Ed__0<T> _003CFind_003Ed__;
+ if (_003C_003E1__state == -2 && _003C_003El__initialThreadId == Environment.CurrentManagedThreadId)
+ {
+ _003C_003E1__state = 0;
+ _003CFind_003Ed__ = this;
+ }
+ else
+ {
+ _003CFind_003Ed__ = new _003CFind_003Ed__0<T>(0);
+ }
+ _003CFind_003Ed__.depObj = _003C_003E3__depObj;
+ return _003CFind_003Ed__;
+ }
+
+ [DebuggerHidden]
+ IEnumerator IEnumerable.GetEnumerator()
+ {
+ return ((IEnumerable<T>)this).GetEnumerator();
+ }
+ }
+
+ [IteratorStateMachine(typeof(_003CFind_003Ed__0<>))]
+ public static IEnumerable<T> Find<T>(DependencyObject depObj) where T : DependencyObject
+ {
+ //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
+ return new _003CFind_003Ed__0<T>(-2)
+ {
+ _003C_003E3__depObj = depObj
+ };
+ }
+}