ConvertToExt.cs
847 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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);
}
}
}