Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- interface IRemindersEmptyCalculator{
- bool IsRemindersEmpty(List<Remider> reminders);
- }
- class RemindersEmptyCalculatorFactory{
- readonly Context context;
- readonly DefaultIsRemindersEmptyCalculator defaultIsRemindersEmptyCalculator
- RemindersEmptyCalculatorFactory(Context context){
- this.context = context;
- }
- public IRemindersEmptyCalculator GetCalculator(){
- switch context.State{
- case Web:
- break;
- case Local:
- break;
- default:
- return new DefaultIsRemindersEmptyCalculator();
- }
- }
- public class DefaultIsRemindersEmptyCalculator:IRemindersEmptyCalculator
- {
- private static readonly Lazy<DefaultIsRemindersEmptyCalculator> _instance =
- new Lazy<DefaultIsRemindersEmptyCalculator>(() => new DefaultIsRemindersEmptyCalculator());
- public static DefaultIsRemindersEmptyCalculator Instance => _instance.Value;
- private DefaultIsRemindersEmptyCalculator() {}
- public bool IsRemindersEmpty(List<Remider> remiders){
- return reminders.Count > 0 ? true : false;
- }
- }
- static void Main(List<Remider> reminders){
- Context = GetCurrentContext();
- RemindersEmptyCalculatorFactory factory = new RemindersEmptyCalculatorFactory(context);
- IRemindersEmptyCalculator isRemindersEmptyCalculator = factory.GetCalcylator();
- bool isRemindersEmpty = isRemindersEmptyCalculator.IsRemindersEmpty(reminders);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement