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