.NET Decompiler with support for PDB generation, ReadyToRun, Metadata (&more) - cross-platform!
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

34 lines
849 B

// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System.Collections.Generic;
using System.Linq;
using System.Windows.Media;
using System.Windows;
using System.Collections;
namespace ICSharpCode.TreeView
{
static class ExtensionMethods
{
public static T FindAncestor<T>(this DependencyObject d) where T : class
{
return AncestorsAndSelf(d).OfType<T>().FirstOrDefault();
}
public static IEnumerable<DependencyObject> AncestorsAndSelf(this DependencyObject d)
{
while (d != null) {
yield return d;
d = VisualTreeHelper.GetParent(d);
}
}
public static void AddOnce(this IList list, object item)
{
if (!list.Contains(item)) {
list.Add(item);
}
}
}
}