Files
Cpp2IL/SharpTreeView/ExtensionMethods.cs
Sam Byass b6f5e008ac A bunch of stuff:
- Ported WASM remapper from stable branch
- Added a function to check metadata header
- Added a skeleton for a GUI
- Update dependencies
2022-01-17 09:03:01 +00:00

35 lines
816 B
C#

// 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;
using System.Collections;
using System.Linq;
using Avalonia.VisualTree;
namespace ICSharpCode.TreeView
{
static class ExtensionMethods
{
public static T FindAncestor<T>(this IVisual d) where T : class
{
return d.GetVisualAncestors().OfType<T>().FirstOrDefault();
}
public static void AddOnce(this IList list, object item)
{
if (!list.Contains(item)) {
list.Add(item);
}
}
public static bool Any(this IEnumerable list)
{
var enumerator = list.GetEnumerator();
var result = enumerator.MoveNext();
(enumerator as IDisposable)?.Dispose();
return result;
}
}
}