System.Windows.Browser.ManagedObject.IsScriptable C# (CSharp) Method

IsScriptable() public static method

public static IsScriptable ( Type t ) : bool
t Type
return bool
		public static bool IsScriptable (Type t)
		{
			if (t.IsDefined (typeof(ScriptableTypeAttribute), true))
				return true;

			foreach (MethodInfo mi in t.GetMethods ())
				if (mi.IsDefined (typeof(ScriptableMemberAttribute), true))
					return true;

			foreach (PropertyInfo pi in t.GetProperties ())
				if (pi.IsDefined (typeof(ScriptableMemberAttribute), true))
					return true;

			foreach (EventInfo ei in t.GetEvents ())
				if (ei.IsDefined (typeof(ScriptableMemberAttribute), true))
					return true;

			return false;
		}

Usage Example

Beispiel #1
0
        public static void RegisterScriptableObject(string scriptKey, object instance)
        {
            CheckThread();
            // no call to CheckHtmlAccess(); -- see DRT364
            CheckName(scriptKey, "scriptKey");
            if (instance == null)
            {
                throw new ArgumentNullException("instance");
            }
            Type t = instance.GetType();

            if (!t.IsPublic && !t.IsNestedPublic)
            {
                throw new InvalidOperationException("'instance' type is not public.");
            }

            if (!ManagedObject.IsScriptable(t))
            {
                throw new ArgumentException("No public [ScriptableMember] method was found.", "instance");
            }

            ScriptObject sobj = instance as ScriptObject;

            if (sobj == null)
            {
                sobj = new ManagedObject(instance);
            }

            NativeMethods.moonlight_scriptable_object_register(PluginHost.Handle, scriptKey, sobj.Handle);
        }