Skip to content

Commit

Permalink
Merge pull request tidev#5519 from cb1kenobi/timob-16692
Browse files Browse the repository at this point in the history
[TIMOB-16692] Fixed bug where objects in the InstanceRegistry weren't be...
  • Loading branch information
cb1kenobi committed Mar 25, 2014
2 parents 2679478 + 4f8e290 commit 471b6ec
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions mobileweb/templates/packages/wp8/{{ProjectName}}/InstanceRegistry.cs
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace TitaniumApp
{
public static class InstanceRegistry
{

namespace TitaniumApp
{
public static class InstanceRegistry
{
private static Dictionary<string, Type> cachedTypes = new Dictionary<string, Type>();
private static Dictionary<string, object> instances = new Dictionary<string, object>();
private static UInt64 instanceCount = 0;
Expand Down Expand Up @@ -111,21 +111,26 @@ public static class InstanceRegistry
public static TiResponse createReturnType(object value) {
Type type = value == null ? null : value.GetType();
TiResponse response = new TiResponse();
string handle = null;

if (value == null || type.IsPrimitive || type == typeof(string) || type == typeof(decimal)) {
response["primitiveValue"] = value;
return response;
}

if (instances.ContainsValue(value)) {
response["handle"] = instances.FirstOrDefault(x => x.Value == value).Key;
return response;
foreach (string key in instances.Keys) {
if (instances[key].Equals(value)) {
handle = key;
break;
}
}

if (handle == null) {
handle = createHandle(value);
}

string handle = createHandle(value);
response["handle"] = handle;
return response;
}

}
}
}
}

0 comments on commit 471b6ec

Please sign in to comment.