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

IsCreateable() public static method

public static IsCreateable ( Type type ) : bool
type Type
return bool
		public static bool IsCreateable (Type type)
		{
			if (type != null && (type == typeof (object) || typeof(Delegate).IsAssignableFrom(type)))
				return false;

			if (!type.IsVisible || type.IsAbstract ||
				type.IsInterface || type.IsPrimitive ||
				type.IsGenericTypeDefinition)
				return false;

			// we like value types and arrays and things with default constructors
			if (!type.IsValueType && !type.IsArray && type.GetConstructor (BindingFlags.Public | BindingFlags.Instance, null, Type.EmptyTypes, null) == null)
				return false;

			return true;
		}

Usage Example

Beispiel #1
0
        public static void RegisterCreateableType(string scriptAlias, Type type)
        {
#if !ANDROID_HACK
            CheckThread();
            // no call to CheckHtmlAccess(); -- see DRT365
            CheckName(scriptAlias, "scriptAlias");
            if (type == null)
            {
                throw new ArgumentNullException("type");
            }

            if (!ManagedObject.IsCreateable(type))
            {
                throw new ArgumentException(type.ToString(), "type");
            }

            if (HostServices.Current.CreateableTypes.ContainsKey(scriptAlias))
            {
                throw new ArgumentException("scriptAlias");
            }

            HostServices.Current.CreateableTypes [scriptAlias] = type;
#endif
        }