Group.fs 1.3 KB

123456789101112131415161718192021222324252627282930
  1. namespace FSharp.Data.Tdms
  2. type Group =
  3. { Name: string
  4. Properties: Property seq
  5. Channels: Channel seq }
  6. module Group =
  7. let tryGetPropertyValue<'t> propertyName ({ Properties = properties }: Group) =
  8. properties
  9. |> Seq.tryFind (fun { Name = propertyName' } -> propertyName' = propertyName)
  10. |> Option.bind Property.tryGet<'t>
  11. let getPropertyValue<'t> propertyName =
  12. tryGetPropertyValue<'t> propertyName >> Option.get
  13. /// <summary>Finds the <see cref="Channel" /> with the given name within the <see cref="Group" />. Returns None if it does not exist.</summary>
  14. /// <param name="channelName">the name of the <see cref="Channel" /> to get.</param>
  15. let tryFindChannel channelName { Channels = channels } =
  16. channels
  17. |> Seq.tryFind (fun { Name = channelName' } -> channelName = channelName')
  18. /// <summary>Finds the <see cref="Channel" /> with the given name within the <see cref="Group" />.</summary>
  19. /// <param name="channelName">the name of the <see cref="Channel" /> to get.</param>
  20. let findChannel channelName =
  21. tryFindChannel channelName >> Option.get
  22. /// <summary>Returns all channels within the <see cref="Group" />.</summary>
  23. let getChannels { Channels = channels } = channels