Inheritance: INativeObject
コード例 #1
0
        public static void GlobalSetClass(Class kls, string codedName)
        {
            if (codedName == null)
                throw new ArgumentNullException ("codedName");
            if (kls == null)
                throw new ArgumentNullException ("kls");

            using (var nsname = new NSString (codedName))
                MonoMac.ObjCRuntime.Messaging.void_objc_msgSend_IntPtr_IntPtr (class_ptr, selSetClassForClassName_, kls.Handle, nsname.Handle);
        }
コード例 #2
0
		public static void GlobalSetClassName (string name, Class kls)
		{
			if (name == null)
				throw new ArgumentNullException ("name");
			if (kls == null)
				throw new ArgumentNullException ("kls");

			var nsname = new NSString (name);
			MonoMac.ObjCRuntime.Messaging.void_objc_msgSend_IntPtr_IntPtr (class_ptr, Selector.GetHandle (selSetClassNameForClass_), nsname.Handle, kls.Handle);
			nsname.Dispose ();
		}
コード例 #3
0
ファイル: Runtime.cs プロジェクト: jonlipsky/monomac
		public static void ConnectMethod (MethodInfo method, Selector selector) {
			if (method == null)
				throw new ArgumentNullException ("method");
			if (selector == null)
				throw new ArgumentNullException ("selector");
			var type = method.DeclaringType;

			if (!Class.IsCustomType (type))
				throw new ArgumentException ("Cannot late bind methods on core types");

			var ea = new ExportAttribute (selector.Name);
			var klass = new Class (type);

			Class.RegisterMethod (method, ea, type, klass.Handle);
		}
コード例 #4
0
        public void GeneralCase()
        {
            Errors = 0;
            foreach (Type t in Assembly.GetTypes ()) {
                if (!NSObjectType.IsAssignableFrom (t))
                    continue;

                if (Skip (t))
                    continue;

                foreach (var intf in t.GetInterfaces ()) {
                    if (SkipDueToAttribute (intf))
                        continue;

                    string protocolName = intf.Name.Substring (1);
                    switch (protocolName) {
                    case "NSCoding":
                    case "NSSecureCoding":
                    case "NSCopying":
                    case "NSMutableCopying":
                        // we have special test cases for them
                        continue;
                    default:
            #if !XAMCORE_2_0
                        // in Classic our internal delegates _inherits_ the type with the [Protocol] attribute
                        // in Unified our internal delegates _implements_ the interface that has the [Protocol] attribute
                        var pt = Type.GetType (intf.Namespace + "." + protocolName + ", " + intf.Assembly.FullName);
                        if (SkipDueToAttribute (pt))
                            continue;
            #endif
                        if (Skip (t, protocolName))
                            continue;
                        break;
                    }

                    var a = intf.GetCustomAttribute<ProtocolAttribute> (true);
                    if (a == null || a.IsInformal)
                        continue;

                    IntPtr protocol = Runtime.GetProtocol (protocolName);
                    if (protocol == IntPtr.Zero)
                        continue; // not a protocol

                    if (LogProgress)
                        Console.WriteLine ("{0} conforms to {1}", t.FullName, protocolName);

                    var klass = new Class (t);
                    if (klass.Handle == IntPtr.Zero) {
                        AddErrorLine ("Could not load {0}", t.FullName);
                    } else if (t.IsPublic && !ConformTo (klass.Handle, protocol)) {
                        // note: some internal types, e.g. like UIAppearance subclasses, return false (and there's not much value in changing this)
                        ReportError ("Type {0} (native: {1}) does not conform {2}", t.FullName, klass.Name, protocolName);
                    }
                }
            }
            AssertIfErrors ("{0} types do not really conform to the protocol interfaces", Errors);
        }
コード例 #5
0
        bool SupportsSecureCoding(Type type)
        {
            Class cls = new Class (type);
            if (!bool_objc_msgSend_IntPtr (cls.Handle, Selector.GetHandle ("respondsToSelector:"), Selector.GetHandle ("supportsSecureCoding")))
                return false;

            return NSSecureCoding.SupportsSecureCoding (type);
        }
コード例 #6
0
		public static string GlobalGetClassName (Class kls)
		{
			if (kls == null)
				throw new ArgumentNullException ("kls");
			return NSString.FromHandle (MonoMac.ObjCRuntime.Messaging.IntPtr_objc_msgSend_IntPtr (class_ptr, Selector.GetHandle (selClassNameForClass_), kls.Handle));
		}