The example code below convers the concept of System.Reflection.
Also it is a Window application, but I have write Console.WriteLine() method in it, so u should run it in the command line like this
eg: application.exe >info.txt
1
mapxtreme2004经典代码之二:TableInfo private void button2_Click( object sender, System.EventArgs e)
2
mapxtreme2004经典代码之二:TableInfo
mapxtreme2004经典代码之二:TableInfo
mapxtreme2004经典代码之二:TableInfo {
3
mapxtreme2004经典代码之二:TableInfo Table table = MapInfo.Engine.Session.Current.Catalog[this.mapControl1.Map.Layers[0].Alias];
4
mapxtreme2004经典代码之二:TableInfo 5
mapxtreme2004经典代码之二:TableInfo TableInfo ti = table.TableInfo;
6
mapxtreme2004经典代码之二:TableInfo Type type = ti.GetType();
7
mapxtreme2004经典代码之二:TableInfo 8
mapxtreme2004经典代码之二:TableInfo PropertyInfo[] api = type.GetProperties();
9
mapxtreme2004经典代码之二:TableInfo string s1="";
10
mapxtreme2004经典代码之二:TableInfo foreach(PropertyInfo pi in api)
11
mapxtreme2004经典代码之二:TableInfo
mapxtreme2004经典代码之二:TableInfo
mapxtreme2004经典代码之二:TableInfo {
12
mapxtreme2004经典代码之二:TableInfo s1 += pi.Name +"="+ pi.GetValue(ti,null)+"\r\n";
13
mapxtreme2004经典代码之二:TableInfo }
14
mapxtreme2004经典代码之二:TableInfo 15
mapxtreme2004经典代码之二:TableInfo Console.WriteLine(s1);
16
mapxtreme2004经典代码之二:TableInfo Console.WriteLine();
17
mapxtreme2004经典代码之二:TableInfo 18
mapxtreme2004经典代码之二:TableInfo s1="";
19
mapxtreme2004经典代码之二:TableInfo foreach(PropertyInfo pi in api)
20
mapxtreme2004经典代码之二:TableInfo
mapxtreme2004经典代码之二:TableInfo
mapxtreme2004经典代码之二:TableInfo {
21
mapxtreme2004经典代码之二:TableInfo s1 += pi.Name +"="+ pi.GetValue(ti,null)+"\r\n";
22
mapxtreme2004经典代码之二:TableInfo }
23
mapxtreme2004经典代码之二:TableInfo 24
mapxtreme2004经典代码之二:TableInfo 25
mapxtreme2004经典代码之二:TableInfo s1+="\r\n";
26
mapxtreme2004经典代码之二:TableInfo 27
mapxtreme2004经典代码之二:TableInfo FieldInfo[] afi = type.GetFields();
28
mapxtreme2004经典代码之二:TableInfo foreach(FieldInfo fi in afi)
29
mapxtreme2004经典代码之二:TableInfo
mapxtreme2004经典代码之二:TableInfo
mapxtreme2004经典代码之二:TableInfo {
30
mapxtreme2004经典代码之二:TableInfo s1 += fi.Name+"="+fi.GetValue(ti);
31
mapxtreme2004经典代码之二:TableInfo }
32
mapxtreme2004经典代码之二:TableInfo 33
mapxtreme2004经典代码之二:TableInfo 34
mapxtreme2004经典代码之二:TableInfo s1 += "\r\n";
35
mapxtreme2004经典代码之二:TableInfo foreach(Column c in ti.Columns)
36
mapxtreme2004经典代码之二:TableInfo
mapxtreme2004经典代码之二:TableInfo
mapxtreme2004经典代码之二:TableInfo {
37
mapxtreme2004经典代码之二:TableInfo 38
mapxtreme2004经典代码之二:TableInfo s1 += "Alias="+c.Alias+"\r\n"+"DataType="+c.DataType+"\r\n"+"Width="+c.Width+"\r\n";
39
mapxtreme2004经典代码之二:TableInfo if(c.DataType == MIDbType.FeatureGeometry)
40
mapxtreme2004经典代码之二:TableInfo
mapxtreme2004经典代码之二:TableInfo
mapxtreme2004经典代码之二:TableInfo {
41
mapxtreme2004经典代码之二:TableInfo GeometryColumn gc = (GeometryColumn)c;
42
mapxtreme2004经典代码之二:TableInfo MapInfo.Geometry.CoordSys cs = gc.CoordSys;
43
mapxtreme2004经典代码之二:TableInfo s1 += "MapBasicString="+cs.MapBasicString+"\r\n";
44
mapxtreme2004经典代码之二:TableInfo MapInfo.Geometry.DRect dr = gc.Bounds;
45
mapxtreme2004经典代码之二:TableInfo s1 += "Bounds="+dr+"\r\n";
46
mapxtreme2004经典代码之二:TableInfo }
47
mapxtreme2004经典代码之二:TableInfo 48
mapxtreme2004经典代码之二:TableInfo }
49
mapxtreme2004经典代码之二:TableInfo 50
mapxtreme2004经典代码之二:TableInfo Console.WriteLine(s1);
51
mapxtreme2004经典代码之二:TableInfo 52
mapxtreme2004经典代码之二:TableInfo }