Esempio n. 1
0
 public static UmlModel CreateEmptyModel()
 {
     UmlModel m = new UmlModel();
     m.projects = new ArrayList();
     m.dllprojs = new ArrayList();
     return m;
 }
Esempio n. 2
0
 public static void AddProject( UmlModel m, string filename )
 {
     UmlProject p = new UmlProject();
     p.filename = filename;
     p.name = Path.GetFileNameWithoutExtension( filename );
     m.projects.Add( p );
 }
Esempio n. 3
0
        private static void try_load(string out_file, string[] projs)
        {
            Console.WriteLine(Path.GetFileNameWithoutExtension(out_file));

            ArrayList errors;
            UmlModel  m = ModelBuilder.CreateEmptyModel();

            foreach (string s in projs)
            {
                ModelBuilder.AddProject(m, s);
            }
            ModelBuilder.UpdateModel(m, out errors, null);
            if (errors != null)
            {
                Console.WriteLine(out_file);
                foreach (string err in errors)
                {
                    Console.WriteLine(err);
                }
                return;
            }

            try {
                XmlSerializer ser = new XmlSerializer(typeof(UmlModel));
                StreamWriter  sw  = new StreamWriter(out_file);
                ser.Serialize(sw, m);
                Console.WriteLine("passed");
            }
            catch (Exception ex) {
                Console.WriteLine(ex.ToString());
                Console.WriteLine("failed");
            }
        }
Esempio n. 4
0
 public override string AsUml(bool full)
 {
     if (full)
     {
         return(base.AsUml(full) + " { " + Accessors + " } : " + UmlModel.GetShortName(Type));
     }
     else
     {
         return(base.AsUml(full) + " { " + Accessors + " }");
     }
 }
Esempio n. 5
0
        public static IEnumerable GetRelations( UmlClass cl, UmlModel m )
        {
            ArrayList l = new ArrayList();

            // get inheritances
            if( cl.BaseObjects != null )
                foreach( string s in cl.BaseObjects ) {
                    UmlClass obj = m.GetObject( s ) as UmlClass;
                    if( obj != null )
                        l.Add( new UmlRelation( obj, cl, obj.kind == UmlKind.Interface ? UmlRelationType.Realization : UmlRelationType.Inheritance, null, null, null, null ) );
                }

            // get associations
            Hashtable h = new Hashtable();
            if( cl.Members != null )
                foreach( UmlMember mb in cl.Members ) {
                    string name = mb.name, type = null;
                    switch( mb.Kind ) {
                        case UmlKind.Property:
                            type = ((UmlProperty)mb).Type;
                            break;
                        case UmlKind.Field:
                            type = ((UmlField)mb).Type;
                            break;
                    }

                    if( type != null ) {
                        if( type.IndexOf( '[' ) >= 0 ) {
                            int i = type.IndexOf( '[' );
                            name += type.Substring(i);
                            type = type.Substring(0, i);
                        }

                        UmlClass obj = m.GetObject( type ) as UmlClass;

                        if( obj != null && obj != cl ) {
                            if( h.ContainsKey( obj ) )
                                h[obj] = (string)h[obj] + "," + name;
                            else
                                h[obj] = name;
                        }
                    }
                }

            foreach( UmlClass obj in h.Keys ) {
                l.Add( new UmlRelation( obj, cl, UmlRelationType.Association, (string)h[obj], null, null, null ) );

            }

            return l;
        }
Esempio n. 6
0
 public static void AddProjectFromSLN( UmlModel m, string slnname )
 {
     System.Environment.CurrentDirectory = Path.GetDirectoryName( slnname );
     try {
         System.Text.RegularExpressions.Regex re = new System.Text.RegularExpressions.Regex( @"^Project\(.*\)\s+=\s+"".*"",\s+""(.*)"",\s+"".*""$" );
         using( StreamReader sr = new StreamReader( slnname ) ) {
             string line;
             while ((line = sr.ReadLine()) != null) {
                 System.Text.RegularExpressions.Match mt = re.Match(line);
                 if( mt.Success ) {
                     string filename = mt.Groups[1].Value;
                     if( filename.ToLower().EndsWith( ".csproj" ) && File.Exists( filename ) )
                         AddProject( m, Path.GetFullPath( filename ) );
                 }
             }
         }
     } catch {
     }
 }
Esempio n. 7
0
        internal static string GetParametersAsUml(ArrayList l)
        {
            if (l == null)
            {
                return(String.Empty);
            }

            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            foreach (UmlParameter p in l)
            {
                if (sb.Length > 0)
                {
                    sb.Append("; ");
                }
                sb.Append(p.name);
                sb.Append(" :");
                sb.Append(UmlModel.GetShortName(p.Type));
            }
            return(sb.Length == 0 ? String.Empty : " " + sb.ToString() + " ");
        }
Esempio n. 8
0
        static void Main(string[] args)
        {
            //string text;

            //if( args.Length > 0 )
            //	text = new StreamReader(args[0]).ReadToEnd();
            //else
            //	text = new StreamReader( /*System.Console.OpenStandardInput()*/ @"D:\projects\CDS\UMLDes.Model\test\test.cs" ).ReadToEnd();

            ArrayList errors;
            UmlModel  m = ModelBuilder.CreateEmptyModel();

            //ModelBuilder.AddProject( m, @"D:\projects\CDS\CDS.csproj" );
            ModelBuilder.AddProject(m, @"D:\projects\CDS\UMLDes.Model.CSharp\UMLDes.Model.CSharp.csproj");
            ModelBuilder.AddProject(m, @"D:\projects\CDS\UMLDes.Model\UMLDes.Model.csproj");
            //ModelBuilder.AddProject( m, @"D:\projects\test_lib\WindowsApplication1\WindowsApplication1.csproj" );
            ModelBuilder.UpdateModel(m, out errors);
            if (errors != null)
            {
                foreach (string err in errors)
                {
                    Console.WriteLine(err);
                }
                return;
            }

            try {
                XmlSerializer ser = new XmlSerializer(typeof(UmlModel));
                StreamWriter  sw  = new StreamWriter(@"d:\temp\model.xml");
                ser.Serialize(sw, m);
            }
            catch (Exception ex) {
                Console.WriteLine(ex.ToString());
            }

            //NamespaceDecl node = parser.parse( text );
            //Console.WriteLine( "parsed\n" );
            //NodeView.ShowNode( node, text );
        }
