本文整理汇总了C#中Snippet.Serialize方法的典型用法代码示例。如果您正苦于以下问题:C# Snippet.Serialize方法的具体用法?C# Snippet.Serialize怎么用?C# Snippet.Serialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Snippet
的用法示例。
在下文中一共展示了Snippet.Serialize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SaveSnippet
/////////////////////////////////////////////////////////////////////////////////////////////////////
#region Create/Add/Modify Methods
/////////////////////////////////////////////////////////////////////////////////////////////////////
///// <summary>
///// Create a Snippet having Owner and Creator = CurrentUser
///// </summary>
//public long SaveSnippet(Snippet snippet)
//{
// //Check that the client has been already logged in, and if this is not the case, automatically login:
// if (!CheckLogin())
// {
// SetLastError(log, "Cannot login into the system");
// return -1;
// }
// snippet.TargetGroupID = CurrentUser.PersonalGroupID;
// return CreateSnippet(snippet, CurrentUser);
//}
public long SaveSnippet(Snippet snippet)
{
if ((snippet == null) || (snippet.AreFieldsValid() != SnippetWrongField.OK))
{
SetLastError(log, ErrorCodes.WRONG_INPUT,
string.Format("Input error: snippet={0}, creator={1}", snippet.PrintNull(), CurrentUser.PrintNull()));
return -1;
}
//Check that the client has been already logged in, and if this is not the case, automatically login:
if (!CheckLogin())
{
SetLastError(log, ErrorCodes.NOT_LOGGED_IN, "Cannot login into the system");
return -1;
}
//send the request and parse the response:
string contentToSend = "content=" + HttpUtility.UrlEncode(snippet.Serialize(m_serialFormat));
S2CResObj<object> resp = SendReqObj(CREATE_SNIPPET_URL, contentToSend, true);
//build the result:
long result = ParseLongResponse(resp);
if (result == -1)
{
//check if the Status is TARGET_GROUP_INVALID:
if ((resp != null) && (resp.Status == ErrorCodes.TARGET_GROUP_DELETED))
return -2;
}
return result;
}