本文整理汇总了C#中JsonObject.TryGetArray方法的典型用法代码示例。如果您正苦于以下问题:C# JsonObject.TryGetArray方法的具体用法?C# JsonObject.TryGetArray怎么用?C# JsonObject.TryGetArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JsonObject
的用法示例。
在下文中一共展示了JsonObject.TryGetArray方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Handler
/// <summary>
/// Handles the incoming rest requests
/// </summary>
/// <param name="boundVariables"> The bound variables. </param>
/// <param name="operationInput"> The operation input. </param>
/// <param name="outputFormat"> The output format. </param>
/// <param name="requestProperties"> The request properties. </param>
/// <param name="responseProperties"> The response properties. </param>
/// <returns> </returns>
/// <exception cref="System.ArgumentNullException"></exception>
public static byte[] Handler(NameValueCollection boundVariables, JsonObject operationInput,
string outputFormat, string requestProperties,
out string responseProperties)
{
responseProperties = null;
var errors = new ErrorModel(400);
object[] geometryJson;
var found = operationInput.TryGetArray("geometry", out geometryJson);
if (!found || geometryJson.Length < 1)
errors.Message += "Value cannot be null: {0}. ".With("geometry");
double? durationThreshold;
found = operationInput.TryGetAsDouble("durationThreshold", out durationThreshold);
if (!found || !durationThreshold.HasValue)
durationThreshold = 0;
if (errors.HasErrors)
return Json(new ErrorContainer(errors));
var areaOfInterest = new AreaOfInterest
{
PointCollection = geometryJson.Cast<decimal>().ToList()
};
IPolygon4 polygon;
try
{
polygon = CommandExecutor.ExecuteCommand(new BuildPolygonFromPointsCommand(areaOfInterest));
}
catch (Exception ex)
{
errors.Message += ex.Message;
return Json(new ErrorContainer(errors));
}
SolarPotential solarValues = null;
try
{
solarValues =
CommandExecutor.ExecuteCommand(new GetSolarPotentialCommand(polygon,
ApplicationCache.PropertyValueIndexMap,
durationThreshold.GetValueOrDefault(0)));
}
catch (Exception ex)
{
errors.Message += ex.Message;
}
return Json(new SolarContainer(solarValues));
}
示例2: ListServices
/// <summary>
/// list of services in folder
/// </summary>
/// <param name="folder">name of folder</param>
public void ListServices(string folder)
{
try
{
string token = this.GenerateAGSToken();
string serviceUrl = this.urlRestAdmin + "/services/" + folder;
string postcontent = "f=json&token=" + token;
string result = this.GetResult(serviceUrl, postcontent);
JsonObject jsonObject = new JsonObject(result);
object[] folders = null;
if (jsonObject.Exists("folders") && jsonObject.TryGetArray("folders", out folders))
{
foreach (string subfolder in folders)
{
this.ListServices(subfolder);
}
}
object[] services = null;
if (jsonObject.Exists("services") && jsonObject.TryGetArray("services", out services))
{
IEnumerable<JsonObject> jsonObjectService = services.Cast<JsonObject>();
jsonObjectService.ToList().ForEach(jo =>
{
string serviceName;
jo.TryGetString("serviceName", out serviceName);
string folderName;
jo.TryGetString("folderName", out folderName);
Console.WriteLine(folderName + "/" + serviceName);
});
}
}
catch
{
throw;
}
}
示例3: convertAnyJsonGeometry
private IGeometry convertAnyJsonGeometry(JsonObject jsonObjectGeometry)
{
object[] objArray;
//// double? nullable,
if (jsonObjectGeometry.TryGetArray("rings", out objArray))
{
return Conversion.ToGeometry(jsonObjectGeometry, esriGeometryType.esriGeometryPolygon);
}
if (jsonObjectGeometry.TryGetArray("paths", out objArray))
{
return Conversion.ToGeometry(jsonObjectGeometry, esriGeometryType.esriGeometryPolyline);
}
if (jsonObjectGeometry.TryGetArray("points", out objArray))
{
return Conversion.ToGeometry(jsonObjectGeometry, esriGeometryType.esriGeometryMultipoint);
}
try
{
return Conversion.ToGeometry(jsonObjectGeometry, esriGeometryType.esriGeometryPoint);
}
catch
{
try
{
return Conversion.ToGeometry(jsonObjectGeometry, esriGeometryType.esriGeometryEnvelope);
}
catch
{
logger.LogMessage(ServerLogger.msgType.debug, "process input params", 8000, "Couldn't convert geometry!");
return null;
}
}
}
示例4: Handler
/// <summary>
/// Handles the incoming rest requests
/// </summary>
/// <param name="boundVariables"> The bound variables. </param>
/// <param name="operationInput"> The operation input. </param>
/// <param name="outputFormat"> The output format. </param>
/// <param name="requestProperties"> The request properties. </param>
/// <param name="responseProperties"> The response properties. </param>
/// <returns> </returns>
/// <exception cref="System.ArgumentNullException"></exception>
public static byte[] Handler(NameValueCollection boundVariables, JsonObject operationInput,
string outputFormat, string requestProperties,
out string responseProperties)
{
responseProperties = null;
string layerName;
object[] objectid;
var found = operationInput.TryGetString("layerName", out layerName);
if (!found || string.IsNullOrEmpty(layerName))
{
throw new ArgumentNullException("layerName");
}
found = operationInput.TryGetArray("objectid", out objectid);
if (!found || objectid == null || objectid.Length < 1)
{
throw new ArgumentNullException("objectid");
}
var searchArgs = new EnvelopeArgs(layerName, objectid.Cast<int>().ToArray());
var connector = SdeConnectorFactory.Create(layerName);
if (connector == null)
{
return Json(new
{
Message = "Database does not exist for {0}".With(layerName)
});
}
var workspace = connector.Connect();
var featureWorkSpace = workspace as IFeatureWorkspace;
if (featureWorkSpace == null)
{
return Json(new
{
Message = "Error connecting to SDE."
});
}
var response = CommandExecutor.ExecuteCommand(new GetEnvelopeCommand(searchArgs, featureWorkSpace));
if (response == null)
{
return Json(new
{
Message = "No features found in {0} with the Id of {1}.".With(
searchArgs.LayerName, string.Join(",", searchArgs.ObjectIds))
});
}
return Json(response);
}
示例5: Handler
/// <summary>
/// Handles the incoming rest requests
/// </summary>
/// <param name="boundVariables"> The bound variables. </param>
/// <param name="operationInput"> The operation input. </param>
/// <param name="outputFormat"> The output format. </param>
/// <param name="requestProperties"> The request properties. </param>
/// <param name="responseProperties"> The response properties. </param>
/// <returns> </returns>
/// <exception cref="System.ArgumentNullException"></exception>
public static byte[] Handler(NameValueCollection boundVariables, JsonObject operationInput,
string outputFormat, string requestProperties,
out string responseProperties)
{
responseProperties = null;
var errors = new ErrorModel(400);
string layerName;
double? utmx, utmy;
object[] attributeListObj;
var found = operationInput.TryGetString("layerName", out layerName);
if (!found || string.IsNullOrEmpty(layerName))
{
throw new ArgumentNullException("layerName");
}
found = operationInput.TryGetAsDouble("utmx", out utmx);
if (!found || !utmx.HasValue)
{
throw new ArgumentNullException("utmx");
}
found = operationInput.TryGetAsDouble("utmy", out utmy);
if (!found || !utmy.HasValue)
{
throw new ArgumentNullException("utmy");
}
found = operationInput.TryGetArray("attributeList", out attributeListObj);
if (!found || attributeListObj == null || attributeListObj.Length < 1)
{
throw new ArgumentNullException("attributeList");
}
var attributeList = attributeListObj.Cast<string>().ToArray();
var searchArgs = new PointInPolyArgs(layerName, utmx.Value, utmy.Value, attributeList);
var connector = SdeConnectorFactory.Create(layerName);
if (connector == null)
{
return Json(new
{
Message = "Database does not exist for {0}".With(layerName)
});
}
var workspace = connector.Connect();
var featureWorkSpace = workspace as IFeatureWorkspace;
if (featureWorkSpace == null)
{
return Json(new
{
Message = "Error connecting to SDE."
});
}
var response = CommandExecutor.ExecuteCommand(new PointInPolygoinQueryCommand(searchArgs, featureWorkSpace));
if (response == null)
{
return Json(new
{
Message = "No features found in {2} at the location {0}, {1}.".With(
searchArgs.Point.X, searchArgs.Point.Y, searchArgs.LayerName)
});
}
return Json(response);
}