ScriptableTypeAttribute Class


Indicates that all public properties, methods, and events on a managed type are available to JavaScript code when they are registered by using the RegisterCreateableType method.


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

<AttributeUsageAttribute(AttributeTargets.Class Or AttributeTargets.Struct, AllowMultiple := False,  _
	Inherited := False)> _
Public NotInheritable Class ScriptableTypeAttribute _
	Inherits Attribute

The ScriptableTypeAttribute type exposes the following members.

Public methodScriptableTypeAttributeInitializes a new instance of the ScriptableTypeAttribute class.

Public methodEqualsInfrastructure. Returns a value that indicates whether this instance is equal to a specified object. (Inherited from Attribute.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetHashCodeReturns the hash code for this instance. (Inherited from Attribute.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodMatchWhen overridden in a derived class, returns a value that indicates whether this instance equals a specified object. (Inherited from Attribute.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)

The ScriptableTypeAttribute method exposes all properties, methods, and events as scriptable endpoints.

If you want to expose only a subset of properties, methods, and events as scriptable endpoints, do not use a ScriptableTypeAttribute object. Instead, attribute the subset of properties, methods, and events with a ScriptableMemberAttribute object.

The ScriptableMemberAttribute setting overrides the default behavior inherited from ScriptableTypeAttribute.

If a type is attributed with ScriptableTypeAttribute, by default, all members that are used as input parameters or return values can be created by using the createManagedType and createManagedArray helpers.

You can turn off support for obtaining script wrappers for input parameters and return values that are exposed on a scriptable property, method, or event by explicitly attributing individual members with the code ScriptableMember(EnableCreateableTypes := false). The following example shows how to disable a single method and let all other methods remain scriptable.

public class SMT_ScriptableManagedType
    [ScriptableMember(EnableCreateableTypes = false)] // No access
     public string GetString1()
        { return "abcdefg"; }

     public string GetString2()            // Can be accessed.
        { return "123456"; }


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.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.