private fsFailure RunParse(out fsData data) { SkipSpace(); switch (Character()) { case 'I': // Infinity case 'N': // NaN case '.': case '+': case '-': case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': return(TryParseNumber(out data)); case '"': { string str; fsFailure fail = TryParseString(out str); if (fail.Failed) { data = null; return(fail); } data = new fsData(str); return(fsFailure.Success); } case '[': return(TryParseArray(out data)); case '{': return(TryParseObject(out data)); case 't': return(TryParseTrue(out data)); case 'f': return(TryParseFalse(out data)); case 'n': return(TryParseNull(out data)); default: data = null; return(MakeFailure("unable to parse; invalid initial token \"" + Character() + "\"")); } }
private fsFailure InternalDeserialize_2_Version(fsData data, Type storageType, ref object result) { if (IsVersioned(data)) { // data is versioned, but we might not need to do a migration string version = data.AsDictionary[Key_Version].AsString; fsOption <fsVersionedType> versionedType = fsVersionManager.GetVersionedType(storageType); if (versionedType.HasValue && versionedType.Value.VersionString != version) { // we have to do a migration List <fsVersionedType> path; fsFailure fail = fsVersionManager.GetVersionImportPath(version, versionedType.Value, out path); if (fail.Failed) { return(fail); } // deserialize as the original type fail = InternalDeserialize_3_Inheritance(data, path[0].ModelType, ref result); if (fail.Failed) { return(fail); } for (int i = 1; i < path.Count; ++i) { result = path[i].Migrate(result); } return(fsFailure.Success); } } return(InternalDeserialize_3_Inheritance(data, storageType, ref result)); }