本文整理汇总了C#中JsonObject.GetNumberValue方法的典型用法代码示例。如果您正苦于以下问题:C# JsonObject.GetNumberValue方法的具体用法?C# JsonObject.GetNumberValue怎么用?C# JsonObject.GetNumberValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JsonObject
的用法示例。
在下文中一共展示了JsonObject.GetNumberValue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 ErrorContainer(400);
var wkid = 26912;
//pull out all the variables
var featureClass = operationInput.GetStringValue("featureClass");
var returnValues = operationInput.GetStringValue("returnValues");
var predicate = operationInput.GetStringValue("predicate", nullable: true);
var geometryJson = operationInput.GetStringValue("geometry", nullable: true);
var wkidInput = operationInput.GetNumberValue("wkid", nullable: true);
var bufferInput = operationInput.GetNumberValue("buffer", nullable: true);
if (wkidInput > 0)
{
wkid = Convert.ToInt32(wkidInput);
}
var isSafeSqlCommand = new IsSafeSqlCommand(new[]
{
featureClass, returnValues, predicate
});
if (!CommandExecutor.ExecuteCommand(isSafeSqlCommand))
{
errors.Add("Input appears to be unsafe. That is all I will tell you.");
}
GeometryContainer container = null;
ISpatialReference newSpatialRefefence = null;
ISpatialReferenceFactory srFactory = null;
//reproject to our data's spatial reference
if (wkid != 26912)
{
srFactory = new SpatialReferenceEnvironmentClass();
var isProjected = true;
try
{
newSpatialRefefence = srFactory.CreateProjectedCoordinateSystem(wkid);
}
catch (ArgumentException)
{
isProjected = false;
}
if (!isProjected)
{
newSpatialRefefence = srFactory.CreateGeographicCoordinateSystem(wkid);
}
}
//input has a geometry - deal with it
if (!string.IsNullOrEmpty(geometryJson))
{
var extractGeometryCommand = new ExtractGeometryCommand(geometryJson);
container = CommandExecutor.ExecuteCommand(extractGeometryCommand);
if (container == null)
{
var message = "Geometry coordinates appear to be invalid.";
if (!string.IsNullOrEmpty(extractGeometryCommand.ErrorMessage))
{
message += " Maybe this information can help: {0}".With(extractGeometryCommand.ErrorMessage);
}
errors.Add(message);
}
//input is in different projection - reproject it
if (wkid != 26912)
{
if (srFactory == null)
{
srFactory = new SpatialReferenceEnvironmentClass();
}
var toUtm = srFactory.CreateProjectedCoordinateSystem(26912);
if (container != null)
{
foreach (var points in container.Coordinates)
{
var point = new PointClass
{
//.........这里部分代码省略.........
示例2: 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 ErrorContainer(400);
var wkid = 26912;
const string featureClass = "SGID10.TRANSPORTATION.UDOTRoutes_LRS";
//pull out all the variables
var x = operationInput.GetNumberValue("x");
var y = operationInput.GetNumberValue("y");
var wkidInput = operationInput.GetNumberValue("wkid", nullable: true);
var bufferInput = operationInput.GetNumberValue("buffer", nullable: true);
var includeRamps = operationInput.GetNumberValue("includeRamps", nullable: true);
ISpatialReference newSpatialRefefence = null;
ISpatialReferenceFactory srFactory = new SpatialReferenceEnvironment();
if (wkidInput > 0)
{
wkid = Convert.ToInt32(wkidInput);
}
if (bufferInput < 1 || bufferInput > 200)
{
bufferInput = 100;
}
//reproject to our data's spatial reference
if (wkid != 26912)
{
var isProjected = true;
try
{
newSpatialRefefence = srFactory.CreateProjectedCoordinateSystem(wkid);
}
catch (ArgumentException)
{
isProjected = false;
}
if (!isProjected)
{
newSpatialRefefence = srFactory.CreateGeographicCoordinateSystem(wkid);
}
}
var utm = srFactory.CreateProjectedCoordinateSystem(26912);
IPoint point = new Point
{
X = x,
Y = y,
SpatialReference = utm
};
//input is in different projection - reproject it
if (wkid != 26912)
{
point = new Point
{
X = x,
Y = y,
SpatialReference = newSpatialRefefence
};
point.Project(utm);
}
var bufferGeometry = CommandExecutor.ExecuteCommand(
new BufferGeometryCommand(new GeometryContainer
{
Geometry = point
}, bufferInput));
var sdeConnector = SdeConnectorFactory.Create(featureClass);
if (sdeConnector == null)
{
errors.Add("{0} was not found in our database. ".With(featureClass) +
"A valid example would be SGID10.BOUNDARIES.Counties.");
}
if (errors.HasErrors)
{
return Json(errors);
}
// ReSharper disable PossibleNullReferenceException because of returning errors if null
//.........这里部分代码省略.........