本文整理匯總了C#中API.Authenticate方法的典型用法代碼示例。如果您正苦於以下問題:C# API.Authenticate方法的具體用法?C# API.Authenticate怎麽用?C# API.Authenticate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類API
的用法示例。
在下文中一共展示了API.Authenticate方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Initialize
/********************************************************
* CLASS METHODS
*********************************************************/
public static void Initialize()
{
// Start thread
Thread thread = new Thread(new ThreadStart(Async.Consumer));
thread.Start();
// Set email and password
string[] credentials = LoadCredentials();
Email = credentials[0];
Password = credentials[1];
//Create API Object
API = new API(Email, Password);
//Attempt Login:
QuantConnectPlugin.Logged = API.Authenticate(Email, Password);
//Check if QCAlgorithm is saved to its last version
try
{
Async.Add(new APIJob(APICommand.CheckQCAlgoVersion, (latestversion, errors) =>
{
if (!(bool)latestversion)
{
API.DownloadQCAlgorithm(Directory);
}
}, Directory));
}
catch (Exception err)
{
MessageBox.Show(err.Message);
}
//Check if QCTemplate exists
try
{
Async.Add(new APIJob(APICommand.UpdateTemplate, (a, b) =>
{
var finished = false;
var baseDirectory = Directory + "QCTemplate";
var destination = baseDirectory + @"\template.zip";
// Check if QCTemplate exists
if (!System.IO.Directory.Exists(baseDirectory))
{
System.IO.Directory.CreateDirectory(baseDirectory);
using (System.Net.WebClient client = new System.Net.WebClient())
{
try
{
client.DownloadFile(new Uri("https://www.quantconnect.com/api/v1/QCTemplate.zip"), destination);
finished = true;
} catch
{
MessageBox.Show("Sorry there was an error downloading the QCTemplate Project. Please make sure your computer has access to the internet.");
}
}
if (finished)
{
API.WriteZip(baseDirectory, destination);
}
}
}, Directory));
}
catch (Exception err)
{
MessageBox.Show(err.Message);
}
}