实现同一接口的两个不同的类对象,例如:
class A:interface C{}
class B:interface C{}
那么
A a;
B b;
a = b;
能不能成立呢?那自然不能成立。
虽然它们实现了同一接口,但是它们内部实现的方法并不同。(通过强制类型转换呢?)
但是,
通过接口
C c = new A()
c = new B()
可以实现通过同一个接口调用不同类的同一名称的方法。
对于第二个问题,
有两个接口
Interface A;
Interface B;
class C:A,B{}
通过接口A定义一个C类对象
A a = new C();
然后将该对象赋值给接口B的对象b。
这是可以的。
因为,
C类对象,实现了接口B。自然可以赋值给b。
B b = a。
这是成立的。
总之通过接口,调用通过接口实现的对象的实例化方法,是可行的。
面向接口编程的好处:https://ask.csdn.net/questions/342289
面向接口编程和COM组件和面向对象和面向切片编程和容器技术等等编程思想的区别和联系
例子:IMapServer3和IMap
为什么IMapServer3可以和IMap进行强制类型转换,它们有共同的接口吗?
MapServer类和Map类呢?
MapServer is a coarse-grained ArcObject. This object allows users to display and query ArcGIS map documents in internet development environments. In a server environment, MapServer objects can be accessed via SOAP/XML over an HTTP connection (Internet) or via COM in a Server Object Extension (SOE). In SOE, you can use IRESTRequestHandler to process REST/JSON request. The MapServer coclass contains several interfaces like IMapServer, IMapServerDataAccess with functions for displaying and querying a map service.
In addition to MapServer, a number of MapServer objects are defined to represent input and output parameters for methods on MapServer interfaces. For example, the IMapServer method ExportMapImage requires two inputs: a description of the map to be exported and a description of the output parameters. These inputs are captured in the MapDescription and ImageDescription objects.
Though the methods and properties available through MapServer and its associated objects offer important mapping functionality, they cannot possibly encapsulate all that ArcObjects offers. In some cases you may want to use other, finer-grained, ArcObjects in conjunction with MapServer. Starting at 10.1, you can only do this in an SOE using the IMapServerDataAccess interface which will give you access to the datasource (IFeatureClass or ITable ) of a layer or stand-alone table.
Please note that accessing fine-grained ArcObjects through IMapServerObjects interface has been deprecated at 10.1. Typically you would want to use IMapServerObjects interface to make changes to map, such as modifying a layer's renderer or adding a new layer. Starting at 10.1, you do not need to access fine-grained ArcObjects since these capabilities are available via the coarse-grained MapServer's API. If the mapservice you are accessing is enabled with dynamicLayers (SupportsDynamicLayers), you can use IDynamicLayerDescription to change renderer or to set datasource for a new layer.
It is important to know that all changes made to the MapServer object are temporary. A temporary change would include changes to the MapDescription or LayerDescription using IMapDescription, ILayerDescription or IDynamicLayerDescription. For example, you might change the geographic extent of a map (MapArea), change the visibility (Visible) or renderer (DrawingDescription) of a layer or even add a new layer on-the-fly. These changes are temporary and valid for the duration of the call (stateless). Once the call has ended the MapServer object returns to it's default state and does not remember the changes made by the previouscall.
You may find GenerateDataClassesfunction to get unique values from fields or generate classes from a field and optionally ask for renderer that can be used with ExportMapImage.
Only certain symbols are supported when working with the MapServer WSDL. These include ISimpleMarkerSymbol, ICharacterMarker, IPictureMarker, ISimpleLineSymbol, ISimpleFillSymbol and IPictureFill.
A MapServer service can have an associated tiled map cache. ArcGIS map services can use a tile cache to significantly improve performance while delivering maps. A map service that fulfills requests with pre-created tiles from a cache instead of dynamically rendering part of the map is called a cached map service. The map cache is a repository that contains image tiles for map extents at specific scale levels.
Service publishers create the cache for a map service using geoprocessing tools in ArcCatalog or via scripting. Applications that work with a cached map service can directly access tiles from the tile cache. Such applications include ArcGIS for Desktop, the ArcGIS for Server Web ADF applications. While other applications that are based on ArcGIS for Server JavaScript, Silverlight or Flex API access tiles using the tile handler.
For optimal performance, use caches. Applications built with caches do not use the parent map service, but instead pull the images directly from the cached virtual directory or by using a tile handler web service running on the server. Use ICacheDescription to get information on the cached service.
Working with MapServer with a cached map service can be different than working with a map service without a cache. Though you will be able to query against a cached map service just as you would a non-cached map service, you will see differences when working with cached map service's MapDescription and the LayerDescription of any map layer belonging to a cache.
If the map service is a cached map service then custom graphics, the rendering of selected features etc. cannot be applied to the MapDescription. In addition, any changes made to the LayerDescription of any of the map layers, such as applying a definition expression, applying a selection buffer, toggling the visibility of labels or changing the visibility of the layer itself are ignored. You will need to use ITileCacheInfo to change the spatial reference or call ExportMapImage function with different spatial reference set to IMapDescription. In the latter case you will get one single image projected to the requested spatial reference instead of multiple tiles.
IMapServer3和IMapServerObjects的关系是?
它们两个可以指向同一个类,也就是说它们同时被MapServer类实现了。
所以IMapServer3内装的是地图操作方法,IMapServerObject内装的是地图的内容。
所以,IMap和IMapServer3的关系如下:
注:IMapServerObject->IMapServerObjects3
所以,如果把IMapServer3引用的MapServer类对象赋值给IMap接口而非Map类对象,需要进行转换吗?(这就是强制类型转换吗)
最好的办法,把MapServer类对象->IMapServerObject类对象,然后再从IMapServerObject对象中获取到Map成员。。
SOE-动态分段:
https://wenku.baidu.com/view/54c66d8ecd22bcd126fff705cc17552707225e7f.html
PageLayout为NULL:https://www.cnblogs.com/jay-xu33/archive/2010/12/29/1920684.html