Export (0) Print
Expand All

ScriptObject.ConvertTo<T> Method

Silverlight

Converts the current scriptable object to a specified type.

Namespace:  System.Windows.Browser
Assembly:  System.Windows.Browser (in System.Windows.Browser.dll)

public T ConvertTo<T>()

Type Parameters

T

The type to convert the current scriptable object to.

Return Value

Type: T
An object of type T.

ExceptionCondition
ArgumentException

The conversion failed or is not supported.

This method converts the scriptable object to the type specified by T.

NoteNote:

Use this method to convert a JavaScript Date object into a managed DateTime object.

Conversion operations differ depending on the underlying type of the scriptable object:

  • If the ManagedObject property is not null, an attempt is made to cast the underlying managed object to type T. As a result, ConvertTo is an alternative to explicitly casting the ManagedObject property.

  • If the current scriptable object is an event delegate, you can call ConvertTo<EventHandler> to get a ScriptEventHandler that represents the scriptable object. For example, this is possible if the underlying scriptable object is actually a JavaScript method.

  • For all other types (except HtmlObject) an attempt is made to serialize the underlying JavaScript object to the JavaScript Object Notation (JSON), and then to deserialize the resulting JSON string to the target T type.

Silverlight

Supported in: 5, 4, 3

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Community Additions

ADD
Show:
© 2014 Microsoft