Exemplo n.º 1
0
 private void CreateAttribute(TypeInfo ti, Classifier aCls, AttributeInfo aField, PdOOM.BasePackage aPckg)
 {
     CustomHandlerField field = new CustomHandlerField(aField, null);
     if (!field.ThroughProperty)
     {
         PdOOM.Attribute attribute = (PdOOM.Attribute)aCls.CreateObject(0x18112065, "", -1, true);
         if (aField.IsStatic)
         {
             attribute.Static = true;
         }
         try
         {
             attribute.Name = attribute.Code = aField.Name;
         }
         catch (COMException)
         {
             if (LZ.Reverse.Info._bDebug)
             {
                 LZ.Reverse.Info.Write(new string[] { "*** exception while naming the attribute \"{1}\" on the type \"{0}\"", aField.Code, aField.Name });
             }
         }
         attribute.Visibility = GetTypeVisibility(aField.Modifier);
         //attribute.Persistent = !aField.IsNotSerialized;
         field.PdObj = attribute;
         field.Convert();
         ////Type fieldType = aField.FieldType;
         ////if (fieldType.IsArray)
         ////{
         ////    attribute.Multiplicity = "*";
         ////    fieldType = fieldType.GetElementType();
         ////}
         ////if (fieldType.IsGenericType && !fieldType.IsGenericTypeDefinition)
         ////{
         ////    fieldType = fieldType.GetGenericTypeDefinition();
         ////}
         ////this.ProcessType(fieldType, false);
         ////TypeMapping mapping = TypeMapping.Retrieve(fieldType);
         ////if (mapping.HasClassifier())
         ////{
         ////    PdOOM.BaseObject obj2 = ProperRef.Link(NamespaceMapping.Retrieve(aPckg), mapping);
         ////    attribute.UseQualifiedDataType = false;
         ////    attribute.DataTypeObject = obj2;
         ////}
         ////else
         {
             attribute.DataType = ti.Code;   // mapping.Name;
         }
     }
 }
Exemplo n.º 2
0
        private void CreateAttribute(TypeInfo ti, Classifier aCls, AttributeInfo aField, PdOOM.BasePackage aPckg)
        {
            CustomHandlerField field = new CustomHandlerField(aField, null);
            if (!field.ThroughProperty)
            {
                PdOOM.Attribute attribute = (PdOOM.Attribute)aCls.CreateObject(0x18112065, "", -1, true);
                if (aField.IsStatic)
                {
                    attribute.Static = true;
                }
                try
                {
                    attribute.Name = attribute.Code = aField.Name;
                }
                catch (COMException)
                {
                    if (LZ.Reverse.Info._bDebug)
                    {
                        LZ.Reverse.Info.Write(new string[] { "*** exception while naming the attribute \"{1}\" on the type \"{0}\"", aField.Code, aField.Name });
                    }
                }
                attribute.Visibility = GetTypeVisibility(aField.Modifier);
                //attribute.Persistent = !aField.IsNotSerialized;
                attribute.Volatile = aField.IsVolatile;
                if (aField.IsPointer)
                {
                    attribute.Multiplicity = "*";
                }
                field.PdObj = attribute;
                field.Convert();

                TypeInfo tiField = new TypeInfo();
                ////System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex("[a-zA-Z_][a-zA-Z_0-9]*");
                ////System.Text.RegularExpressions.Match m = reg.Match(aField.Type.Replace("unsigned",""));
                tiField.Code = tiField.Name = aField.Type;
                tiField.IsClass = true;
                tiField.Comment = aCls.Comment;
                this.AddClassifier(tiField, false);
                bool bCreate = true;
                TypeMapping mapping = TypeMapping.Retrieve(tiField, ref bCreate);
                if (mapping.HasClassifier())
                {
                    PdOOM.NamedObject objClassB = (PdOOM.NamedObject)ProperRef.Link(NamespaceMapping.Retrieve(aPckg), mapping);
                    PdOOM.NamedObject objClassA = (PdOOM.NamedObject)attribute.Parent;
                    attribute.UseQualifiedDataType = false;
                    attribute.DataTypeObject = objClassA;

                    Association ass = (Association)aPckg.CreateObject((int)PdOOM_Classes.cls_Association, "", -1, true);
                    ass.ClassA = objClassA;
                    ass.ClassB = objClassB;
                    try
                    {
                        ass.Name = ass.Code = string.Format("ass_{0}_2_{1}_{2}", objClassA.Code, objClassB.Code, attribute.Code);
                        if (tiField.Code == aField.FullType)
                        {
                            ass.RoleBMultiplicity = "1..1";
                            ass.RoleAIndicator = aField.IsPointer ? "A" : "C";
                        }
                        ass.RoleAMultiplicity = "";
                        ass.RoleBName = aField.Name;
                        ass.RoleANavigability = false;
                        ass.RoleBNavigability = false;
                    }
                    catch (COMException)
                    {
                        if (LZ.Reverse.Info._bDebug)
                        {
                            LZ.Reverse.Info.Write(new string[] { "*** exception while naming the attribute \"{1}\" on the type \"{0}\"", aField.Code, aField.Name });
                        }
                    }

                }
                ////else
                {
                    attribute.DataType = aField.FullType;   // mapping.Name;
                }
            }
        }