i´m Matias and im new at the forum, right now i´m working on a unity app that uses smartfox as it´s main server service (it uses rest for other stuff).
The thing is that i'm working on a test platform that can test different situations or features without the need of the server. For that purpose i have some .json files that have mocked data, so we can create the sfsobject from them and then pass them to the correct actor that works with that response. The problem is that for some reason everything works perfectly when the object comes from the server, but when it is created with SFSObject.NewFromJsonData(json) method and when i try to retrieve the parameters from that sfsobject i get this error "NotSupportedException: SFSObjectLite doesn't support class serialization".
I have a generic method that gets parameters from sfsobject in a safe way, but i use GetClass method in it to keep it generic, and somehow if i use the type based getters from sfsobject there is no problem with it.
So my question is, is there a way i can use GetClass method to get different types from a SFSObject created with SFSObject.NewFromJsonData(json) method?
Just in case here is my generic parametter getter:
Code: Select all
public static bool TrySafeGetParameter<T>(this SFSObject @params, string paramName, out T obj)
{
if (@params.ContainsKey(paramName))
{
if (@params.IsNull(paramName))
{
obj = default(T);
return false;
}
else
{ }
object tempObj = @params.GetClass(paramName);
if (tempObj is T)
{
obj = (T)tempObj;
return true;
}
else
{
obj = default(T);
return false;
}
}
}
else
{
obj = default(T);
return false;
}
}