コード例 #1
0
        /**
         * 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);
            }
        }
コード例 #2
0
 public void deserializationPostHook(MetadataNS.Metadata deserializedMetadata, MetadataFieldDescriptor mfd)
 {
     currentMMstack.Pop();
 }