本文整理汇总了C#中JsonArray.RequireArgument方法的典型用法代码示例。如果您正苦于以下问题:C# JsonArray.RequireArgument方法的具体用法?C# JsonArray.RequireArgument怎么用?C# JsonArray.RequireArgument使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JsonArray
的用法示例。
在下文中一共展示了JsonArray.RequireArgument方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadPoint
public static MapPoint ReadPoint( JsonArray coordinates )
{
coordinates.RequireArgument<JsonArray>( "coordinates" ).NotNull<JsonArray>();
return ReadCoordinates( coordinates );
}
示例2: ReadCoordinates
public static MapPoint ReadCoordinates( JsonArray coordinates )
{
coordinates.RequireArgument<JsonArray>( "coordinates" ).NotNull<JsonArray>();
if( coordinates.Count > 3 )
throw new InvalidOperationException( "Only a maximum of 3 coordinate values can be present." );
if( coordinates.Count < 2 )
throw new InvalidOperationException( "A minimum of 2 coordinate values must be present." );
return new MapPoint( (double)coordinates[0], (double)coordinates[ 1 ] );
}
示例3: ReadLineString
public static PointCollection ReadLineString( JsonArray points )
{
points.RequireArgument<JsonArray>( "points" ).NotNull<JsonArray>();
PointCollection linestring = new PointCollection();
foreach( JsonValue entry in points )
{
JsonArray coordinates = entry as JsonArray;
linestring.Add(ReadPoint(coordinates));
}
return linestring;
}
示例4: ReadMultiPoint
public static MultiPoint ReadMultiPoint( JsonArray points )
{
points.RequireArgument<JsonArray>( "points" ).NotNull<JsonArray>();
MultiPoint multiPoint = new MultiPoint();
foreach( JsonValue entry in points )
{
JsonArray coordinates = entry as JsonArray;
multiPoint.Points.Add(ReadPoint(coordinates));
}
return multiPoint;
}
示例5: ReadRing
private static PointCollection ReadRing( JsonArray points )
{
points.RequireArgument<JsonArray>( "points" ).NotNull<JsonArray>();
PointCollection ringCoords = new PointCollection();
foreach( JsonValue entry in points )
{
JsonArray coordinates = entry as JsonArray;
ringCoords.Add( ReadPoint( coordinates ) );
}
return ringCoords;
}
示例6: ReadMultiLineString
private static Geometry ReadMultiLineString( JsonArray paths )
{
paths.RequireArgument<JsonArray>( "paths" ).NotNull<JsonArray>();
Polyline lines = new Polyline();
foreach( JsonValue entry in paths )
{
JsonArray line = entry as JsonArray;
lines.Paths.Add(ReadLineString(line));
}
return lines;
}
示例7: ReadRings
private static Polygon ReadRings( JsonArray rings )
{
rings.RequireArgument<JsonArray>( "rings" ).NotNull<JsonArray>();
Polygon areas = new Polygon();
foreach( JsonValue entry in rings )
{
JsonArray line = entry as JsonArray;
areas.Rings.Add( ReadRing( line ) );
}
return areas;
}
示例8: ReadPolygon
private static Polygon ReadPolygon( JsonArray rings )
{
rings.RequireArgument<JsonArray>( "rings" ).NotNull<JsonArray>();
return ReadRings( rings );
}
示例9: ReadMultiPolygon
private static Geometry ReadMultiPolygon( JsonArray polygons )
{
polygons.RequireArgument<JsonArray>( "polygons" ).NotNull<JsonArray>();
Polygon areas = new Polygon();
foreach( JsonValue polygon in polygons )
{
JsonArray polygonCoords = polygon as JsonArray;
Polygon poly = ReadPolygon( polygonCoords );
poly.Rings.ForEach<PointCollection>( item => areas.Rings.Add( item ) );
}
return areas;
}
示例10: ReadLayerReferenceArray
public static Dictionary<int, string> ReadLayerReferenceArray( JsonArray json )
{
json.RequireArgument<JsonArray>( "json" ).NotNull<JsonArray>();
Dictionary<int, string> lyrRefs = new Dictionary<int, string>();
foreach( JsonValue item in json )
{
if( !( item is JsonObject ) )
throw new FormatException( "All entries in a layer reference array should be of type JsonObjects." );
KeyValuePair<int, string> entry = ReadLayerReference( item as JsonObject );
lyrRefs.Add(entry.Key, entry.Value );
}
return lyrRefs;
}
示例11: ReadFieldMetadataArray
public static List<FieldMetadata> ReadFieldMetadataArray( JsonArray json )
{
json.RequireArgument<JsonArray>( "json" ).NotNull<JsonArray>();
List<FieldMetadata> flds = new List<FieldMetadata>();
foreach( JsonValue item in json )
{
if( !( item is JsonObject ) )
throw new FormatException( "All entries in a field metadata array should be of type JsonObject." );
FieldMetadata fld = ReadFieldMetadata( item as JsonObject );
flds.Add( fld );
}
return flds;
}