using System; using System.Collections.Generic; using System.Linq; using WCS.Core; using WCS.Entity; namespace WCS.Service.Handlers { public abstract class Work : Work { public override sealed void Execute(object obj) { Do((T)obj); } public override sealed IEnumerable GetObjs() { return InitObjects().OfType().ToArray(); } protected abstract void Do(T obj); protected abstract bool SelectDevice(WCS_DEVICE dev); protected virtual IEnumerable InitObjects() { var arr = Device.Where(v => v.ENABLED) .Where(SelectDevice).ToArray(); var res = arr.Select(v => (T)Activator.CreateInstance(typeof(T), v)); return res; } } }