本文整理汇总了C#中Parse.ParseObject.GetRelation方法的典型用法代码示例。如果您正苦于以下问题:C# ParseObject.GetRelation方法的具体用法?C# ParseObject.GetRelation怎么用?C# ParseObject.GetRelation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Parse.ParseObject
的用法示例。
在下文中一共展示了ParseObject.GetRelation方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestIsValidType
public void TestIsValidType() {
var corgi = new ParseObject("Corgi");
var corgiRelation = corgi.GetRelation<ParseObject>("corgi");
Assert.IsTrue(ParseEncoder.IsValidType(322));
Assert.IsTrue(ParseEncoder.IsValidType(0.3f));
Assert.IsTrue(ParseEncoder.IsValidType(new byte[]{ 1, 2, 3, 4 }));
Assert.IsTrue(ParseEncoder.IsValidType("corgi"));
Assert.IsTrue(ParseEncoder.IsValidType(corgi));
Assert.IsTrue(ParseEncoder.IsValidType(new ParseACL()));
Assert.IsTrue(ParseEncoder.IsValidType(new ParseFile("Corgi", new byte[0])));
Assert.IsTrue(ParseEncoder.IsValidType(new ParseGeoPoint(1, 2)));
Assert.IsTrue(ParseEncoder.IsValidType(corgiRelation));
Assert.IsTrue(ParseEncoder.IsValidType(new DateTime()));
Assert.IsTrue(ParseEncoder.IsValidType(new List<object>()));
Assert.IsTrue(ParseEncoder.IsValidType(new Dictionary<string, string>()));
Assert.IsTrue(ParseEncoder.IsValidType(new Dictionary<string, object>()));
Assert.IsFalse(ParseEncoder.IsValidType(new ParseAddOperation(new List<object>())));
Assert.IsFalse(ParseEncoder.IsValidType(Task<ParseObject>.FromResult(new ParseObject("Corgi"))));
Assert.Throws<MissingMethodException>(() => ParseEncoder.IsValidType(new Dictionary<object, object>()));
Assert.Throws<MissingMethodException>(() => ParseEncoder.IsValidType(new Dictionary<object, string>()));
}
示例2: LoadEverything
private async Task LoadEverything()
{
//ScriptManager.RegisterStartupScript(this, this.GetType(), "scrollPanel", "scrollPanel();", true);
IEnumerable<ParseObject> conversations = await GetConversations();
DataTable dt = InitConversationTable();
foreach (ParseObject conv in conversations)
{
//ConversationPanel pnl = (ConversationPanel)LoadControl("~/UserControls/ConversationPanel.ascx");
//string theirNumber = conv.Get<string>("baseUserId1") == UserID ? "2" : "1";
//ParseObject tempTheirPublicData = conv.Get<ParseObject>("publicUserData" + theirNumber);
//await tempTheirPublicData.FetchIfNeededAsync();
//pnl.TheirName = tempTheirPublicData.Get<string>("displayName");
//pnl.LastMessage = await GetFirstMessageText(conv);
//pnl.TheirUserID = tempTheirPublicData.ObjectId;
//pnlConversations.ContentTemplateContainer.Controls.Add(pnl);
//pnlConversations.Controls.Add(pnl);
DataRow dr = dt.NewRow();
string theirNumber = conv.Get<string>("baseUserId1") == UserID ? "2" : "1";
ParseObject tempTheirPublicData = conv.Get<ParseObject>("publicUserData" + theirNumber);
await tempTheirPublicData.FetchIfNeededAsync();
dr["TheirName"] = tempTheirPublicData.Get<string>("displayName");
string lastMessage = await GetFirstMessageText(conv);
dr["LastMessage"] = lastMessage.Length <= 30 ? lastMessage : lastMessage.Substring(0, 30) + "...";
dr["TheirUserID"] = tempTheirPublicData.ObjectId;
ParseFile profilePic = tempTheirPublicData.Get<ParseFile>("profilePic");
dr["ProfilePicUrl"] = profilePic == null ? "Images/default_prof_pic.png" : profilePic.Url.ToString();
dt.Rows.Add(dr);
}
repConversations.DataSource = dt;
repConversations.DataBind();
if (Session["ConversationUserId"] != null)
{
RecipientPublicData = await GetStudentPublicData(Session["ConversationUserId"].ToString());
Conversation = await GetThisConversation(RecipientPublicData.Get<string>("baseUserId"));
if (Conversation == null)
{
}
else
{
ParseRelation<ParseObject> relation = Conversation.GetRelation<ParseObject>("messages");
IEnumerable<ParseObject> messages = await relation.Query.OrderBy("createdAt").FindAsync();
DataTable messageData = InitMessageTable();
foreach (ParseObject mes in messages)
{
DataRow dr = messageData.NewRow();
dr["Text"] = mes.Get<string>("text");
dr["WasSentByMe"] = mes.Get<string>("senderBaseUserId") == UserID;
dr["SentAt"] = mes.Get<DateTime>("sentAt").ToString();
messageData.Rows.Add(dr);
}
repMessages.DataSource = messageData;
repMessages.DataBind();
await RemoveNotificationsForConversation();
}
tbType.Enabled = true;
btnSend.Enabled = true;
}
else
{
tbType.Enabled = false;
btnSend.Enabled = false;
}
}
示例3: GetFirstMessageText
private async Task<string> GetFirstMessageText(ParseObject conversation)
{
var relation = conversation.GetRelation<ParseObject>("messages");
var query = from mes in relation.Query
orderby mes.CreatedAt descending
select mes;
ParseObject message = await query.FirstAsync();
return message.Get<string>("text");
}