本文整理汇总了C#中IStrategy类的典型用法代码示例。如果您正苦于以下问题:C# IStrategy类的具体用法?C# IStrategy怎么用?C# IStrategy使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IStrategy类属于命名空间,在下文中一共展示了IStrategy类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: PerformSimulation
public SeasonSimulationResult PerformSimulation(IStrategy strategy, SeasonSimulationOptions options)
{
if (strategy == null) throw new ArgumentNullException("strategy");
var allPlayers = GetPlayersForFirstGameweek();
var maxGameweek = CalculateMaxGameweek(options.MaximumGameweek);
_logger.Log(Tag.Simulation, string.Concat("Max gameweek is ", maxGameweek));
var startingTeam = options.UseSavedInitialTeam ? SelectInitialTeamByIds(allPlayers, options.InitialTeamPlayerIds) : strategy.PickStartingTeam(allPlayers);
_logger.Log(Tag.Simulation, "Starting team picked");
LogHelper.LogTeam(startingTeam, _logger);
if (options.ChooseInitialTeamOnly)
{
return new SeasonSimulationResult();
}
var seasonState = _decisionActioner.ValidateAndApplyStartingTeam(startingTeam, allPlayers);
_logger.Log(Tag.Simulation, "Applied starting team");
return SimulateSeason(seasonState, strategy, maxGameweek);
}
开发者ID:robinweston,项目名称:fantasyfootballrobot,代码行数:26,代码来源:SeasonSimulator.cs
示例2: QuoteProvider
public QuoteProvider(IStrategy owner)
{
_owner = owner;
_lastPeek = new DateTime(1900, 1, 1);
_timer = new Timer(1000);
_timer.Elapsed += new ElapsedEventHandler(OnTick);
}
开发者ID:bra5047,项目名称:psugv-500-team4,代码行数:7,代码来源:QuoteProvider.cs
示例3: run
public void run()
{
try
{
remoteProcessClient.WriteToken(token);
int teamSize = remoteProcessClient.ReadTeamSize();
remoteProcessClient.WriteProtocolVersion();
Game game = remoteProcessClient.readGameContext();
IStrategy[] strategies = new IStrategy[teamSize];
for (int strategyIndex = 0; strategyIndex < teamSize; ++strategyIndex)
{
strategies[strategyIndex] = new MyStrategy();
}
PlayerContext playerContext;
while ((playerContext = remoteProcessClient.ReadPlayerContext()) != null)
{
Trooper playerTrooper = playerContext.Trooper;
Move move = new Move();
strategies[playerTrooper.TeammateIndex].Move(playerTrooper, playerContext.World, game, move);
remoteProcessClient.WriteMove(move);
}
}
finally
{
remoteProcessClient.Close();
}
}
开发者ID:Evander83,项目名称:AICup-2013,代码行数:32,代码来源:Runner.cs
示例4: AddStock
/// <summary>
/// 增加一个策略,和关注的股票价格
/// </summary>
/// <param name="code">股票代码</param>
/// <param name="strategy">策略实例</param>
public void AddStock(String code, IStrategy strategy)
{
if (stockDataCache[code] == null)
{
stockDataCache[code] = new StockDataQueue();
}
stockDataCache[code].OnStockDataChange += strategy.OnStockDataChanged;
}
开发者ID:lzyeasyboy,项目名称:StockTrader,代码行数:13,代码来源:StockMarketManager.cs
示例5: Template
public Template(IStrategy strategy, String templateText, String[] namespaces,
params Variable[] variables)
{
_strategy = strategy;
this.templateText = templateText;
this.namespaces = namespaces;
this.variables = variables;
}
开发者ID:oleguchok,项目名称:Template-Performer-Client-Server,代码行数:8,代码来源:Template.cs
示例6: StrategyControl
public StrategyControl(IStrategy strategy)
{
InitializeComponent();
this.strategy = strategy;
// load my stock pool
LoadMyStockPool();
}
开发者ID:GhostCamel,项目名称:StockTrader,代码行数:8,代码来源:StrategyControl.cs
示例7: BuildConfigurationContext
public ConfigurationContext BuildConfigurationContext(BaseFeature feature, IStrategy strategy)
{
if (string.IsNullOrWhiteSpace(Key))
{
throw new ArgumentException("Missing 'Key' parameter for '" + strategy.GetType().Name + "' strategy for '" + feature.Name + "' feature");
}
return new ConfigurationContext(this);
}
开发者ID:valdisiljuconoks,项目名称:FeatureSwitch,代码行数:9,代码来源:FeatureStrategyAttribute.cs
示例8: ComplexStrategy
public ComplexStrategy(IStrategy[] innerStrategies, string name, long quantity,
IStrategy defaultStrategy, StrategyType strategyType)
{
_innerStrategies = innerStrategies;
_name = name;
_quantity = quantity;
_defaultStrategy = defaultStrategy;
_strategyType = strategyType;
}
开发者ID:slahn,项目名称:structuremap,代码行数:9,代码来源:Strategy.cs
示例9: GuardianAgentSession
public GuardianAgentSession(Agent agent, string process,
IStrategy redStrategy, IStrategy yellowStrategy, double e1, double e2)
{
this.Agent = agent;
this.TargetProcess = process;
this.RedStrategy = redStrategy;
this.YellowStrategy = yellowStrategy;
this.E1 = e1;
this.E2 = e2;
}
开发者ID:Evlikat,项目名称:incinerate,代码行数:10,代码来源:GuardianAgentsPool.cs
示例10: ReachabilityStrategyCalculationAlgorithm
public ReachabilityStrategyCalculationAlgorithm(ITestGraph testGraph, IStrategy strategy)
{
if (this.testGraph == null)
{
throw new ArgumentNullException("testGraph");
}
this.testGraph = testGraph;
this.strategy = new QuickGraph.Algorithms.TestGames.Strategy();
this.performanceComparer = new PairPreOrderPerformanceComparer();
}
开发者ID:NigelThorne,项目名称:ndependencyinjection,代码行数:10,代码来源:ReachabilityStrategyCalculationAlgorithm.cs
示例11: FoxWatchMainController
public FoxWatchMainController(IStrategy strategy, DBOutEnum dbOutEnum)
{
_strategy = strategy;
Boolean bDBOut_InRunning = false;
if (dbOutEnum == DBOutEnum.Enable)
{
bDBOut_InRunning = true;
}
_foxCaptureController = new FoxWatchCaptureController(bDBOut_InRunning);
}
开发者ID:HongSeokHwan,项目名称:legacy,代码行数:11,代码来源:FoxWatchMainController.cs
示例12: RecognizedAgent
public RecognizedAgent(string name, double res,
IStrategy redStrategy, IStrategy yellowStrategy,
double p1, double p2)
{
Name = name;
m_P1 = p1;
m_P2 = p2;
m_Res = res;
m_RedStrategy = redStrategy;
m_YellowStrategy = yellowStrategy;
}
开发者ID:Evlikat,项目名称:incinerate,代码行数:11,代码来源:WatchingAgentPool.cs
示例13: RegisterStrategy
/// <summary>
/// 在行情市场中登记一个策略,当关注股票价格发生变动的时候,即时提醒策略。
/// </summary>
/// <param name="strategy">策略实例</param>
public void RegisterStrategy(IStrategy strategy)
{
foreach (string code in strategy.StockPool)
{
if (!StockMarketManager.bidCache.ContainsKey(code))
{
StockMarketManager.bidCache.Add(code, new BidCacheQueue());
}
StockMarketManager.bidCache[code].OnBidChange += strategy.OnStockDataChanged;
}
}
开发者ID:huoxudong125,项目名称:StockTrader,代码行数:15,代码来源:StockMarketManager.cs
示例14: ProcessStrategy
private void ProcessStrategy(IStrategy strategy)
{
foreach (var quote in this.quotes)
{
strategy.ProcessQuote(quote);
}
if (Interlocked.Decrement(ref numberOfTasks) == 0)
{
signal.Set();
}
}
开发者ID:WinnieThePoooh,项目名称:Trading,代码行数:12,代码来源:BackTesting.cs
示例15: BackTest
public BackTest(
IEventBus eventBus,
IDataHandler bars,
IStrategy strategy,
IPortfolio portfolio,
IExecutionHandler executionHandler)
{
this.eventBus = eventBus;
this.bars = bars;
this.strategy = strategy;
this.portfolio = portfolio;
this.executionHandler = executionHandler;
this.stopWatch = new Stopwatch();
}
开发者ID:afedyanin,项目名称:event-driven-backtesting,代码行数:14,代码来源:BackTest.cs
示例16: Main
public static void Main(string[] args)
{
// Some pre-processing filters.
IFilter[] filters = new IFilter[] {
new BMPConvert(),
// new DynamicRangeReduce(),
};
// Find all strategies and instantiate.
Type[] strategy_types = Assembly
.GetExecutingAssembly()
.GetTypes()
.Where(
type => typeof(IStrategy).IsAssignableFrom(type) && typeof(IStrategy) != type
)
.ToArray();
IStrategy[] strategies = new IStrategy[strategy_types.Length];
for(int t = 0; t < strategy_types.Length; ++t) {
strategies[t] = (IStrategy) Activator.CreateInstance(strategy_types[t]);
}
StringBuilder html = new StringBuilder();
html.Append ("<html><body>");
foreach(string arg in args) {
// Load image from arguments.
Image bmp = Image.FromFile(arg);
// Run through filters.
foreach(IFilter filter in filters) {
bmp = filter.filter (bmp);
}
// Run through each strategy.
html.AppendFormat ("<div><h2>{0}</h2>", arg);
foreach(IStrategy strategy in strategies) {
String table = GenerateHTMLForImage(bmp, strategy);
html.AppendFormat ("<h3>{0}</h3><p>{1} bytes</p><div>{2}</div>", strategy.Name, table.Length, table);
}
html.Append ("</div>");
}
html.Append ("</body>");
// Dump to console.
Console.Write (html.ToString ());
}
开发者ID:wtracz,项目名称:pixelator,代码行数:50,代码来源:Main.cs
示例17: GenerateHTMLForImage
private static String GenerateHTMLForImage(Image img, IStrategy strategy)
{
// Create table .
Table tbl = new Table();
// Convert image.
strategy.generateTable(img, tbl);
// Table to HTML.
HTMLBuilder builder = new HTMLBuilder();
tbl.accept(builder);
return builder.HTML;
}
开发者ID:wtracz,项目名称:pixelator,代码行数:14,代码来源:Main.cs
示例18: run
public void run()
{
try
{
remoteProcessClient.WriteToken(token);
int teamSize = remoteProcessClient.ReadTeamSize();
IStrategy[] strategies = new IStrategy[teamSize];
TankType[] tankTypes = new TankType[teamSize];
for (int strategyIndex = 0; strategyIndex < teamSize; ++strategyIndex)
{
IStrategy strategy = new MyStrategy();
strategies[strategyIndex] = strategy;
tankTypes[strategyIndex] = strategy.SelectTank(strategyIndex, teamSize);
}
remoteProcessClient.WriteSelectedTanks(tankTypes);
PlayerContext playerContext;
while ((playerContext = remoteProcessClient.ReadPlayerContext()) != null)
{
Tank[] playerTanks = playerContext.Tanks;
if (playerTanks.Length != teamSize)
{
break;
}
Move[] moves = new Move[teamSize];
for (int strategyIndex = 0; strategyIndex < teamSize; ++strategyIndex)
{
Move move = new Move();
moves[strategyIndex] = move;
strategies[strategyIndex].Move(playerTanks[strategyIndex], playerContext.World, move);
}
remoteProcessClient.WriteMoves(moves);
}
}
finally
{
remoteProcessClient.Close();
}
}
开发者ID:jeremejevs,项目名称:code-tanks,代码行数:46,代码来源:Runner.cs
示例19: Agent
public Agent(IStrategy strategy, List<Account> accounts)
{
this._strategy = strategy;
_accounts = accounts;
_bStart = false;
AgentManager.Ins().Register(this);
ScheduleManager.Ins().AddSchedule(this);
foreach (Account account in accounts)
{
account.SetAgent(this);
}
this._strategy.TakeOverRemainPosition();
}
开发者ID:HongSeokHwan,项目名称:legacy,代码行数:17,代码来源:Agent.cs
示例20: SwitchStrategy
// Changing strategies
public void SwitchStrategy()
{
if (strategy is Strategy1)
strategy = new Strategy2();
else
strategy = new Strategy1();
}
开发者ID:david--liu,项目名称:code_kata,代码行数:8,代码来源:StrategyPattern.cs
注:本文中的IStrategy类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论