ConvertToExt.cs 847 Bytes
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using ControlPanel.Interfaces.Strategys;
using ControlPanel.Contexts;
using ControlPanel.Models;


namespace ControlPanel.Contexts
{
    public class ContextConvert<T>
    {
        private IConvertToExt<T> _strategy;

        public ContextConvert(IConvertToExt<T> strategy)
        {
            _strategy = strategy;
        }
        
        /// <summary>
        ///  Устанавливаем стратегию  конвертирование
        /// </summary>
        /// <param name="strategy"></param>
        public void SetStrategy(IConvertToExt<T> strategy)
        {
            _strategy = strategy;
        }

        public object ExecuteOperation(T message)
        {
            return _strategy.New(message);
        }

    }
}