public NotificationChain basicSetElement(UnresolvedItem newobj, NotificationChain msgs) { var oldobj = _element; _element = newobj; if (eNotificationRequired()) { var notification = new ENotificationImpl(this, NotificationImpl.SET, Java_PackageImpl.UNRESOLVEDITEMACCESS_ELEMENT, oldobj, newobj); if (msgs == null) { msgs = notification; } else { msgs.add(notification); } } return(msgs); }
/// <summary> /// Reads a list of IBinarySerializable objects or various other types. /// </summary> public static List <T> ReadObjectList <T>(this BinaryReader r, uint count) where T : new() { var list = new List <T>((int)count); if (count == 0) { return(list); } if (typeof(IBinarySerializable).IsAssignableFrom(typeof(T))) // trucklib objects { ReadList(r => { var obj = new T() as IBinarySerializable; obj.Deserialize(r); return((T)obj); }); } else if (typeof(IComparable).IsAssignableFrom(typeof(T))) // int, float etc. { ReadList(r => { var val = r.Read <T>(); return((T)Convert.ChangeType(val, typeof(T))); }); } else if (typeof(T) == typeof(Vector2)) { ReadList(r => { var vector = r.ReadVector2(); return((T)Convert.ChangeType(vector, typeof(T))); }); } else if (typeof(T) == typeof(Vector3)) { ReadList(r => { var vector = r.ReadVector3(); return((T)Convert.ChangeType(vector, typeof(T))); }); } else if (typeof(T) == typeof(UnresolvedItem)) { ReadList(r => { var item = new UnresolvedItem(r.ReadUInt64()); return((T)Convert.ChangeType(item, typeof(T))); }); } else { throw new NotImplementedException($"Don't know what to do with {typeof(T).Name}"); } return(list); void ReadList(Func <BinaryReader, T> readOneItem) { for (int i = 0; i < count; i++) { list.Add(readOneItem.Invoke(r)); } } }