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)); } }
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); } }