public void DeserializationPreHook(Object e, FieldDescriptor fd) { var deserializedMetadata = e as Metadata; if (deserializedMetadata == null) { return; } if (_currentMMStack.Count == 0) { MetaMetadataCompositeField deserializationMM = deserializedMetadata.MetaMetadata; // MetaMetadataCompositeField metaMetadata = semanticsSessionScope.getMetaMetadataRepository().getByClass(InformationComposition.class); // if (metaMetadata != null && metaMetadata.bindMetaMetadataToMetadata(deserializationMM)) // { // metaMetadata = (MetaMetadata) deserializationMM; // } // else // { // deserializedMetadata.setMetaMetadata(metaMetadata); // } _currentMMStack.Push(deserializationMM); } else if (fd is MetadataFieldDescriptor) { MetadataFieldDescriptor mfd = (MetadataFieldDescriptor)fd; String mmName = mfd.MmName; MetaMetadataNestedField currentMM = _currentMMStack.Peek(); MetaMetadataNestedField childMMNested = (MetaMetadataNestedField)currentMM.LookupChild(mmName); MetaMetadataCompositeField childMMComposite = null; if (childMMNested.IsPolymorphicInherently) { String tagName = deserializedMetadata.MetadataClassDescriptor.TagName; childMMComposite = _semanticsSessionScope.MetaMetadataRepository.GetMMByName(tagName); } else { childMMComposite = childMMNested.GetMetaMetadataCompositeField(); } deserializedMetadata.MetaMetadata = childMMComposite; _currentMMStack.Push(childMMComposite); } if (e is Document) { ((Document)e).SemanticsSessionScope = _semanticsSessionScope; } }
/** * For the root, compare the meta-metadata from the binding with the one we started with. Down the * hierarchy, try to perform similar bindings. */ public void DeserializationPreHook(MetadataNS.Metadata deserializedMetadata, MetadataFieldDescriptor mfd) { if (deserializingRoot) { deserializingRoot = false; Document document = GetDocument(); MetaMetadataCompositeField preMM = document.MetaMetadata; MetadataClassDescriptor mcd = (MetadataClassDescriptor)ClassDescriptor.GetClassDescriptor(deserializedMetadata);; MetaMetadataCompositeField metaMetadata; String tagName = mcd.TagName; if (preMM.GetTagForTranslationScope().Equals(tagName)) { metaMetadata = preMM; } else { // just match in translation scope //TODO use local TranslationScope if there is one metaMetadata = SemanticsSessionScope.MetaMetadataRepository.GetMMByName(tagName); } deserializedMetadata.MetaMetadata = metaMetadata; currentMMstack.Push(metaMetadata); } else { String mmName = mfd.MmName; MetaMetadataNestedField currentMM = currentMMstack.Peek(); MetaMetadataNestedField childMMNested = (MetaMetadataNestedField)currentMM.LookupChild(mmName); // this fails for collections :-( if (childMMNested == null) { throw new Exception("Can't find composite child meta-metadata for " + mmName + " amidst " + mfd + "\n\tThis probably means there is a conflict between the meta-metadata repository and the runtime." + "\n\tProgrammer: Have you Changed the fields in built-in Metadata subclasses without updating primitives.xml???!"); } MetaMetadataCompositeField childMMComposite = null; if (childMMNested.IsPolymorphicInherently) { String tagName = ClassDescriptor.GetClassDescriptor(deserializedMetadata).TagName; childMMComposite = SemanticsSessionScope.MetaMetadataRepository.GetMMByName(tagName); } else { childMMComposite = childMMNested.GetMetaMetadataCompositeField(); } deserializedMetadata.MetaMetadata = childMMComposite; currentMMstack.Push(childMMComposite); } }