저는 Vala를 처음 사용하고 조금 놀았습니다. 현재 런타임에 일반 목록의 형식 매개 변수를 결정하는 방법을 찾고 있습니다.Vala : 런타임에 List 내에서 제네릭 형식을 결정하십시오.
아래 코드는 'reflection'을 사용하여 Locations 클래스의 속성을 인쇄합니다. 그러나 런타임에이 목록에 문자열 인스턴스가 포함되어 있는지 확인할 수 없습니다.
이 방법이 있습니까? 또는 Vala에서 지원되지 않습니까?
using Gee;
class Locations : Object {
public string numFound { get; set; }
public ArrayList<string> docs { get; set; }
}
void main() {
ObjectClass ocl = (ObjectClass) typeof (Locations).class_ref();
ParamSpec[] properties = ocl.list_properties();
foreach (ParamSpec spec in properties) {
string fieldName = spec.get_nick();
stdout.printf (" fieldName: %s\n", fieldName);
Type fieldType = spec.value_type;
stdout.printf (" Type : %s\n", fieldType.name());
}
}
출력 : G 객체/GType 때문에이 작업을 수행하는 일반적인 방법이 없습니다
fieldName: numFound
Type : gchararray
fieldName: docs
Type : GeeArrayList
좋아! 당신의 대답은 제게 많은 도움이되었습니다. 오늘 밤 나는 기능적인 예를 올릴 것이다. – scuro