本文整理汇总了C#中JsonObject.TryGetObject方法的典型用法代码示例。如果您正苦于以下问题:C# JsonObject.TryGetObject方法的具体用法?C# JsonObject.TryGetObject怎么用?C# JsonObject.TryGetObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JsonObject
的用法示例。
在下文中一共展示了JsonObject.TryGetObject方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: editFeatureOperHandler
private byte[] editFeatureOperHandler(NameValueCollection boundVariables,
JsonObject operationInput,
string outputFormat,
string requestProperties,
out string responseProperties)
{
responseProperties = null;
// get the id of the feature to be edited
object featureIdObj;
operationInput.TryGetObject("featureId", out featureIdObj);
int updateFeatureId = Convert.ToInt32(featureIdObj.ToString());
object featureJSONObj;
operationInput.TryGetObject("featureJSON", out featureJSONObj);
JsonObject updateFeatureJSON = (JsonObject)featureJSONObj;
// set a filter for the specific feature
QueryFilter queryFilter = new QueryFilter();
if (this.fc == null)
{
return createErrorObject(
406,
"Incorrect layer id provided.",
new String[] { "Please provide layer id of a feature layer." });
}
IClass myClass = (IClass) this.fc;
queryFilter.WhereClause = myClass.OIDFieldName + "=" + updateFeatureId;
IFeatureCursor featureCursor = this.fc.Search(queryFilter, false);
// attempt retrieval of the feature and check if it does exist
IFeatureCursor myFeatureCursor = (IFeatureCursor) featureCursor;
IFeature updateFeature = myFeatureCursor.NextFeature();
if (updateFeature == null) {
return createErrorObject(
406,
"Incorrect feature id provided.",
new String[] { "No feature exists for feature id "
+ updateFeatureId + "." });
}
JsonObject response = new JsonObject();
// edit feature
string result = System.Text.Encoding.GetEncoding("utf-8").GetString(performEdits(updateFeature, updateFeatureJSON));
featureCursor.Flush();
if (result.Equals(System.Boolean.TrueString))
{
response.AddString("status", "success");
response.AddString("message", "Feature " + updateFeatureId + " updated");
}
else
{
response.AddString("status", "failure");
response.AddString("message", result);
}
// send response back to client app
return Encoding.UTF8.GetBytes(response.ToJson());
}
示例2: GetSpatialReferenceParam
protected ISpatialReference GetSpatialReferenceParam(JsonObject input, string name)
{
object outSRParam = null;
if (input.TryGetObject(name, out outSRParam)) {
ISpatialReferenceFactory factory = new SpatialReferenceEnvironment();
if (outSRParam is int) {
return (factory as ISpatialReferenceFactory2).CreateSpatialReference((int)outSRParam);
} else if (outSRParam is JsonObject) {
JsonObject jsonParam = outSRParam as JsonObject;
long? wkid;
string wkt;
if (jsonParam.TryGetAsLong("wkid", out wkid)) {
return (factory as ISpatialReferenceFactory2).CreateSpatialReference((int)wkid.Value);
} else if (jsonParam.TryGetString("wkt", out wkt)) {
ISpatialReference result;
int bytesRead;
(factory as ISpatialReferenceFactory3).CreateESRISpatialReference(wkt, out result, out bytesRead);
return result;
}
}
}
return null;
}