Esempio n. 1
0
        private bool UpdateMembers(UmlType cl, Type tpcl)
        {
            classes[tpcl] = cl;
            name_to_class[tpcl.FullName] = cl;

            if (cl is UmlClass)
            {
                // nested
                UmlClass ucl = (UmlClass)cl;
                foreach (Type t in tpcl.GetNestedTypes())
                {
                    if (ucl.Types == null)
                    {
                        ucl.Types = new ArrayList();
                    }
                    UmlType found = UpdateTypeInArray(ucl.Types, t, t.Name);
                    if (!UpdateMembers(found, t))
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
Esempio n. 2
0
        private UmlType UpdateTypeInArray(ArrayList Types, Type t, string typename)
        {
            // resolve kind
            UmlKind kind = UmlKind.Class;

            if (t.IsInterface)
            {
                kind = UmlKind.Interface;
            }
            else if (t.IsEnum)
            {
                kind = UmlKind.Enum;
            }
            else if (t.IsValueType)
            {
                kind = UmlKind.Struct;
            }

            // search existing or create a new
            UmlType found = null;

            foreach (UmlType e in Types)
            {
                if (e.name.Equals(typename))
                {
                    found = e;
                    break;
                }
            }
recreate:
            if (found == null)
            {
                if (kind == UmlKind.Enum)
                {
                    found = new UmlEnum();
                }
                else
                {
                    found = new UmlClass();
                    ((UmlClass)found).kind = kind;
                }
                found.name = typename;
                Types.Add(found);
            }
            else
            {
                if (found.Kind == UmlKind.Enum && kind != UmlKind.Enum || found.Kind != UmlKind.Enum && kind == UmlKind.Enum)
                {
                    Types.Remove(found);
                    found = null;
                    goto recreate;
                }
                if (found.Kind != UmlKind.Enum)
                {
                    ((UmlClass)found).kind = kind;
                }
                found.Deleted = false;
            }
            return(found);
        }
Esempio n. 3
0
        private void toolStripButton2_Click(object sender, EventArgs e)
        {
            UmlType newClass = new UmlType();

            newClass.Bounds   = new Rectangle(1 * 21, 1 * 21, 7 * 21, 2 * 21);
            newClass.TypeName = "SomeClass";
            umlDesigner1.Diagram.Shapes.Add(newClass);
            umlDesigner1.Refresh();
        }
Esempio n. 4
0
        private bool Update()
        {
            Hashtable h = new Hashtable();

            foreach (Type t in assem.GetExportedTypes())
            {
                if (t.DeclaringType != null)
                {
                    continue;
                }
                UmlNamespace ns       = root;
                string       typename = t.FullName;
                int          lastdot  = typename.LastIndexOf('.');
                if (lastdot >= 0)
                {
                    string N = typename.Substring(0, lastdot);
                    typename = typename.Substring(lastdot + 1);
                    if (h.ContainsKey(N))
                    {
                        ns = (UmlNamespace)h[N];
                    }
                    else
                    {
                        h[N] = ns = EnsureNamespaceCreated(root, N);
                    }
                }
                if (typename.Length == 0)
                {
                    return(false);
                }
                if (ns.Types == null)
                {
                    ns.Types = new ArrayList();
                }
                UmlType found = UpdateTypeInArray(ns.Types, t, typename);
                if (!UpdateMembers(found, t))
                {
                    return(false);
                }
            }

            return(true);
        }
Esempio n. 5
0
        /// <summary>
        /// Resolve inheritances in DllProject, use referenced projects to search
        /// </summary>
        public static void Inheritances(UmlProject proj, Hashtable dllprojs, ArrayList errors)
        {
            foreach (DictionaryEntry ent in proj.classes)
            {
                Type    t  = (Type)ent.Key;
                UmlType tp = (UmlType)ent.Value;

                if (tp is UmlClass)
                {
                    if (t.BaseType != null && !t.BaseType.Equals(typeof(object)))
                    {
                        UmlClass cl        = (UmlClass)tp;
                        Type     base_type = t.BaseType;

                        cl.BaseList = new ArrayList();
                        UmlProject base_proj = (UmlProject)dllprojs[base_type.Assembly.FullName];

                        if (base_proj == null)
                        {
                            errors.Add("unknown assembly: " + base_type.Assembly.FullName);
                            continue;
                        }

                        UmlClass base_class = (UmlClass)base_proj.name_to_class[base_type.FullName];

                        if (base_class == null)
                        {
                            errors.Add("unknown class in assembly: " + base_type.FullName);
                            continue;
                        }

                        cl.BaseList.Add(base_class);
                    }
                    else
                    {
                        ((UmlClass)tp).BaseList = null;
                    }
                }
            }
        }
Esempio n. 6
0
        private bool UpdateMembers( UmlType cl, Type tpcl )
        {
            classes[tpcl] = cl;
            name_to_class[tpcl.FullName] = cl;

            if( cl is UmlClass ) {
                // nested
                UmlClass ucl = (UmlClass)cl;
                foreach( Type t in tpcl.GetNestedTypes() ) {
                    if( ucl.Types == null )
                        ucl.Types = new ArrayList();
                    UmlType found = UpdateTypeInArray( ucl.Types, t, t.Name );
                    if( !UpdateMembers( found, t ) )
                        return false;
                }
            }

            return true;
        }
Esempio n. 7
0
        private void Form1_Load(object sender, EventArgs e)
        {
            //if (openFileDialog1.ShowDialog() == DialogResult.OK)
            //{
            //    Hashtable classLookup = new Hashtable();
            //    IDomainMap dm = DomainMap.Load(openFileDialog1.FileName);

            //    foreach (IClassMap classMap in dm.ClassMaps)
            //    {
            //        UmlType umlClass = new UmlType();
            //        umlClass.TypeName = classMap.Name;

            //        foreach (IPropertyMap propertyMap in classMap.PropertyMaps)
            //        {
            //            UmlProperty umlProperty = new UmlProperty();
            //            umlProperty.Name = propertyMap.Name;
            //            umlProperty.Type = propertyMap.DataType;
            //            umlClass.Properties.Add(umlProperty);
            //        }
            //        umlClass.Bounds = new Rectangle(0, 0, 200, 10);
            //        umlClass.Expanded = true;
            //        umlDesigner1.Diagram.Shapes.Add(umlClass);
            //        classLookup.Add(umlClass.TypeName, umlClass);
            //    }

            //    foreach (IClassMap classMap in dm.ClassMaps)
            //    {
            //        foreach (IPropertyMap propertyMap in classMap.PropertyMaps)
            //        {
            //            if (propertyMap.ReferenceType != Puzzle.NPersist.Framework.Enumerations.ReferenceType.None)
            //            {
            //                UmlType start = (UmlType)classLookup[classMap.Name];
            //                UmlType end = (UmlType)classLookup[propertyMap.DataType];
            //                UmlConnection umlConnection = new UmlConnection();
            //                umlConnection.Start = start;
            //                umlConnection.End = end;
            //                umlDesigner1.Diagram.Shapes.Add(umlConnection);
            //            }
            //        }
            //    }
            //}

            umlDesigner1.AutoLayout();

            UmlType person = new UmlType();

            person.Bounds   = new Rectangle(1 * 21, 1 * 21, 7 * 21, 2 * 21);
            person.TypeName = "Person";
            umlDesigner1.Diagram.Shapes.Add(person);

            UmlType employee = new UmlType();

            employee.Bounds   = new Rectangle(3 * 21, 6 * 21, 7 * 21, 2 * 21);
            employee.Expanded = true;
            UmlProperty prop = new UmlProperty();

            prop.Name = "Name";
            prop.Type = "System.String";
            employee.Properties.Members.Add(prop);



            prop      = new UmlProperty();
            prop.Name = "Age";
            prop.Type = "System.Int32";
            employee.Properties.Members.Add(prop);
            employee.InheritsType = person;

            employee.TypeName = "Employee";
            umlDesigner1.Diagram.Shapes.Add(employee);

            UmlConnection connection1 = new UmlConnection();

            connection1.Start = employee;
            connection1.End   = person;
            umlDesigner1.Diagram.Shapes.Add(connection1);

            //employee.BorderPen = new Pen(Color.Black, 1);
            //employee.BorderPen.DashCap = DashCap.Round;
            //employee.BorderPen.DashStyle = DashStyle.Dash;

            //person.BorderPen = new Pen(Color.Gray, 2);
            //person.BorderPen.DashCap = DashCap.Round;
            //person.BorderPen.DashStyle = DashStyle.Dash;
        }