本文整理汇总了C#中MindTouch.Dream.Plug.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Plug.ToString方法的具体用法?C# Plug.ToString怎么用?C# Plug.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MindTouch.Dream.Plug
的用法示例。
在下文中一共展示了Plug.ToString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConnectToDeki
public void ConnectToDeki(string dreamAPI, string dekiUserName, string dekiUserPassword)
{
this._dreamAPI = dreamAPI;
this._dekiPlug = Plug.New(_dreamAPI).WithCredentials(dekiUserName, dekiUserPassword);
DreamMessage authResponse = _dekiPlug.At("users", "authenticate").GetAsync().Wait();
if(!authResponse.IsSuccessful) {
Log.FatalFormat("Could not connect to MT API '{0}' username: '{1}' password: '{2}' Error:", _dekiPlug.ToString(), dekiUserName, dekiUserPassword, authResponse.ToString());
throw new DreamAbortException(authResponse);
}
//Check that user have admin rights
DreamMessage userResponse = _dekiPlug.At("users", "=" + Utils.DoubleUrlEncode(dekiUserName)).Get();
XDoc resDoc = userResponse.AsDocument();
string roleName = resDoc["permissions.user/role"].AsText;
if ((roleName == null) || (roleName.ToLower() != "admin"))
{
WriteLineToConsole("User " + dekiUserName + " should have Admin role in Deki.");
return;
}
_connectedToDeki = true;
}