示例#1
0
        internal int GetID(NSObject obj)
        {
            if (obj is UID)
            {
                var uid   = obj as UID;
                var first = idMap.OfType <UID>().First(v => NSObject.ArrayEquals(v.Bytes, uid.Bytes));
                return(idMap.IndexOf(first));
            }
            else if (obj is NSArray)
            {
                int index = 0;

                for (int i = 0; i < idMap.Count; i++)
                {
                    if (idMap[i] == obj)
                    {
                        index = i;
                        break;
                    }
                }

                return(index);
            }
            else
            {
                return(idMap.IndexOf(obj));
            }
        }
示例#2
0
        internal int GetID(NSObject obj)
        {
            if (!this.ReuseObjectIds && obj is UID)
            {
                var uid = obj as UID;
                var first = idMap.OfType<UID>().First(v => NSObject.ArrayEquals(v.Bytes, uid.Bytes));
                return idMap.IndexOf(first);
            }
            else if (!this.ReuseObjectIds && (obj is NSArray || (obj is NSString && !IsSerializationPrimitive((NSString)obj))))
            {
                int index = -1;

                for (int i = 0; i < idMap.Count; i++)
                {
                    if (idMap[i] == obj)
                    {
                        index = i;
                        break;
                    }
                }

                if (index == -1)
                {
                    throw new InvalidOperationException();
                }

                return index;
            }
            else
            {
                return idMap.IndexOf(obj);
            }
        }