1using System.Reflection;
63 public void AddRange(IEnumerable<Widget> widgets) {
64 foreach (
Widget widget
in widgets) {
75 throw new InvalidOperationException(
"Widget index out of range.");
84 int num =
m_widgets.IndexOf(beforeWidget);
86 throw new InvalidOperationException(
"Widget not present in container.");
94 throw new InvalidOperationException(
"Widget not present in container.");
109 throw new InvalidOperationException(
"Widget index out of range.");
128 public Widget Find(
string name, Type type,
bool throwIfNotFound =
true) {
130 if ((name ==
null || (widget2.
Name !=
null && widget2.
Name == name))
131 && (type ==
null || type == widget2.GetType() || widget2.GetType().GetTypeInfo().IsSubclassOf(type))) {
135 Widget widget = containerWidget.Children.Find(name, type,
false);
136 if (widget !=
null) {
141 if (throwIfNotFound) {
142 throw new Exception($
"Required widget \"{name}\" of type \"{type}\" not found.");
147 public Widget Find(
string name,
bool throwIfNotFound =
true) =>
Find(name,
null, throwIfNotFound);
149 public T
Find<T>(
string name,
bool throwIfNotFound =
true) where T : class =>
Find(name, typeof(T), throwIfNotFound) as T;
151 public T
Find<T>(
bool throwIfNotFound = true) where T : class =>
Find(null, typeof(T), throwIfNotFound) as T;