我有一个泛型类,我想创建一个列表.然后在运行时我得到项目的类型
public class Job<T>
{
public int ID { get; set; }
public Task<T> Task { get; set; }
public TimeSpan Interval { get; set; }
public bool Repeat { get; set; }
public DateTimeOffset NextExecutionTime { get; set; }
public Job<T> RunOnceAt(DateTimeOffset executionTime)
{
NextExecutionTime = executionTime;
Repeat = false;
return this;
}
}
Run Code Online (Sandbox Code Playgroud)
List<Job<T>> x = new List<Job<T>>();
public void Example()
{
//Adding a job
x.Add(new Job<string>());
//The i want to retreive a job from the …Run Code Online (Sandbox Code Playgroud) 我正在使用新的HttpClient来处理我项目的网上冲浪需求; 但是,尽管设置正确,但HttpClient不会将cookie保存到Cookie容器中,并且它始终为EMPTY.
private CookieContainer _cookieContainer = new CookieContainer();
private HttpClient HttpClient { get; set; }
private HttpClientHandler HttpClientHandler { get; set; }
public Initialize()
{
HttpClientHandler = new HttpClientHandler
{
AllowAutoRedirect = true,
UseCookies = true,
CookieContainer = _cookieContainer
};
HttpClient = new HttpClient(HttpClientHandler);
}
public CookieContainer Cookies
{
get { return _cookieContainer; }
set { _cookieContainer = value; }
}
public void TEST()
{
//This is always empty, although I am sure that the site is saving login …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用HttpClient的PostAsync登录网站; 但总是失败,当我使用WireShark跟踪连接时,我发现它错误地发布了数据
var content = new FormUrlEncodedContent(new[]
{
new KeyValuePair<string, string>("value1", data1),
new KeyValuePair<string, string>("value2", data2),
new KeyValuePair<string, string>("value3", data3)
});
Run Code Online (Sandbox Code Playgroud)
要么
var content = new List<KeyValuePair<string, string>>
{
new KeyValuePair<string, string>("value1", data1),
new KeyValuePair<string, string>("value2", data2),
new KeyValuePair<string, string>("value3", data3)
};
Run Code Online (Sandbox Code Playgroud)
用法
httpClient.PostAsync(postUri, content)
Run Code Online (Sandbox Code Playgroud)
value1=123456&value2=123456&value3=123456
Run Code Online (Sandbox Code Playgroud)
//It adds strange += which makes the post fail...
value1=123456&value2+=123456&value3+=123456
Run Code Online (Sandbox Code Playgroud) 当我正在开发我的小游戏时,我已经取得了很多进步但却对许多事情感到沮丧.最新的事情是,creating a list of required items并且让你明白,我将为你提供我创建的两个Explanation,Code但显然不起作用......
我 - 解释
为了让玩家建造一座建筑,他必须做一些必要的研究,每项研究都需要更多的研究才能研究......就像一棵研究树,玩家将通过探索游戏和做一些任务......
所以想象一下,你可以在这里查看我的小代码
II - 代码
//Available Main Elements
var carbon = new Element {Name = "Carbon"};
var hydrogen = new Element {Name = "Hydrogen"};
var oxygen = new Element {Name = "Oxygen"};
var nitrogen = new Element {Name = "Nitrogen"};
//Example Research
var steam = new Research(name : "Steam", requiredElements: null, requiredResearches: /*Fire*/ & /*Water*/ & /*Iron*/);
Run Code Online (Sandbox Code Playgroud)
所以从最后一段代码[只是为了解释]玩家想要研究Steam那个例如需要3个研究才能被研究...其中一个the Iron还需要另外1个研究来研究等等[也许更少或许更多或根本没有要求] ...... …
嗯...请原谅我提出这样模糊的问题,但我因为它而崩溃了,我找不到一个好的逻辑来实现它,或者至少是一个好的库,为我做这样的事情.
我的应用程序应该以不同的时间间隔执行许多任务,其中一些任务只有在满足某些条件或其他方法完成后才需要执行等等.[把它想象成一个方法依赖树] ...我想知道像巨大的在线游戏或这样的项目这样的大项目,他们如何组织他们的代码,以便在错误的时间内没有崩溃或执行某些方法或没有满足它的条件?
整个问题是在我的应用程序中我想要以下规格