1 //
2 // Copyright (c) 2010-2018 Antmicro
3 // Copyright (c) 2011-2015 Realtime Embedded
4 //
5 // This file is licensed under the MIT License.
6 // Full license text is available in 'licenses/MIT.txt'.
7 //
8 using System.Collections.Generic;
9 
10 namespace Antmicro.Renode.Core.Structure
11 {
12     public interface IHasChildren<out T>
13     {
GetNames()14         IEnumerable<string> GetNames();
TryGetByName(string name, out bool success)15         T TryGetByName(string name, out bool success);
16     }
17 
18     public static class IHasChildrenHelper
19     {
TryGetByName(this IHasChildren<T> @this, string name, out T child)20         public static bool TryGetByName<T>(this IHasChildren<T> @this, string name, out T child)
21         {
22             bool success;
23             child = @this.TryGetByName(name, out success);
24             return success;
25         }
26     }
27 }
28 
29