コード例 #1
0
      /// <summary>Add uml extentions for enum and primitive types.</summary>
      private void AddToolExtensions(BplPrimitive bplPrimitive) {

         if (bplPrimitive.IsEnum) {
            AddEnumToolExtensions(bplPrimitive);
            return;
         }

         // Add the element extensions
         XElement xElementExt = new XElement("element",
             new XAttribute(xmiNs + "idref", bplPrimitive.GetID()),
             new XAttribute(xmiNs + "type", "uml:PrimitiveType"),
             new XAttribute("name", bplPrimitive.Name),
             new XAttribute("scope", "public"));

         xElementExt.Add(new XElement("properties",
            new XAttribute("documentation", bplPrimitive.CanonicName),
            new XAttribute("isSpecification", "false"),
            new XAttribute("sType", "PrimitiveType"),
            new XAttribute("scope", "public"),
            new XAttribute("stereotype", "bplPrimitive")));

         XmiElements.Add(xElementExt);
      }
コード例 #2
0
      /// <summary>Add uml extentions for enum and primitive types.</summary>
      private void AddEnumToolExtensions(BplPrimitive bplPrimitive) {

         string xmitype = (bplPrimitive.IsEnum) ? "uml:Class" : "uml:PrimitiveType";
         string stereotype = (bplPrimitive.IsEnum) ? "uml:Class" : "uml:PrimitiveType";

         // Add the element extensions
         XElement xElementExt = new XElement("element",
             new XAttribute(xmiNs + "idref", bplPrimitive.GetID()),
             new XAttribute(xmiNs + "type", "uml:Class"),
             new XAttribute("name", bplPrimitive.Name),
             new XAttribute("scope", "public"));

         xElementExt.Add(new XElement("properties",
            new XAttribute("documentation", bplPrimitive.CanonicName),
            new XAttribute("isSpecification", "false"),
            new XAttribute("sType", "Class"),
            new XAttribute("scope", "public"),
            new XAttribute("stereotype", "bplEnum")));

         // Add enum values for the the profile extension
         XElement xAttributes = new XElement("attributes");

         // For enums, add all literal values
         int cnt = 0;

         foreach (object val in Enum.GetValues(bplPrimitive.UnderlyingType)) {
            string name = Enum.GetName(bplPrimitive.UnderlyingType, val);
            string valName = Enum.Format(bplPrimitive.UnderlyingType, val, "d");

            XElement xAttribute = new XElement("attribute",
               new XAttribute(xmiNs + "idref", string.Format("{0}_{1}", bplPrimitive.GetID(), cnt)),
               new XAttribute("name", name),
               new XAttribute("value", valName),
               new XAttribute("scope", "public")
               );

            xAttribute.Add(new XElement("initial", new XAttribute("body", valName)));
            xAttribute.Add(new XElement("documentation", new XAttribute("value", name)));
            xAttribute.Add(new XElement("properties",
               new XAttribute("derived", "0"),
               new XAttribute("collection", "false"),
               new XAttribute("length", "0"),
               new XAttribute("duplicates", "0"),
               new XAttribute("changeability", "changeable")));

            xAttribute.Add(new XElement("bounds", new XAttribute("lower", "1"), new XAttribute("upper", "1")));
            xAttribute.Add(new XElement("styleex", new XAttribute("value", "IsLiteral=1;volatile=0;")));

            xAttributes.Add(xAttribute);
            cnt++;
         }
         
         
         xElementExt.Add(xAttributes);
         XmiElements.Add(xElementExt);
      }
コード例 #3
0
      /// <summary>Add uml extentions for enum and primitive types.</summary>
      private void AddUmlExtensions(BplPrimitive bplPrimitive) {

         if (bplPrimitive.IsEnum) {
            AddUmlExtentions("bplEnum", BASE_CLASS, bplPrimitive.GetID());
            XmiModel.Add(new XElement(eaNs + "enumeration", new XAttribute(BASE_CLASS, bplPrimitive.GetID())));
         } else {
            AddUmlExtentions("bplPrimitive", BASE_PRIMITIVE, bplPrimitive.GetID());
         }
      }