[Vala] Problem with programmatic generic object instantiation
- From: Andy Lees <andrewl oz gmail com>
- To: Vala List <vala-list gnome org>
- Subject: [Vala] Problem with programmatic generic object instantiation
- Date: Tue, 16 Feb 2016 22:14:35 +1100
Hi,
I have a generic array implementation like so:
public class GArrSerializable<T> : Serializable, Object {
public T[] data;
public int length;
public GArrSerializable(int size = 0) {
data = new T[size];
}
public Type type () { return typeof (T); }
...etc
and a derived type:
public class IntArr : GArrSerializable<int> {
public IntArr(int size = 0) {
base (size);
}
}
If I create an instance of the type, then instance.type () returns 24 as
expected.
If I create an instance like so:
var ia = Object new (type) as IntArr;
var t = ia.type ();
Then t is 4 rather than 24. As it is in the instance when it tries to
deserialize.
Can you tell me why this is so, and how I can programmatically create
objects derived from a parameterised type?
Thanks
Andrew Lees
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]