Exemplo n.º 1
0
bool EPParameter::IsValueValid(const Any& value) const {
	Any::Type vt = GetValueType();
	Any forced = value.Force(vt);
	if(vt==Any::TypeInteger || vt==Any::TypeDouble) {
		if(GetMaximumValue()>GetMinimumValue()) {
			if(forced > GetMaximumValue()) {
				return false;
			}
			
			if(forced < GetMinimumValue()) {
				return false;
			}
		}
	}
	
	return true;
}
Exemplo n.º 2
0
bool FabricState::Set(Field field, ref<Scriptable> value) {
	ref<FabricEngine> fe = _fe;
	if(fe) {
		ThreadLock lock(&_lock);
		if(value.IsCastableTo<ScriptAny>()) {
			Any previousValue = fe->_state->GetValue(field);
			Any val = ref<ScriptAny>(value)->Unbox();
			
			// Retain value type if previous type was not null
			if(previousValue.GetType()!=Any::TypeNull) {
				val = val.Force(previousValue.GetType());
			}
			fe->_state->SetValue(field, val);
			_shouldCommit = true;
			return true;
		}
	}
	return false;
}