Innovenergy_trunk/csharp/app/API/DataModel/DataElement.Extensions.cs

17 lines
498 B
C#
Raw Normal View History

2023-02-16 12:57:06 +00:00
namespace InnovEnergy.API.DataModel;
public static class DataElementExtensions
{
public static IEnumerable<DataElement> GetChildren(this DataElement de)
{
return de switch
{
Folder f => f.Folders.Concat<DataElement>(f.Installations).Concat(f.Users),
Installation i => i.Users,
_ => Enumerable.Empty<DataElement>()
};
}
public static Path RelativePath(this DataElement root) => new Path(null, root);
}