Пример #1
0
        private EnAr.Element ConstructPrimitiveType(Ecore.IEDataType eDataType)
        {
            if (!eclassifier2Class.ContainsKey(eDataType))
            {
                EnAr.Package parentPackage = ConstructMetamodelPackage(eDataType.EPackage);
                EnAr.Element primitiveType = (EnAr.Element)parentPackage.Elements.AddNew(eDataType.Name, "Class");
                eclassifier2Class[eDataType] = primitiveType;
                primitiveType.Stereotype     = "primitive";

                if (ecorePrimitiveToEnAr.ContainsKey(eDataType.Name))
                {
                    EnAr.TaggedValue tag =
                        (EnAr.TaggedValue)primitiveType.TaggedValues.AddNew("MOFPrimitiveType", "Tag");
                    tag.Value = ecorePrimitiveToEnAr[eDataType.Name];
                    tag.Update();
                    primitiveType.TaggedValues.Refresh();
                }

                parentPackage.Elements.Refresh();
                parentPackage.Update();
                parentPackage.Element.Update();
                primitiveType.Update();
                return(primitiveType);
            }
            return(eclassifier2Class[eDataType]);
        }
Пример #2
0
        private EnAr.Package ConstructMetamodelPackage(Ecore.IEPackage ePackage, bool constructContent = false)
        {
            if (!ePackage2Package.ContainsKey(ePackage))
            {
                EnAr.Package parentPackage = ePackage.ESuperPackage != null
                    ? ConstructMetamodelPackage(ePackage.ESuperPackage)
                    : rootContainerPackage;

                EnAr.Package package = (EnAr.Package)parentPackage.Packages.AddNew(ePackage.Name, "Package");
                ePackage2Package[ePackage] = package;
                package.Element.Stereotype = "metamodel";
                parentPackage.Packages.Refresh();
                parentPackage.Update();
                package.Update();
                package.Element.Update();
            }
            if (constructContent)
            {
                foreach (Ecore.IEClassifier eClassifier in ePackage.EClassifiers)
                {
                    ConstructClassifier(eClassifier);
                }

                foreach (Ecore.IEPackage eSubpackage in ePackage.ESubpackages)
                {
                    ConstructMetamodelPackage(eSubpackage, true);
                }
            }

            return(ePackage2Package[ePackage]);
        }
Пример #3
0
 public void ConstructMetamodel(ISet <Ecore.IEPackage> ePackages)
 {
     foreach (Ecore.IEPackage ePackage in ePackages)
     {
         ConstructMetamodelPackage(ePackage, true);
     }
     rootContainerPackage.Elements.Refresh();
     rootContainerPackage.Packages.Refresh();
     rootContainerPackage.Element.Update();
     rootContainerPackage.Update();
 }