Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class UnitXmlConstructor : IEntityXmlConstructor
- {
- private readonly IHandbooksService _handbooksService;
- public UnitXmlConstructor(IHandbooksService handbooksService)
- {
- _handbooksService = handbooksService;
- }
- public async Task<XElement> Construct(string id)
- {
- var units = _handbooksService.GetUnitsList(0, -1, null);
- var unit = units.Data.FirstOrDefault(c => c.Code == id);
- return new XElement("root",
- new XAttribute("Code", unit?.Code ?? ""),
- new XAttribute("Name", unit?.UnitName ?? ""));
- }
- }
- public class BoolXmlConstructor : IEntityXmlConstructor
- {
- public BoolXmlConstructor()
- {
- }
- public async Task<XElement> Construct(string value, object parameter)
- {
- bool logicValue = false;
- bool.TryParse(value, out logicValue);
- return new XElement("root",
- new XText(logicValue ? parameter?.ToString() ?? "" : ""));
- }
- }
Add Comment
Please, Sign In to add comment