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

17 lines
498 B
C#

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);
}