Skip to content

Commit

Permalink
Merge pull request #5517 from cb1kenobi/timob-16691
Browse files Browse the repository at this point in the history
[TIMOB-16691] Added error handling when trying to get or set an invalid ...
  • Loading branch information
cb1kenobi committed Mar 25, 2014
2 parents fc12317 + b151bf9 commit 6051d7c
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,11 @@ class ReflectionRequestHandler : IRequestHandler
Dictionary<string, TiResponse> value = new Dictionary<string, TiResponse>();
for (var i = 0; i < arr.Count; i++) {
string propName = arr[i].ToString();
object val = instanceType.GetProperty(propName).GetValue(instance);
var propertyInfo = instanceType.GetProperty(propName);
if (propertyInfo == null) {
throw new Exception("Reflection Handler Exception: Invalid property \"" + propName + "\"");
}
object val = propertyInfo.GetValue(instance);
value[propName] = InstanceRegistry.createReturnType(val);
}
response["value"] = value;
Expand All @@ -562,6 +566,9 @@ class ReflectionRequestHandler : IRequestHandler
JObject props = (JObject)obj;
foreach (JProperty prop in props.Properties()) {
var propertyInfo = instanceType.GetProperty(prop.Name);
if (propertyInfo == null) {
throw new Exception("Reflection Handler Exception: Invalid property \"" + prop.Name + "\"");
}
JObject value = (JObject)prop.Value;
if (value["valueHnd"] != null) {
propertyInfo.SetValue(instance, InstanceRegistry.getInstance((string)value["valueHnd"]));
Expand All @@ -582,6 +589,9 @@ class ReflectionRequestHandler : IRequestHandler
{
string name = (string)obj;
var propertyInfo = instanceType.GetProperty(name);
if (propertyInfo == null) {
throw new Exception("Reflection Handler Exception: Invalid property \"" + name + "\"");
}

// setting a single prop
if (data.ContainsKey("valueHnd") && data["valueHnd"] != null) {
Expand Down

0 comments on commit 6051d7c

Please sign in to comment.