public T Post <T>(IUploadRequest <T> request) where T : IWeiboResponse, new() { var url = new StringBuilder(request.Url); if (request.WeiboType == WeiboType.Sina) { url.Append(_format); } var form = new HttpMultipartMimeForm(); if (request.WeiboType == WeiboType.QQ) { form.AppendValue("format", _format.ToString()); } if (request.Parameters.Count > 0) { foreach (var parameter in request.Parameters) { form.AppendValue(parameter.Key, parameter.Value); } } if (request.FileParameters.Count > 0) { foreach (var fileParameter in request.FileParameters) { form.AppendFile(fileParameter.Key, fileParameter.Value); } } var oauthRequest = new OAuthHttpRequestMessage("POST", url.ToString(), form).Sign(_accessToken); var result = _client.Send(oauthRequest).ReadContentAsString(); var response = new T(); response.ConvertFrom(result); return(response); }
/// <overloads> /// <summary> /// Triggers a <i>Mathematica</i> computation. /// </summary> /// <remarks> /// This method does not return until the computation is finished. /// </remarks> /// </overloads> /// /// <summary> /// Sends the current value of the <see cref="Input"/> property to <i>Mathematica</i> for evaluation. /// </summary> /// public void Compute() { if (IsComputing) { throw new InvalidOperationException("The Mathematica kernel is currently busy (you cannot make a reentrant call to MathKernel.Compute())."); } isComputing = true; try { Clear(); Connect(); lock (ml) { try { ml.PutFunction("EvaluatePacket", 1); ml.PutFunction(KernelLinkImpl.PACKAGE_INTERNAL_CONTEXT + "computeWrapper", 9); ml.Put(Input); ml.Put(ResultFormat.ToString()); ml.Put(PageWidth); ml.Put(GraphicsFormat); ml.Put(GraphicsWidth); ml.Put(GraphicsHeight); ml.Put(GraphicsResolution); ml.Put(UseFrontEnd); ml.Put(CaptureGraphics); ml.WaitForAnswer(); switch (ResultFormat) { case ResultFormatType.Expr: result = ml.GetExpr(); break; case ResultFormatType.StandardForm: case ResultFormatType.TraditionalForm: result = readImage(); break; default: { result = ml.GetStringCRLF(); break; } } } catch (MathLinkException e) { ml.ClearError(); ml.NewPacket(); throw e; } } } finally { isComputing = false; } }
private static string BuildGetQuery(string viewId, Dictionary <string, string> parameters, ResultFormat resultFormat) { var query = $"?viewId={Uri.EscapeDataString(viewId)}"; query += $"&resultFormat={Uri.EscapeDataString(resultFormat.ToString())}"; if (parameters != null) { foreach (var parameter in parameters) { query += $"&{parameter.Key}={parameter.Value}"; } } return(query); }
/// <summary> /// 淘宝 客户对象 /// </summary> public ITopClient TopClient(ResultFormat resultFormat) { return _topClient ?? (_topClient = new DefaultTopClient(TopUtility.TopApiUrl, AppKey, AppSecret, resultFormat.ToString())); }
public ActionResult Results(Guid id, ResultFormat format, string name = null) { var doc = DocumentManager.GetDocument(id); return File(doc.OpenStream(format.ToString()), format.GetMimeType()); }