[mapguide-users] Get Identity Properties
Andy Morsell
amorsell at spatialgis.com
Thu Apr 2 12:11:10 EDT 2009
There's also some similar code in several places in the viewer files (both
AJAX and Fusion) and some of the sample applications. This is from
www/mapviewernet/search.aspx.:
String prop = (String)resProps[i];
int propType = features.GetPropertyType(prop);
String val = "";
switch (propType)
{
case MgPropertyType.Boolean:
val = features.GetBoolean(prop) ? "True" :
"False";
break;
case MgPropertyType.Single:
val = features.GetSingle(prop).ToString();
break;
case MgPropertyType.Double:
val = features.GetDouble(prop).ToString();
break;
case MgPropertyType.Int16:
val = features.GetInt16(prop).ToString();
break;
case MgPropertyType.Int32:
val = features.GetInt32(prop).ToString();
break;
case MgPropertyType.Int64:
val = features.GetInt64(prop).ToString();
break;
case MgPropertyType.String:
val = features.GetString(prop);
break;
case MgPropertyType.DateTime:
val = features.GetDateTime(prop).ToString();
break;
}
Andy Morsell, P.E.
Spatial Integrators, Inc.
www.SpatialGIS.com
-----Original Message-----
From: mapguide-users-bounces at lists.osgeo.org
[mailto:mapguide-users-bounces at lists.osgeo.org] On Behalf Of Jamo
Sent: Wednesday, April 01, 2009 11:38 PM
To: mapguide-users at lists.osgeo.org
Subject: Re: [mapguide-users] Get Identity Properties
Incase anyone is interested I figured it out... I no longer have to hard
code what the identity property is .
the following will read the feature reader and return the identity property
allowing me now to create more dynamic commands :)
I haven't filled in all the select cases as I'm not sure whats what there.
while (newFeatReader.ReadNext())
{
MgPropertyCollection idProps = new MgPropertyCollection();
MgResourceIdentifier myRes = new
MgResourceIdentifier(currentLayer.GetFeatureSourceId());
foreach (MgPropertyDefinition IdPropDef in
newFeatReader.GetClassDefinition().GetIdentityProperties())
{
switch (newFeatReader.GetPropertyType(IdPropDef.Name))
{
case 1:
// Response.Write("1");
break;
case 2:
// Response.Write("2");
break;
case 3:
// Response.Write("3");
break;
case 4:
// Response.Write("4");
break;
case 5:
// Response.Write("5");
break;
case 6:
// Response.Write("6");
break;
case 7:
idProps.Add(new MgInt32Property(IdPropDef.Name,
newFeatReader.GetInt32(IdPropDef.Name)));
// Response.Write("7");
break;
case 8:
// Response.Write("8");
break;
case 9:
// Response.Write("9");
break;
default:
// Response.Write("no valid type");
break;
}
}
MgSelection sel = new MgSelection();
sel.AddFeatureIds(currentLayer, currentClassName, idProps);
String selText = EscapeForHtml(sel.ToXml());
//do additional stuff with feature here....
}
--
View this message in context:
http://n2.nabble.com/Get-Identity-Properties-tp2567438p2573602.html
Sent from the MapGuide Users mailing list archive at Nabble.com.
_______________________________________________
mapguide-users mailing list
mapguide-users at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapguide-users
More information about the mapguide-users
mailing list