Quantcast
Channel: DevNet Questions
Viewing all articles
Browse latest Browse all 8901

kentico12 form component DI implementation

$
0
0
Hi All,We had a custom drop-down component for widget and seems we cannot apply DI. Any suggestion on this?You can check below code. One argument Constructor is not working.public CustomDropDownComponent(ICustomDropdownComponentRepository _repo) { this.repo = _repo ?? new CustomDropDownComponentRepository(); }public class CustomDropDownComponent : SelectorFormComponent@CustomDropDownProperties@ { private ICustomDropdownComponentRepository repo; public CustomDropDownComponent() { } // below constructor is not working public CustomDropDownComponent(ICustomDropdownComponentRepository _repo) { this.repo = _repo ?? new CustomDropDownComponentRepository(); } protected override IEnumerable@SelectListItem@ GetItems() { objList = repo.GetSelectItems(); foreach (var item in objList) { var listItem = new SelectListItem() { Value = item.Value, Text = item.Key }; yield return listItem; } } } }

Viewing all articles
Browse latest Browse all 8901

Trending Articles