本文整理汇总了C#中JsonObject.AddJsonObject方法的典型用法代码示例。如果您正苦于以下问题:C# JsonObject.AddJsonObject方法的具体用法?C# JsonObject.AddJsonObject怎么用?C# JsonObject.AddJsonObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JsonObject
的用法示例。
在下文中一共展示了JsonObject.AddJsonObject方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ToJsonObject
public JsonObject ToJsonObject()
{
JsonObject result = new JsonObject();
result.AddString("name", Name);
result.AddLong("id", ID);
IRasterProps props = Raster as IRasterProps;
result.AddLong("rows", props.Width);
result.AddLong("columns", props.Height);
result.AddJsonObject("extent", Conversion.ToJsonObject(props.Extent));
return result;
}
示例2: ToJsonObject
public JsonObject ToJsonObject()
{
byte[] jsonBytes = Conversion.ToJson((IGeometry)this.Extent);
JsonObject env = new JsonObject(Encoding.UTF8.GetString(jsonBytes));
JsonObject jo = new JsonObject();
jo.AddString("name", Name);
jo.AddLong("id", ID);
jo.AddJsonObject("extent", env);
return jo;
}
示例3: CreateService
/// <summary>
/// create service type MapServer
/// </summary>
/// <returns>>True if successfully created</returns>
public bool CreateService()
{
try
{
string token = this.GenerateAGSToken();
string serviceUrl = this.urlRestAdmin + "/services/createService";
JsonObject jsonObject = new JsonObject();
jsonObject.AddString("serviceName", "Test");
//服务类型
jsonObject.AddString("type", Enum.GetName(typeof(ServiceType), ServiceType.GPServer));
jsonObject.AddString("description", "This is an example");
//不同的服务类型,其capabilities是不同的,地图服务的为Map,query和data
// jsonObject.AddString("capabilities", "Map,Query,Data");
jsonObject.AddString("capabilities","Uploads");//gp 服务的capabilities
jsonObject.AddString("clusterName", "default");
jsonObject.AddLong("minInstancesPerNode", 1);
jsonObject.AddLong("maxInstancesPerNode", 2);
jsonObject.AddLong("maxWaitTime", 60);
jsonObject.AddLong("maxStartupTime", 300);
jsonObject.AddLong("maxIdleTime", 1800);
jsonObject.AddLong("maxUsageTime", 600);
jsonObject.AddLong("recycleInterval", 24);
jsonObject.AddString("loadBalancing", Enum.GetName(typeof(LoadBalancing), LoadBalancing.ROUND_ROBIN));
jsonObject.AddString("isolationLevel", Enum.GetName(typeof(IsolationLevel), IsolationLevel.HIGH));
JsonObject jsonObjectProperties = new JsonObject();
// see for a list complete http://resources.arcgis.com/en/help/server-admin-api/serviceTypes.html
jsonObjectProperties.AddLong("maxBufferCount", 100); // optional 100
jsonObjectProperties.AddString("virtualCacheDir", this.urlRestServer + "/arcgiscache"); // optional
jsonObjectProperties.AddLong("maxImageHeight", 2048); // optional 2048
jsonObjectProperties.AddLong("maxRecordCount", 1000); // optional 500
//10.1中服务是通过msd的形式发布的,所以创建地图服务时候将mxd转换成msd的形式,创建msd的形式而其他服务的数据发布形式,参考上面的链接
// jsonObjectProperties.AddString("filePath", @"C:\AvGis\Test\mappa\UTM_ReteFognaria.msd"); //地图服务 required
jsonObjectProperties.AddString( "toolbox",@"d:\Buffer.tbx");//gp服务使用的是路径创建gp服务的路径
jsonObjectProperties.AddLong("maxImageWidth", 2048); // optional 2048
jsonObjectProperties.AddBoolean("cacheOnDemand", false); // optional false
jsonObjectProperties.AddString("virtualOutputDir", this.urlRestServer + "/arcgisoutput");
jsonObjectProperties.AddString("outputDir", @"C:\arcgisserver\directories\arcgisoutput");
jsonObjectProperties.AddString("jobsDirectory", @"C:\arcgisserver\directories\arcgisjobs"); // required
jsonObjectProperties.AddString("supportedImageReturnTypes", "MIME+URL"); // optional MIME+URL
jsonObjectProperties.AddBoolean("isCached", false); // optional false
jsonObjectProperties.AddBoolean("ignoreCache", false); // optional false
jsonObjectProperties.AddBoolean("clientCachingAllowed", false); // optional true
jsonObjectProperties.AddString("cacheDir", @"C:\arcgisserver\directories\arcgiscache"); // optional
jsonObject.AddJsonObject("properties", jsonObjectProperties);
string result = this.GetResult(serviceUrl, "service=" +HttpUtility.UrlEncode(jsonObject.ToJson()) + "&f=json&token=" + token);
return this.HasSuccess(result);
}
catch
{
return false;
}
}
示例4: getSchemaJSON
//Retrieves feature schema for selected layer that could be used to provide data for editing.
private JsonObject getSchemaJSON()
{
Fields fields = (Fields) editLayerInfo.Fields;
int fieldCount = fields.FieldCount;
JsonObject attributeJsonObject = new JsonObject();
for (int i = 0; i < fieldCount; i++)
{
Field field = (Field)fields.get_Field(i);
String typeStr = null;
switch (field.Type)
{
case esriFieldType.esriFieldTypeBlob:
typeStr = "Blob";
break;
case esriFieldType.esriFieldTypeDate:
typeStr = "Date";
break;
case esriFieldType.esriFieldTypeDouble:
typeStr = "Double";
break;
case esriFieldType.esriFieldTypeInteger:
typeStr = "Integer";
break;
case esriFieldType.esriFieldTypeRaster:
typeStr = "Raster";
break;
case esriFieldType.esriFieldTypeSmallInteger:
typeStr = "Integer";
break;
case esriFieldType.esriFieldTypeString:
typeStr = "String";
break;
case esriFieldType.esriFieldTypeXML:
typeStr = "XML";
break;
default:
break;
}
if (typeStr != null && typeStr.Length > 0 && field.Editable)
{
attributeJsonObject.AddString(field.Name, typeStr);
}
}
JsonObject featuresJsonObject = new JsonObject();
featuresJsonObject.AddJsonObject("attributes", attributeJsonObject);
JsonObject geometryJson = new JsonObject();
switch (((IFeatureClass)fc).ShapeType)
{
case esriGeometryType.esriGeometryPoint:
geometryJson.AddString("x", "x");
geometryJson.AddString("y", "y");
geometryJson.AddString("z", "z");
break;
case esriGeometryType.esriGeometryMultipoint:
geometryJson.AddString("hasM", "true | false");
geometryJson.AddString("hasZ", "true | false");
geometryJson.AddString("points",
"[ [ x1, y1, z1, m1 ] , [ x2, y2, z2, m2 ], ... ]");
break;
case esriGeometryType.esriGeometryPolyline:
geometryJson.AddString("hasM", "true | false");
geometryJson.AddString("hasZ", "true | false");
geometryJson.AddString("paths", "["
+ "[ [x11, y11, z11, m11], [x12, y12, z12, m12] ],"
+ "[ [x21, y21, z21, m21], [x22, y22, z22, m22] ]]");
break;
case esriGeometryType.esriGeometryPolygon:
geometryJson.AddString("hasM", "true | false");
geometryJson.AddString("hasZ", "true | false");
geometryJson.AddString
("rings",
"["
+ "[ [x11, y11, z11, m11], [x12, y12, z12, m12], ..., [x11, y11, z11, m11] ],"
+ "[ [x21, y21, z21, m21], [x22, y22, z22, m22], ..., [x21, y21, z21, m21] ]]");
break;
default: break;
}
JsonObject srJson = new JsonObject();
srJson.AddString("wkid", "wkid");
//.........这里部分代码省略.........
示例5: GetErrorResponse
private JsonObject GetErrorResponse(string message)
{
var error = new JsonObject();
error.AddLong("code", 0);
error.AddString("message", message);
var response = new JsonObject();
response.AddJsonObject("error", error);
return response;
}
示例6: RootResHandler
private byte[] RootResHandler(NameValueCollection boundVariables, string outputFormat, string requestProperties, out string responseProperties)
{
responseProperties = null;
IServerEnvironment3 senv = GetServerEnvironment() as IServerEnvironment3;
JsonObject result = new JsonObject();
JsonObject suinfoj = new JsonObject();
//get user info and serialize into JSON
IServerUserInfo suinfo = senv.UserInfo;
if (null != suinfo)
{
suinfoj.AddString("currentUser", suinfo.Name);
IEnumBSTR roles = suinfo.Roles;
List<string> rolelist = new List<string>();
if (null != roles)
{
string role = roles.Next();
while (!string.IsNullOrEmpty(role))
{
rolelist.Add(role);
role = roles.Next();
}
}
suinfoj.AddArray("roles", rolelist.ToArray());
result.AddJsonObject("serverUserInfo", suinfoj);
}
else
{
result.AddJsonObject("serverUserInfo", null);
}
return Encoding.UTF8.GetBytes(result.ToJson());
}
示例7: backgroundWorker1_DoWork
//.........这里部分代码省略.........
foreach (JsonObject js_field in ls_fields_cache)
{
object value = fea_poi.get_Value(i);
string fieldtype;
js_field.TryGetString("type", out fieldtype);
string fieldname;
js_field.TryGetString("name", out fieldname);
#region
if (fieldtype == Enum.GetName(typeof(esriFieldType), esriFieldType.esriFieldTypeString))
{
js_attributes.AddString(fieldname, value.ToString());
}
else if (fieldtype == Enum.GetName(typeof(esriFieldType), esriFieldType.esriFieldTypeOID))
{
js_attributes.AddLong(fieldname, long.Parse(value.ToString()));
}
else if (fieldtype == Enum.GetName(typeof(esriFieldType), esriFieldType.esriFieldTypeInteger))
{
if (value.ToString() == "")
{
value = 0;
}
js_attributes.AddLong(fieldname, long.Parse(value.ToString()));
}
else if (fieldtype == Enum.GetName(typeof(esriFieldType), esriFieldType.esriFieldTypeSmallInteger))
{
if (value.ToString() == "")
{
value = 0;
}
js_attributes.AddLong(fieldname, long.Parse(value.ToString()));
}
else if (fieldtype == Enum.GetName(typeof(esriFieldType), esriFieldType.esriFieldTypeDouble))
{
if (value.ToString() == "")
{
value = 0;
}
js_attributes.AddDouble(fieldname, double.Parse(value.ToString()));
}
else if (fieldtype == Enum.GetName(typeof(esriFieldType), esriFieldType.esriFieldTypeDate))
{
if (value.ToString() == "")
{
value = DateTime.MinValue;
}
js_attributes.AddDate(fieldname, DateTime.Parse(value.ToString()));
}
else if (fieldtype == Enum.GetName(typeof(esriFieldType), esriFieldType.esriFieldTypeSingle))
{
if (value.ToString() == "")
{
value = 0;
}
js_attributes.AddBoolean(fieldname, bool.Parse(value.ToString()));
}
#endregion
i++;
}
js_fea.AddJsonObject("attributes", js_attributes);
js_fea.AddJsonObject("geometry", Conversion.ToJsonObject(fea_poi.Shape));
}
else
{
IAnnotationFeature anno_fea = fea_poi as IAnnotationFeature;
ITextElement ele = anno_fea.Annotation as ITextElement;
//string text = ele.Text.Replace(System.Environment.NewLine, " ");
string text = ele.Text;
ITextSymbol sym = ele.Symbol;
IFontDisp font = sym.Font;
double symsize = sym.Size;
string fontname = font.Name;
decimal fontsize = font.Size;
string.Format(@"a"":""");
JsonObject js_symbol = new JsonObject(
string.Format(@"{{""type"" : ""esriTS"",""color"": [255,255,255],""haloSize"" : 0,""haloColor"" : [255,255,255,0],""verticalAlignment"" : ""bottom"",""horizontalAlignment"" : ""center"",""size"": {0},""angle"": 0,""xoffset"": 0,""yoffset"": 0,""font"" : {{""family"" : ""{2}"",""size"" : {3},""style"" : ""normal"",""weight"" : ""normal"",""decoration"" : ""none""}},""text"":""{1}""}}",symsize,text,fontname,fontsize));
js_fea.AddJsonObject("symbol", js_symbol);
IArea pshp = fea_poi.Shape as IArea;
js_fea.AddJsonObject("geometry", Conversion.ToJsonObject(pshp.Centroid));
}
ls_features.Add(js_fea);
fea_poi = cur_poi.NextFeature();
}
response.AddArray("features", ls_features.ToArray());
client.StringSet(ns+grid_id.ToString(), response.ToJson());
ReleaseCOMObject(cur_poi);
grid_id++;
progressBar1.BeginInvoke((Action)(() =>
{
progressBar1.Increment(1);
}));
}
}
MessageBox.Show("Build Cache Successfully!");
this.button1.BeginInvoke((Action)(()=>
{
ListCaches();
this.button1.Enabled = true;
}));
}
示例8: BuildMeta
/// <summary>
/// Build Meta Info
/// </summary>
private void BuildMeta()
{
IFeatureClass fc_poi = m_fcName.Open() as IFeatureClass;
IGeoDataset ds_poi = fc_poi as IGeoDataset;
int xmin = (int)Math.Floor(ds_poi.Extent.XMin);
int ymin = (int)Math.Floor(ds_poi.Extent.YMin);
int xmax = (int)Math.Ceiling(ds_poi.Extent.XMax);
int ymax = (int)Math.Ceiling(ds_poi.Extent.YMax);
int size = int.Parse(this.tbxSize.Text);
int step = (int)Math.Ceiling((xmax - xmin) * 1.0 / size);
string ns = "poi:" + this.tbxCacheName.Text + ":";
IDatabase client = m_redis.GetDatabase();
client.StringSet(ns + "size", size.ToString());
client.StringSet(ns + "xmin", xmin.ToString());
client.StringSet(ns + "ymin", ymin.ToString());
client.StringSet(ns + "xmax", xmax.ToString());
client.StringSet(ns + "ymax", ymax.ToString());
client.StringSet(ns + "step", step.ToString());
JsonObject response = new JsonObject();
List<JsonObject> ls_fields_cache = new List<JsonObject>();
for (int i = 0; i < fc_poi.Fields.FieldCount; i++)
{
IField field = fc_poi.Fields.get_Field(i);
JsonObject js_f = new JsonObject();
js_f.AddString("name", field.Name);
js_f.AddString("type", Enum.GetName(typeof(esriFieldType), field.Type));
js_f.AddString("alias", field.AliasName);
if (field.Type == esriFieldType.esriFieldTypeString)
{
js_f.AddString("length", field.Length.ToString());
}
else
{
js_f.AddString("length", "");
}
ls_fields_cache.Add(js_f);
}
response.AddArray("fields", ls_fields_cache.ToArray());
if (fc_poi.ShapeType == esriGeometryType.esriGeometryPoint)
{
response.AddString("geometryType", "esriGeometryPoint");
}
else if (fc_poi.ShapeType == esriGeometryType.esriGeometryPolyline)
{
response.AddString("geometryType", "esriGeometryPolyline");
}
else if (fc_poi.ShapeType == esriGeometryType.esriGeometryPolygon)
{
response.AddString("geometryType", "esriGeometryPolygon");
}
IGeoDataset gds_poi = fc_poi as IGeoDataset;
JsonObject js_sr = new JsonObject();
js_sr.AddLong("wkid", gds_poi.SpatialReference.FactoryCode);
response.AddJsonObject("spatialReference", js_sr);
client.StringSet(ns + "response", response.ToJson());
client.SetAdd("poi:caches", this.tbxCacheName.Text);
}
示例9: ToJsonObject
public JsonObject ToJsonObject()
{
JsonObject result = new JsonObject();
if (Attributes.Count > 0) {
JsonObject attributes = new JsonObject();
foreach (KeyValuePair<string, object> kvp in Attributes) {
attributes.AddObject(kvp.Key, kvp.Value);
}
result.AddJsonObject("attributes", attributes);
}
if (Geometry != null) {
result.AddJsonObject("geometry", Conversion.ToJsonObject(Geometry));
}
return result;
}