To understand the classes and interfaces in AO, read the code: /*
* Created by sharpdevelop.
* User: noo
* Date: 2009-8-19
* Time: 10: 01
*
* The relationships between classes and interfaces in AO. One Class inherits from multiple interfaces, and mapclass inherits from iactiveview and IMAP.
*/
Using system;
Interface iactiveview // The current view Interface
{
Void refresh (); // refresh Method
Bool showscrollbars // whether to display the scale attribute, which can be read and written
{
Get;
Set;
}
}
Interface IMAP // map interface
{
Void addlayer (); // Add Layer Method
Int layercount // number of layers attribute, read-only
{
Get;
}
}
Class mapclass: iactiveview, IMAP // The map class inherits from the above two interfaces. Actually, there are more than these two interfaces, such as igraphicscontainer.
{
Void iactiveview. Refresh () // describes the principle. The following methods or attributes are not the actual implementation results of methods or attributes in AO.
{
Console. writeline ("refresh the current view. ");
}
Private bool isshow;
Bool iactiveview. showscrollbars
{
Get {return isshow ;}
Set {isshow = value ;}
}
Void IMAP. addlayer ()
{
Console. writeline ("add layer. ");
}
Private int COUNT = 5;
Int IMAP. layercount
{
Get {return count ;}
}
}
Class Test
{
Static void main () // entry function
{
Console. writeline ("\ n operations and settings on the current view. \ N ");
Iactiveview pactiveview = new mapclass ();
Pactiveview. Refresh ();
Pactiveview. showscrollbars = true;
If (pactiveview. showscrollbars)
{
Console. writeline ("Explicit scale. ");
}
Else
{
Console. writeline ("no explicit scale. ");
}
Console. writeline ("\ n operations and settings on the map. \ N ");
IMAP pmap = new mapclass ();
Pmap. addlayer ();
Console. writeline ("the current map has {0} layers", pmap. layercount );
// When a class inherits from multiple interfaces, the interface is used to classify methods or attributes in the class. The iactiveview and IMAP interfaces above implement different functions.
// Of Course, if one of the APIs in the same class (iactiveview) (such as IMAP) wants to implement the methods or attributes in the other interface (iactiveview), you can apply the interface query (QI) for more information about the technology, see my other blog post "C #. net describes the interface query (QI) technology in arcobjctes ".
}
}