Esempio n. 9
0
 public UmlDesignerSolution()
 {
     projectfile = String.Empty;
     model = ModelBuilder.CreateEmptyModel();
 }
Esempio n. 10
0
 public static void UpdateModel( UmlModel model, out ArrayList errors, StatusNotifier sn )
 {
     ModelBuilder mb = new ModelBuilder();
     mb.model = model;
     mb.notify = sn;
     mb.Update();
     errors = mb.errors.Count > 0 ? mb.errors : null;
 }
Esempio n. 11
0
        /// <summary>
        /// Fixes GUI trees and references
        /// </summary>
        public void PostLoad( )
        {
            if( model != null )
                ModelBuilder.PostLoad( model );
            else
                model = ModelBuilder.CreateEmptyModel();

            foreach( GUI.View d in diagrams )	{
                d.proj = this;
                if( container != null )
                    container.SelectView( d, false );	// TODO bad code
                d.PostLoad();
            }
        }
Esempio n. 12
0
 public override string AsUml(bool full)
 {
     if (full)
     {
         return(VisibilityString + "\x00ABevent\xBB " + name + (Accessors == null?"":" { " + Accessors + " }") + " : " + UmlModel.GetShortName(Type));
     }
     else
     {
         return(VisibilityString + "\x00ABevent\xBB " + name);
     }
 }
Esempio n. 13
0
 public static void PostLoad( UmlModel model )
 {
     model.Visit( new UmlObject.Visitor( SetParentAndBuildHash ), null );
 }
Esempio n. 14
0
 public override string AsUml(bool full)
 {
     if (full)
     {
         return(VisibilityString + "\x00ABindexer\xBB " + name + "[" + GetParametersAsUml(Params) + "] : " + UmlModel.GetShortName(this.ReturnType));
     }
     else
     {
         return(VisibilityString + "\x00ABindexer\xBB " + name + "[]");
     }
 }
Esempio n. 15
0
 public override string AsUml(bool full)
 {
     return(base.AsUml(full) + " : " + UmlModel.GetShortName(Type));
 }
Esempio n. 16
0
 private static bool UpdateStudioProjects( UmlModel m )
 {
     foreach( UmlProject p in m.projects ) {
         try {
             Directory.SetCurrentDirectory( Path.GetDirectoryName( p.filename ) );
             XmlDocument doc = new XmlDocument();
             doc.Load( p.filename );
             p.name = null;
             p.files = new ArrayList();
             p.refs = new ArrayList();
             if( p.root == null )
                 p.root = new UmlNamespace();
             CreateProjectFromXml( doc, p );
             if( p.name == null )
                 p.name = Path.GetFileNameWithoutExtension(p.filename);
             if( p.guid == null )
                 p.guid = "{" + System.Guid.NewGuid().ToString().ToLower() + "}";
             if( p.uid == null )
                 m.AssignUID( p );
         } catch {
             return false;
         }
     }
     return true;
 }
Esempio n. 17
0
 public override string AsUml(bool full)
 {
     if (full)
     {
         return(base.AsUml(full) + "(" + GetParametersAsUml(Params) + ")" + (ReturnType == null ? "":" : " + UmlModel.GetShortName(ReturnType)));
     }
     else
     {
         return(base.AsUml(full) + "()");
     }
 }
Esempio n. 18
0
        public static IEnumerable GetRelations(UmlClass cl, UmlModel m)
        {
            ArrayList l = new ArrayList();

            // get inheritances
            if (cl.BaseObjects != null)
            {
                foreach (string s in cl.BaseObjects)
                {
                    UmlClass obj = m.GetObject(s) as UmlClass;
                    if (obj != null)
                    {
                        l.Add(new UmlRelation(obj, cl, obj.kind == UmlKind.Interface ? UmlRelationType.Realization : UmlRelationType.Inheritance, null, null, null, null));
                    }
                }
            }

            // get associations
            Hashtable h = new Hashtable();

            if (cl.Members != null)
            {
                foreach (UmlMember mb in cl.Members)
                {
                    string name = mb.name, type = null;
                    switch (mb.Kind)
                    {
                    case UmlKind.Property:
                        type = ((UmlProperty)mb).Type;
                        break;

                    case UmlKind.Field:
                        type = ((UmlField)mb).Type;
                        break;
                    }

                    if (type != null)
                    {
                        if (type.IndexOf('[') >= 0)
                        {
                            int i = type.IndexOf('[');
                            name += type.Substring(i);
                            type  = type.Substring(0, i);
                        }

                        UmlClass obj = m.GetObject(type) as UmlClass;

                        if (obj != null && obj != cl)
                        {
                            if (h.ContainsKey(obj))
                            {
                                h[obj] = (string)h[obj] + "," + name;
                            }
                            else
                            {
                                h[obj] = name;
                            }
                        }
                    }
                }
            }

            foreach (UmlClass obj in h.Keys)
            {
                l.Add(new UmlRelation(obj, cl, UmlRelationType.Association, (string)h[obj], null, null, null));
            }

            return(l);
        }