|
using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Collections.Generic;
using System.Linq;
using DiagnosticExplorer.Silverlight.WebServices;
namespace DiagnosticExplorer.Silverlight.Util
{
public static class DiagFolderExtensions
{
const StringComparison _ignoreCase = StringComparison.CurrentCultureIgnoreCase;
public static IEnumerable<DiagItem> EnumerateAll(this DiagFolder folder)
{
yield return folder;
foreach (DiagProcess process in folder.Items.OfType<DiagProcess>())
yield return process;
foreach (DiagFolder child in folder.Items.OfType<DiagFolder>())
foreach (DiagItem item in EnumerateAll(child))
yield return item;
}
public static DiagProcess FindByUri(this IEnumerable<DiagItem> list, string uri)
{
return list.OfType<DiagProcess>().FirstOrDefault(x => string.Equals(x.Uri, uri, _ignoreCase));
}
public static T FindById<T>(this IEnumerable<T> list, string id) where T : DiagItem
{
return list.FirstOrDefault(x => string.Equals(x.Id, id, _ignoreCase));
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I am a software developer originally from Auckland, New Zealand. I have lived and worked in London since 2005.