当前位置: 首页>>代码示例>>C#>>正文


C# JsonObject.TryGetObject方法代码示例

本文整理汇总了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());
        }
开发者ID:Esri,项目名称:arcobjects-sdk-community-samples,代码行数:62,代码来源:NetEditFeaturesRESTSOE.cs

示例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;
 }
开发者ID:NGFieldScope,项目名称:FieldScope-SOE,代码行数:23,代码来源:FieldScopeSOE.cs


注:本文中的JsonObject.TryGetObject方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。