本文整理汇总了C#中System.Dynamic.ExpandoObject.Flatten方法的典型用法代码示例。如果您正苦于以下问题:C# ExpandoObject.Flatten方法的具体用法?C# ExpandoObject.Flatten怎么用?C# ExpandoObject.Flatten使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Dynamic.ExpandoObject
的用法示例。
在下文中一共展示了ExpandoObject.Flatten方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Request
internal dynamic Request(string method, string serviceUrl, ExpandoObject postData)
{
if (string.IsNullOrEmpty(serviceUrl))
throw new ArgumentNullException("serviceUrl");
string url = string.Format("{0}{1}", _baseUrl, serviceUrl);
WebRequest request = WebRequest.Create(url);
request.Method = method;
request.ContentType = "application/json";
request.Headers["X-Auth-Token"] = _authToken;
//Write post data
if (method == "POST" && postData != null || method == "PUT" && postData != null)
{
string json = postData.Flatten();
var bytes = Encoding.ASCII.GetBytes(json);
request.ContentLength = bytes.Length;
var requestStream = request.GetRequestStream();
requestStream.Write(bytes, 0, bytes.Length);
requestStream.Close();
}
string response;
using (var webResponse = request.GetResponse())
{
using (var streamReader = new StreamReader(webResponse.GetResponseStream()))
{
response = streamReader.ReadToEnd();
}
}
if (string.IsNullOrEmpty(response))
{
return null;
}
else
{
return response.ToExpando();
}
}