top-silverlight | Just another WordPress weblog

五/09

19

13.3.4 使用CreateInstance方法

 13.4 使用t调用托管代码 

  13.4.1 使用t调用托管代码简介

  在Silverlight应用程序中,我们可以使用托管代码来调用t,反过来也可以在t中调用托管代码。HtmlPage静态类为我们提供了如下两组方法。

  Registertablet:允许注册一个可以被t调用的对象,使用Unregistertablet方法取消注册。

  RegisterCreateableType:允许注册一个可以在t中创建对象实例的类型,使用UnregisterCreateableType方法取消注册。

  它们的签名如下面的代码所示:

  C#public static class HtmlPagepublic staticvoidRegistertablet(string tKey, t instance);public staticvoidUnregistertablet(string tKey);

  public static void RegisterCreateableType(string tAlias,Typetype);public static voidUnregisterCreateableType(stringtAlias);

  不管是注册对象还是注册类型,我们都要对公开给t的类型或成员添加如下特性。

  tableType:公开类型给t代码。

  tableMr:公开成员给t代码。

  下面的示例将介绍上述两种方法如何在t中调用托管代码。

No tags

No comments yet.

Leave a Reply

<<

>>

Theme Design by devolux.nh2.me