-
Notifications
You must be signed in to change notification settings - Fork 58
/
Copy pathControlsService.cs
34 lines (29 loc) · 1.07 KB
/
ControlsService.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
using System.Collections.Generic;
using System.Linq;
using Microsoft.Maui.Controls;
using QSF.Common;
namespace QSF.Services
{
/// <summary>
/// The ControlsService is responsible for managing the controls section in the app.
/// </summary>
public class ControlsService : IControlsService
{
public IEnumerable<Control> GetAllControls()
{
IConfigurationService configurationService = DependencyService.Get<IConfigurationService>();
var controls = configurationService.GetControlsConfiguration().OrderBy(p => p.DisplayName);
return controls;
}
public Control GetControlByName(string controlName)
{
var controls = this.GetAllControls();
return controls.Where(p => p.Name == controlName).FirstOrDefault();
}
public Example GetControlExample(string controlName, string exampleName)
{
var control = this.GetControlByName(controlName);
return control.Examples.Where(p => p.Name == exampleName).FirstOrDefault();
}
}
}