Exemplo n.º 1
0
        /**
         * This constructor should only be called from SemanticsScope's constructor!
         *
         * @param _metadataTranslationScope
         */
        public MetaMetadataRepositoryInit(SimplTypesScope metadataTranslationScope, string repoLocation, EventHandler <EventArgs> onCompleted)
        {
            //		    if (SingletonApplicationEnvironment.isInUse() && !SingletonApplicationEnvironment.runningInEclipse())
            //		    {
            //			    AssetsRoot mmAssetsRoot = new AssetsRoot(
            //					    EnvironmentGeneric.configDir().getRelative(SEMANTICS),
            //					    Files.newFile(PropertiesAndDirectories.thisApplicationDir(), SEMANTICS + "/repository")
            //					    );
            //
            //			    METAMETADATA_REPOSITORY_DIR_FILE    = Assets.getAsset(mmAssetsRoot, null, "repository", null, !USE_ASSETS_CACHE, SemanticsAssetVersions.METAMETADATA_ASSET_VERSION);
            //		    }
            //		    else

            MetametadataRepositoryDirFile = repoLocation;

            this._metadataTranslationScope = metadataTranslationScope;
            Debug.WriteLine("\t\t-- Reading meta_metadata from " + MetametadataRepositoryDirFile);

            if (onCompleted != null)
            {
                this.RepositoryLoaded += onCompleted;
            }


            _generatedDocumentTranslations = metadataTranslationScope.GetAssignableSubset(
                SemanticNames.RepositoryDocumentTranslations,
                typeof(Document));
            _generatedMediaTranslations = metadataTranslationScope.GetAssignableSubset(
                SemanticNames.RepositoryMediaTranslations,
                typeof(ClippableDocument));
            _repositoryClippingTranslations = metadataTranslationScope.GetAssignableSubset(
                SemanticNames.RepositoryClippingTranslations,
                typeof(Clipping <>));

            _noAnnotationsScope = metadataTranslationScope.GetSubtractedSubset(
                SemanticNames.RepositoryNoAnnotationsTypeScope,
                typeof(TextSelfmade));



            _generatedMediaTranslations.AddTranslation(typeof(Clipping <>));
            _generatedMediaTranslations.AddTranslation(typeof(TextSelfmade));
            _generatedMediaTranslations.AddTranslation(typeof(HtmlText));
        }
        MetadataClassDescriptor GetMetadataClassDescriptor(SimplTypesScope metadataTScope)
        {
            MetadataClassDescriptor metadataCd = this.metadataClassDescriptor;

            if (metadataCd == null)
            {
                //this.InheritMetaMetadata(null); //edit

                String metadataClassSimpleName = this.GetMetadataClassSimpleName();
                // first look up by simple name, since package names for some built-ins are wrong

                metadataCd =
                    (MetadataClassDescriptor)metadataTScope.GetClassDescriptorBySimpleName(metadataClassSimpleName);
                if (metadataCd == null)
                {
                    String metadataClassName = this.GetMetadataClassName();

                    metadataCd = (MetadataClassDescriptor)metadataTScope.GetClassDescriptorByClassName(metadataClassName);
                    if (metadataCd == null)
                    {
                        try
                        {
                            Type metadataType = Type.GetType(metadataClassName) ??
                                                Type.GetType(metadataClassName +
                                                             AsemblyQualifiedNameForGeneratedSemantics);
                            this.metadataClass = metadataType;
                            if (MetadataClass != null)
                            {
                                metadataCd = (MetadataClassDescriptor)ClassDescriptor.GetClassDescriptor(MetadataClass);
                                metadataTScope.AddTranslation(MetadataClass);
                            }
                            else
                            {
                                Debug.WriteLineIf(BigSemanticsSettings.DebugLevel > 5, "Cannot find metadata class " + metadataClassName + " for " + this);
                            }
                        }
                        catch (Exception e)
                        {
                            Debug.WriteLine("Exception: " + e.Message);
                            Debug.WriteLine("Stacktrace:\n" + e.StackTrace);
                            Debug.WriteLine("Cannot find metadata class " + metadataClassName + " for " + this);
                        }
                    }
                }
            }
            return(metadataCd);
        }
Exemplo n.º 3
0
        public new MetadataClassDescriptor BindMetadataClassDescriptor(SimplTypesScope metadataTScope)
        {
            if (metadataClassDescriptor != null)
            {
                return(metadataClassDescriptor);
            }

            // create a temporary local metadata translation scope
            SimplTypesScope localMetadataTScope = SimplTypesScope.Get("mmd_local_tscope:" + Name, metadataTScope);

            // record the initial number of classes in the local translation scope

            int initialLocalTScopeSize = localMetadataTScope.EntriesByClassName.Count;

            // do actual stuff ...
            base.BindMetadataClassDescriptor(localMetadataTScope);

            // if tag overlaps, or there are fields using classes not in metadataTScope, use localTScope
            MetadataClassDescriptor thisCd = this.MetadataClassDescriptor;

            if (thisCd != null)
            {
                MetadataClassDescriptor thatCd = (MetadataClassDescriptor)metadataTScope.GetClassDescriptorByTag(thisCd.TagName);
                if (thisCd != thatCd)
                {
                    localMetadataTScope.AddTranslation(thisCd);
                    this.localMetadataTranslationScope = localMetadataTScope;
                }
                else if (localMetadataTScope.EntriesByClassName.Count > initialLocalTScopeSize)
                {
                    this.localMetadataTranslationScope = localMetadataTScope;
                }
                else
                {
                    this.localMetadataTranslationScope = metadataTScope;
                }
            }

            // return the bound metadata class descriptor
            return(thisCd);
        }