本文整理汇总了C#中JsonObject.Serialize方法的典型用法代码示例。如果您正苦于以下问题:C# JsonObject.Serialize方法的具体用法?C# JsonObject.Serialize怎么用?C# JsonObject.Serialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JsonObject
的用法示例。
在下文中一共展示了JsonObject.Serialize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetItemDetails
public string GetItemDetails(DetailsRequest p_DetailsRequest)
{
var l_Result = new JsonObject();
var l_FileDate = DateTime.Parse(p_DetailsRequest.FileDate);
var l_Details = PxLog.Models.PxLogModel.GetDetails(l_FileDate, p_DetailsRequest.Position);
l_Details = l_Details.Replace("\r\n", "<br/>");
l_Result.Add("Details", l_Details);
return l_Result.Serialize();
}
示例2: bUploadLog_Click
void bUploadLog_Click( object sender, EventArgs e )
{
Log( "[UploadLog]" );
JsonObject files = new JsonObject();
if( File.Exists( Paths.GameLogFile ) ) {
string content = File.ReadAllText( Paths.GameLogFile );
files.Add( "log.txt",
new JsonObject {
{
"content", content
}
} );
}
if( File.Exists( Paths.LauncherLogFile ) ) {
string content = File.ReadAllText( Paths.LauncherLogFile );
files.Add( "launcher.log",
new JsonObject {
{
"content", content
}
} );
}
if( File.Exists( Paths.LauncherLogFile + ".old" ) ) {
string content = File.ReadAllText( Paths.LauncherLogFile + ".old" );
files.Add( "launcher.log.old",
new JsonObject {
{
"content", content
}
} );
}
if( files.Count == 0 ) {
lToolStatus.Text = "No log files to submit";
return;
}
JsonObject request = new JsonObject {
{
"description", "Charged-Miners log upload"
}, {
"public", false
}, {
"files", files
}
};
WebClient logClient = new WebClient();
logClient.Headers.Add( "user-agent", VersionString );
string dataString = request.Serialize();
byte[] data = Encoding.UTF8.GetBytes( dataString );
try {
byte[] responseData = logClient.UploadData( "https://api.github.com/gists", data );
string responseString = Encoding.UTF8.GetString( responseData );
JsonObject response = new JsonObject( responseString );
tPastebinUrl.Text = response.GetString( "html_url" );
tPastebinUrl.Select();
tPastebinUrl.SelectAll();
lToolStatus.Text = "Log files uploaded! Please copy the given URL.";
} catch( WebException ex ) {
Log( "UploadLog ERROR: " + ex );
string responseBody;
using( Stream responseStream = ex.Response.GetResponseStream() ) {
responseBody = new StreamReader( responseStream ).ReadToEnd();
}
Log( "UploadLog response: " + responseBody );
lToolStatus.Text = "Log file upload failed! " + ex.Message;
}
}
示例3: SendMsgToPlugin
public JsonObject SendMsgToPlugin(int nSenderId, JsonObject jsonMsg)
{
#if UNITY_EDITOR
return new JsonObject();
#endif
jsonMsg["senderId"] = nSenderId;
string strJson = jsonMsg.Serialize();
string strRet = "";
#if UNITY_IPHONE
strRet = _iOS_SendUnityMsgToPlugin(nSenderId, strJson);
#elif UNITY_ANDROID
strRet = smAndroid.CallStatic<string>("SendUnityMsgToPlugin", nSenderId, strJson);
#endif
JsonObject jsonRet = new JsonObject(strRet);
return jsonRet;
}