本文整理汇总了C#中JContainer类的典型用法代码示例。如果您正苦于以下问题:C# JContainer类的具体用法?C# JContainer怎么用?C# JContainer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JContainer类属于命名空间,在下文中一共展示了JContainer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Serialize
public static byte[] Serialize(JContainer item)
{
var stringWriter = new StringWriter();
var writer = new JsonTextWriter(stringWriter);
item.WriteTo(writer);
return Encoding.UTF8.GetBytes(stringWriter.ToString());
}
开发者ID:bmjames,项目名称:diffa-dotnet,代码行数:7,代码来源:JsonAmqpRpcServer.cs
示例2: FillWithJsonObject
public void FillWithJsonObject(JContainer dict, Scheme scheme)
{
Title = (string)dict["title"];
Id = (string)dict["id"];
Color = (Color)ColorConverter.ConvertFromString((string)dict["color"]);
Points = (dict["points"]).Select(p => new Point((double)p[0], (double)p[1])).ToArray();
}
开发者ID:baSSiLL,项目名称:SchemeEditorWpf,代码行数:7,代码来源:Room.cs
示例3: JTokenWriter
/// <summary>
/// Initializes a new instance of the <see cref="JTokenWriter"/> class writing to the given <see cref="JContainer"/>.
/// </summary>
/// <param name="container">The container being written to.</param>
public JTokenWriter(JContainer container)
{
ValidationUtils.ArgumentNotNull(container, "container");
_token = container;
_parent = container;
}
开发者ID:GOArango,项目名称:arangoclient.net,代码行数:11,代码来源:JTokenWriter.cs
示例4: AddParent
private void AddParent(JContainer container)
{
if (this._parent == null)
this._token = container;
else
this._parent.AddAndSkipParentCheck((JToken) container);
this._parent = container;
}
开发者ID:Zeludon,项目名称:FEZ,代码行数:8,代码来源:JTokenWriter.cs
示例5: FillWithJsonObject
public virtual void FillWithJsonObject(JContainer dict, Scheme scheme)
{
Title = (string)dict["title"];
Room = scheme.Rooms.Single(r => r.Id.Equals(dict["room"]));
QRCode = (string)dict[@"qr_code"];
Image = (string)dict["image"];
Visible = (bool)dict[@"visible"];
}
开发者ID:baSSiLL,项目名称:SchemeEditorWpf,代码行数:8,代码来源:Item.cs
示例6: _SendHttpRequest
/**
* @param uri
* @param method Case-insensitive
* @param bodyObject
* @param responseObject output, the value would be JObject or JArray
*/
private bool _SendHttpRequest(string uri, string method, JObject bodyObject, out JContainer responseObject)
{
responseObject = null;
var url = APIEndPoint + BaseURL + @"/" + uri;
// Set remote url and http method.
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Method = method;
// Set the content type header and http body.
if(bodyObject != null){
var body = JsonConvert.SerializeObject(bodyObject);
if (body.Length != 0)
{
request.ContentType = "application/json";
using (Stream requestStream = request.GetRequestStream())
using (StreamWriter writer = new StreamWriter(requestStream))
{
writer.Write(body);
}
}
}
// Set the authorization id.
string sAuth = "auth_id=" + AuthoId;
request.Headers.Add("Authorization", sAuth);
string responseData = "";
try
{
// Send request
System.Net.WebResponse response = (HttpWebResponse)request.GetResponse();
responseData = new StreamReader(response.GetResponseStream()).ReadToEnd();
}
catch (WebException e)
{
HttpWebResponse response = (HttpWebResponse)e.Response;
if (response != null)
{
responseData = new StreamReader(response.GetResponseStream()).ReadToEnd();
response.Close(); // Releases the resources of the response.
}
}
catch (Exception)
{
return false;
}
if (!string.IsNullOrEmpty(responseData))
{
var res = JsonConvert.DeserializeObject(responseData);
responseObject = res as JContainer;
}
return true;
}
开发者ID:JeffreyZksun,项目名称:RESTCSharp,代码行数:64,代码来源:RestAPI.cs
示例7: AddParent
private void AddParent(JContainer container)
{
if (_parent == null)
_token = container;
else
_parent.Add(container);
_parent = container;
}
开发者ID:gabrielamboss,项目名称:Ulkoa,代码行数:9,代码来源:JTokenWriter.cs
示例8: FromJObject
public static QueryAggregateDigestsRequest FromJObject(JContainer jObject)
{
var request = JsonConvert.DeserializeObject<QueryAggregateDigestsRequest>(jObject.ToString());
if (request.Constraints == null || request.Buckets == null)
{
throw new ArgumentNullException();
}
return request;
}
开发者ID:bmjames,项目名称:diffa-dotnet,代码行数:9,代码来源:QueryAggregateDigestsRequest.cs
示例9: FormatLinks
public void FormatLinks(JContainer container, IEnumerable<Link> links, JsonSerializer serializer)
{
var jLinks = new JArray();
foreach (var link in links)
{
jLinks.Add(JObject.FromObject(link, serializer));
}
container[_linksPropertyName] = jLinks;
}
开发者ID:muratbeyaztas,项目名称:Simple.Web,代码行数:9,代码来源:DefaultJsonLinksFormatter.cs
示例10: FormatLinks
public void FormatLinks(JContainer container, IEnumerable<Link> links, JsonSerializer serializer)
{
var jLinks = new JObject();
foreach (var link in links)
{
jLinks[link.Rel] = JValue.CreateString(link.Href);
}
container[_linksPropertyName] = jLinks;
}
开发者ID:muratbeyaztas,项目名称:Simple.Web,代码行数:9,代码来源:SimpleJsonLinksFormatter.cs
示例11: AssertSchemaIsValid
public static void AssertSchemaIsValid(JSchema jSchema, JContainer jContainer)
{
IList<string> messages;
var isValid = jContainer.IsValid(jSchema, out messages);
foreach (var message in messages)
{
Console.WriteLine(message);
}
Assert.IsTrue(isValid);
}
开发者ID:baLR0n,项目名称:HaloSharp,代码行数:11,代码来源:SchemaUtility.cs
示例12: parseActions
/// <summary>
/// Parse the child Actions object that is part of the Tropo Result object.
/// </summary>
/// <param name="actions">Actions - is either an Object or an Array.</param>
/// <returns></returns>
public static JContainer parseActions(JContainer actions)
{
JTokenType type = actions.Type;
if (type == JTokenType.Array)
{
return JArray.Parse(actions.ToString());
}
else
{
return parseObject(actions);
}
}
开发者ID:Shannon-McCoy,项目名称:tropo-webapi-csharp,代码行数:17,代码来源:TropoUtilities.cs
示例13: ReadInto
private bool ReadInto(JContainer c)
{
JToken firstChild = c.First;
if (firstChild == null)
{
return SetEnd(c);
}
else
{
SetToken(firstChild);
_current = firstChild;
_parent = c;
return true;
}
}
开发者ID:robgreen,项目名称:nom,代码行数:15,代码来源:JsonTokenReader.cs
示例14: GetEndToken
private JsonToken? GetEndToken(JContainer c)
{
switch (c.Type)
{
case JsonTokenType.Object:
return JsonToken.EndObject;
case JsonTokenType.Array:
return JsonToken.EndArray;
case JsonTokenType.Constructor:
return JsonToken.EndConstructor;
case JsonTokenType.Property:
return null;
default:
throw MiscellaneousUtils.CreateArgumentOutOfRangeException("Type", c.Type, "Unexpected JContainer type.");
}
}
开发者ID:robgreen,项目名称:nom,代码行数:16,代码来源:JsonTokenReader.cs
示例15: GeneratePatterns
/// <summary>
/// Generates a collection of patterns for the specified <see cref="JContainer"/>.
/// </summary>
public PatternCollection GeneratePatterns(JContainer root, int desiredCount, bool skipValues = true)
{
var descendants = root.DescendantsAndSelf().ToArray();
descendants.Shuffle(random);
if (skipValues)
descendants = descendants.Where(x => x is JObject || x is JArray).ToArray();
var patterns = descendants
.Select(x => x.Path)
.Where(x => !string.IsNullOrWhiteSpace(x))
.Take(desiredCount)
.Select(x => (random.NextBool() ? "!" : "") + x)
.Select(AddWildcards)
.ToArray();
return PatternCollection.Parse(patterns);
}
开发者ID:pgolebiowski,项目名称:onism-cldr,代码行数:21,代码来源:PatternCollectionGenerator.cs
示例16: DoesParentHaveSaidKey
private bool DoesParentHaveSaidKey(JContainer container, string tokenPath)
{
if (container == null)
return false;
var result = DoesParentHaveSaidKey(container.Parent, tokenPath);
var key = tokenPath.Split('.').LastOrDefault();
foreach (var desc in container.Values())
{
var descPath = desc.Path.Split('.');
if (descPath.Length < tokenPath.Split('.').Length && descPath.Last() == key) {
result = result || true;
break;
}
}
return result;
}
开发者ID:BufferUnderrunOK,项目名称:JSONScrubber,代码行数:19,代码来源:Scrubber.cs
示例17: ReadSources
private IEnumerable<Source> ReadSources(JContainer json)
{
var sources = new List<Source>();
var items = json.ToObject<List<JObject>>();
foreach (var item in items)
{
var source = new Source()
{
Id = item["id"].Value<int>(),
Title = item["title"].ToString(),
Spout = item["spout"].ToString(),
Params = item["params"].ToObject<Dictionary<string, string>>(),
Error = item["error"].ToString(),
Favicon = item["icon"].ToString(),
Tags = new List<string>(item["tags"].ToString().Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
};
sources.Add(source);
}
return sources;
}
开发者ID:gleroi,项目名称:selfnet,代码行数:20,代码来源:SourcesApi.cs
示例18: FillWithJsonObject
public void FillWithJsonObject(JContainer dict, Scheme scheme)
{
Rooms = dict["rooms"].Select(r =>
{
Room room = new Room();
room.FillWithJsonObject((JContainer)r, scheme);
return room;
}).ToArray();
Items = dict["items"].Select(i =>
{
Item item;
string locType = (string)i["location_type"];
if (locType.Equals("room"))
item = new RoomItem();
else
item = new CoordinateItem();
item.FillWithJsonObject((JContainer)i, scheme);
return item;
}).ToArray();
}
开发者ID:baSSiLL,项目名称:SchemeEditorWpf,代码行数:21,代码来源:Scheme.cs
示例19: DynExecute
public HttpResponseMessage DynExecute(string sp, JContainer requestBody)
{
if (requestBody == null)
return Execute(sp, null);
JObject parameters = requestBody as JObject;
if (parameters != null)
return Execute(sp, parameters.ToObject<Dictionary<string, object>>());
JArray bulkParameters = requestBody as JArray;
if (bulkParameters != null)
{
List<Dictionary<string, object>> listOfDicts = bulkParameters.ToObject<List<Dictionary<string, object>>>();
if (listOfDicts != null && listOfDicts.Count > 0)
return BulkExecute(sp, listOfDicts);
else
return Request.CreateResponse(HttpStatusCode.NoContent);
}
return Request.CreateResponse(HttpStatusCode.BadRequest);
}
开发者ID:REALTOBIZ,项目名称:DbWebApi,代码行数:24,代码来源:DbWebApiController.cs
示例20: JObjectValueProvider
public JObjectValueProvider(JContainer jcontainer)
{
_jcontainer = jcontainer;
}
开发者ID:18098924759,项目名称:WuWen,代码行数:4,代码来源:JsonValueProviderFactory.cs
注:本文中的JContainer类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论