Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>After another look at the linked article, I believe the quoted text refers to marshalling operations on a managed object that take place after it has been created by <code>createObject</code> or <code>createManagedObject</code>. </p> <p>So a class like this:</p> <pre><code>[ScriptableType] public class TestClass { public object arrayObj; public object dicObj; public TestClass sibling; public TestClass(){} public void testMethod(TestClass testClassObj) { //Assuming argument came from Javascript //&amp; arrayObj and dicObj were assigned an //Array and dictionary-obj respectively testClassObj.arrayObj; //Formal type: Object. Actual type: object[] testClassObj.dicObj; //Formal type: Object. Actual type: // Dictionary&lt;string, object&gt; } } </code></pre> <p>Utilized by the Silverlight application like this:</p> <pre><code>private void Application_Startup(object sender, StartupEventArgs e) { this.RootVisual = new MainPage(); HtmlPage.RegisterCreatableType("TestClass", typeof(TestClass)); HtmlPage.RegisterScriptableObject("scripTestClassObj", new TestClass()); } </code></pre> <p>Can be used like this on the client-side:</p> <pre><code>var testClassObj = silverlight_domElement.content .services.CreateObject("TestClass"); testClassObj.arrayObj = [1,2,3]; testClassObj.dicObj = {key: 1}; silverlight_domElement.content.scripTestClassObj.testMethod(testClassObj); //"sibling"'s arrayObj and dicObj types will have actual types //of object[] and Dictionary&lt;string, object&gt; respectively silverlight_domElement.content.scripTestClassObj.sibling = testClassObj; </code></pre> <p>In other words, it has no bearing on the functionality in discussion.</p> <p>In the context of my question, it means that passing non-primitive Javascript values to managed code requires adherence to one of the following guidelines:</p> <ol> <li>The type of the target property or method parameter must be <code>ScriptObject</code> (or <code>Object</code>, since that is the class it derives from).</li> <li>The type of the target property or method parameter must either be explicitly or implicitly registered with HtmlPage.RegisterCreatableType, and the value passed must be the object resulting from a <code>createObject</code> or <code>createManagedObject</code> call with the registered alias (<code>createObject</code>) or type (<code>createManagedObject</code>).</li> </ol> <p>Please feel free to correct me if any of the statements I've made are incorrect.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload