using Autofac;
|
using Bro.Common.Helper;
|
using Bro.Common.Interface;
|
using System.Collections;
|
using System.Collections.Generic;
|
using System.ComponentModel;
|
using System.Linq;
|
|
namespace Bro.Common.Model
|
{
|
public class DeviceSelectorConverter<T> : ComboBoxItemTypeConvert //where T : IDevice
|
{
|
public override Hashtable GetConvertHash(ITypeDescriptorContext context)
|
{
|
Hashtable table = new Hashtable();
|
using (var scope = GlobalVar.Container.BeginLifetimeScope())
|
{
|
List<IDevice> deviceList = scope.Resolve<List<IDevice>>();
|
|
deviceList.Where(d => d is T).ToList().ForEach(d =>
|
{
|
table[d.Id] = d.Name;
|
});
|
}
|
|
return table;
|
}
|
}
|
}
|