private fsResult InternalDeserialize_2_Version(Type overrideConverterType, fsData data, Type storageType, ref object result, out List <fsObjectProcessor> processors) { 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 //私たちはマイグレーションをしなくてはなりません var deserializeResult = fsResult.Success; List <fsVersionedType> path; deserializeResult += fsVersionManager.GetVersionImportPath(version, versionedType.Value, out path); if (deserializeResult.Failed) { processors = GetProcessors(storageType); return(deserializeResult); } // deserialize as the original type //元の型として非直列化する deserializeResult += InternalDeserialize_3_Inheritance(overrideConverterType, data, path[0].ModelType, ref result, out processors); if (deserializeResult.Failed) { return(deserializeResult); } // TODO: we probably should be invoking object processors all along this pipeline //TODO:おそらくこのパイプラインに沿ってオブジェクトプロセッサを呼び出すべきです for (int i = 1; i < path.Count; ++i) { result = path[i].Migrate(result); } // Our data contained an object definition ($id) that was added to _references in step 4. // However, in case we are doing versioning, it will contain the old version. // To make sure future references to this object end up referencing the migrated version, // we must update the reference. //私たちのデータには、手順4で_referencesに追加されたオブジェクト定義($ id)が含まれていました。 //ただし、バージョン管理を行っている場合は古いバージョンが含まれます。このオブジェクトへの今後の参照が移行されたバージョンを参照するようにするには、参照を更新する必要があります。 if (IsObjectDefinition(data)) { int sourceId = int.Parse(data.AsDictionary[Key_ObjectDefinition].AsString); _references.AddReferenceWithId(sourceId, result); } processors = GetProcessors(deserializeResult.GetType()); return(deserializeResult); } } return(InternalDeserialize_3_Inheritance(overrideConverterType, data, storageType, ref result, out processors)); }
private fsResult InternalDeserialize_2_Version(Type overrideConverterType, fsData data, Type storageType, ref object result, out List <fsObjectProcessor> processors) { 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 fsResult deserializeResult = fsResult.Success; List <fsVersionedType> path; deserializeResult += fsVersionManager.GetVersionImportPath(version, versionedType.Value, out path); if (deserializeResult.Failed) { processors = GetProcessors(storageType); return(deserializeResult); } // deserialize as the original type deserializeResult += InternalDeserialize_3_Inheritance(overrideConverterType, data, path[0].ModelType, ref result, out processors); if (deserializeResult.Failed) { return(deserializeResult); } // TODO: we probably should be invoking object processors all // along this pipeline for (int i = 1; i < path.Count; ++i) { result = path[i].Migrate(result); } // Our data contained an object definition ($id) that was // added to _references in step 4. However, in case we are // doing versioning, it will contain the old version. To make // sure future references to this object end up referencing // the migrated version, we must update the reference. if (IsObjectDefinition(data)) { int sourceId = int.Parse(data.AsDictionary[Key_ObjectDefinition].AsString); _references.AddReferenceWithId(sourceId, result); } processors = GetProcessors(deserializeResult.GetType()); return(deserializeResult); } } return(InternalDeserialize_3_Inheritance(overrideConverterType, data, storageType, ref result, out processors)); }
private fsFailure InternalDeserialize_4_Cycles(fsData data, Type resultType, ref object result) { // object references are handled at stage 1 if (IsObjectDefinition(data)) { var dict = data.AsDictionary; int sourceId = int.Parse(dict[Key_ObjectDefinition].AsString); // to get the reference object, we need to deserialize it, but doing so sends a // request back to our _references group... so we just construct an instance // before deserialization so that our _references group resolves correctly. _references.AddReferenceWithId(sourceId, result); return(InternalDeserialize_4_Converter(data, resultType, ref result)); } // Nothing special, go through the standard deserialization logic. return(InternalDeserialize_4_Converter(data, resultType, ref result)); }
private fsResult InternalDeserialize_4_Cycles(fsData data, Type resultType, ref object result) { if (IsObjectDefinition(data)) { // NOTE: object references are handled at stage 1 // If this is a definition, then we have a serialization invariant that this is the // first time we have encountered the object (TODO: verify in the deserialization logic) // Since at this stage in the deserialization process we already have access to the // object instance, so we just need to sync the object id to the references database // so that when we encounter the instance we lookup this same object. We want to do // this before actually deserializing the object because when deserializing the object // there may be references to itself. int sourceId = int.Parse(data.AsDictionary[Key_ObjectDefinition].AsString); _references.AddReferenceWithId(sourceId, result); } // Nothing special, go through the standard deserialization logic. return(InternalDeserialize_5_Converter(data, resultType, ref result)); }