本文整理汇总了C#中JContainer.SelectToken方法的典型用法代码示例。如果您正苦于以下问题:C# JContainer.SelectToken方法的具体用法?C# JContainer.SelectToken怎么用?C# JContainer.SelectToken使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JContainer
的用法示例。
在下文中一共展示了JContainer.SelectToken方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PositionI
/// <summary>
/// Initializes a new instance of the <see cref="Core.Models.PositionI"/> class.
/// </summary>
/// <param name="obj">JSON Object.</param>
public PositionI(JContainer obj)
{
X = (int)obj.SelectToken("X");
Y = (int)obj.SelectToken("Y");
}
示例2: CellPosition
/// <summary>
/// Initializes a new instance of the <see cref="Core.Models.CellPosition"/> class.
/// </summary>
/// <param name="obj">JContainer Object.</param>
public CellPosition(JContainer obj)
: this((int)obj.SelectToken("CellX"),
(int)obj.SelectToken("CellY"))
{
}
示例3: MergeInto
private static void MergeInto(JContainer left, JToken right)
{
foreach (var rightChild in right.Children<JProperty>())
{
var rightChildProperty = rightChild;
var leftProperty = left.SelectToken(rightChildProperty.Name);
if (leftProperty == null)
{
left.Add(rightChild);
}
else
{
var leftObject = leftProperty as JObject;
if (leftObject == null)
{
var leftParent = (JProperty) leftProperty.Parent;
leftParent.Value = rightChildProperty.Value;
}
else
{
MergeInto(leftObject, rightChildProperty.Value);
}
}
}
}
示例4: CheckApiErrorCode
/// <summary>
/// Check the 'error_code' field and throw the appropriate exception if non-null.
/// </summary>
/// <param name="apiResponse">Deserialized json response from a Keen API call.</param>
public static void CheckApiErrorCode(JContainer apiResponse)
{
if (apiResponse == null) return;
if (apiResponse is JArray) return;
var errorCode = (string) apiResponse.SelectToken("$.error_code");
if (errorCode != null)
{
var message = (string)apiResponse.SelectToken("$.message");
switch (errorCode)
{
case "InvalidApiKeyError":
throw new KeenInvalidApiKeyException(message);
case "ResourceNotFoundError":
throw new KeenResourceNotFoundException(message);
case "NamespaceTypeError":
throw new KeenNamespaceTypeException(message);
case "InvalidEventError":
throw new KeenInvalidEventException(message);
case "ListsOfNonPrimitivesNotAllowedError":
throw new KeenListsOfNonPrimitivesNotAllowedException(message);
case "InvalidBatchError":
throw new KeenInvalidBatchException(message);
case "InternalServerError":
throw new KeenInternalServerErrorException(message);
case "InvalidKeenNamespaceProperty":
throw new KeenInvalidKeenNamespacePropertyException(message);
default:
Debug.WriteLine("Unhandled error_code \"{0}\" : \"{1}\"", errorCode, message);
throw new KeenException(errorCode + " : " + message);
}
}
}
示例5: RegionPosition
/// <summary>
/// Initializes a new instance of the <see cref="Core.Models.RegionPosition"/> class.
/// </summary>
/// <param name="obj">JContainer Object.</param>
public RegionPosition(JContainer obj)
{
RegionX = (int)obj.SelectToken("RegionX");
RegionY = (int)obj.SelectToken("RegionY");
}