C #. Net describes the relationship between interfaces and classes in ArcObjects

Source: Internet
Author: User
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 ".
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.