Value FieldInfoImpl::GetValue(const Value& thisObject) { if(thisObject.IsNull()) { throw ArgumentNullException(L"thisObject", this); } else { auto td = thisObject.GetTypeDescriptor(); auto valueType = td->GetValueSerializer() ? Value::Text : Value::RawPtr; if(!thisObject.CanConvertTo(ownerTypeDescriptor, valueType)) { throw ArgumentTypeMismtatchException(L"thisObject", ownerTypeDescriptor, valueType, thisObject); } } return GetValueInternal(thisObject); }
void FieldInfoImpl::SetValue(Value& thisObject, const Value& newValue) { if(thisObject.IsNull()) { throw ArgumentNullException(L"thisObject", this); } else { auto td = thisObject.GetTypeDescriptor(); auto valueType = td->GetValueSerializer() ? Value::Text : Value::RawPtr; if(!thisObject.CanConvertTo(ownerTypeDescriptor, valueType)) { throw ArgumentTypeMismtatchException(L"thisObject", ownerTypeDescriptor, valueType, thisObject); } } if(!newValue.CanConvertTo(returnInfo.Obj())) { throw ArgumentTypeMismtatchException(L"newValue", returnInfo.Obj(), newValue); } SetValueInternal(thisObject, newValue); }
static void IO(Reader& reader, Value& value) { WString id, text; reader << id << text; if (id == L"") { value = Value(); } else { auto type = GetTypeDescriptor(id); if (type == GetTypeDescriptor<ITypeDescriptor>()) { type = GetTypeDescriptor(text); CHECK_ERROR(type, L"Failed to load type."); value = Value::From(type); } else { type->GetValueSerializer()->Parse(text, value); } } }