简体   繁体   English

扩展密封图钉类以包含更多字段

[英]Extending the sealed Pushpin class to include more fields

I am developing a windows store app that allows a User to place points on a map and load them from a server. 我正在开发Windows商店应用程序,该应用程序允许用户在地图上放置点并从服务器加载它们。 I have this working fine but I need to include more properties than the standard Pushpin class allows (rating / description / user). 我的工作正常,但是我需要包含比标准Pushpin类允许的更多属性(评分/说明/用户)。

Because Pushpin is sealed, I cannot add these fields and use my own object in place of Pushpin. 由于图钉是密封的,因此我无法添加这些字段并使用自己的对象代替图钉。 I tried over the past couple of hours to compose my own PointOfInterest class with a Pushpin object inside it however, this approach fails in a number of areas (When I place a point on a map, I want to retrieve more details than just name / tag and have no way of getting a reference back to the original object.) 在过去的几个小时中,我尝试使用一个图钉对象在自己的PointOfInterest类中进行组合,但是这种方法在很多区域都失败了(当我在地图上放置一个点时,我想获取的详细信息不仅仅是名称/标签,并且无法获取对原始对象的引用。)

If anybody has an idea of where to go from here I would like to hear from you ! 如果有人知道从这里出发的去向,我希望收到您的来信!

If you need access to the private members of a sealed class then you are out of luck. 如果您需要访问密封班的私人成员,那么您很不幸。

Best you can do is proxy (which you already seem to be doing by including it as a member). 最好能做的就是代理(您似乎已经通过将其作为成员来完成此工作)。 Also called faking it :) 也称为伪造它:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM