public static void AddProject( UmlModel m, string filename ) { UmlProject p = new UmlProject(); p.filename = filename; p.name = Path.GetFileNameWithoutExtension( filename ); m.projects.Add( p ); }
public UmlObject GetObject(string name) { int index = name.IndexOf('/'); if (index == -1) { return(null); } string proj_name = name.Substring(0, index); UmlProject project = null; foreach (UmlProject p in projects) { if (p.uid.Equals(proj_name)) { project = p; break; } } if (project == null) { foreach (UmlProject p in dllprojs) { if (p.uid.Equals(proj_name)) { project = p; break; } } } if (project != null) { UmlObject o = project.root; string[] genid = name.Substring(index + 1).Split(new char[] { '.' }); foreach (string s in genid) { Hashtable hash = null; if (o is UmlNamespace) { hash = ((UmlNamespace)o).Children; } else if (o is UmlClass) { hash = ((UmlClass)o).Children; } if (hash == null || !hash.ContainsKey(s)) { return(null); } o = (UmlObject)hash[s]; } return(o); } return(null); }
public void AssignUID(UmlProject p) { string buid = p.name; if (buid.IndexOf(',') != -1) { buid = buid.Substring(0, buid.IndexOf(',')); } string uid = buid; int counter = 1; while (true) { UmlProject f = null; foreach (UmlProject p2 in projects) { if (p2.uid != null && p2.uid.Equals(uid)) { f = p2; } } foreach (UmlProject p3 in dllprojs) { if (p3.uid != null && p3.uid.Equals(uid)) { f = p3; } } if (f == null) { p.uid = uid; break; } counter++; uid = buid + counter.ToString(); } }
/// <summary> /// Search typename in namespace 'qual_name' in curr and refs projects /// </summary> private UmlType SearchInUsing( ArrayList refs, UmlProject curr, string qual_name, string typename, string scope_ns ) { do { string where = Combine( scope_ns, qual_name ); UmlType res; UmlObject ns = GetTypeOrNS( curr, where ); if( ns != null ) { res = SearchInside( ns, typename ); if( res != null ) return res; } // search referenced projects foreach( UmlProject r in refs ) { ns = GetTypeOrNS( r, where ); if( ns != null ) { res = SearchInside( ns, typename ); if( res != null ) return res; } } if( scope_ns.Length == 0 ) break; int ind = scope_ns.LastIndexOf( '.' ); if( ind >= 0 ) scope_ns = scope_ns.Substring( 0, ind ); else scope_ns = String.Empty; } while(true); return null; }
/// <summary> /// Gets type or Namespace name in project /// </summary> private UmlObject GetTypeOrNS( UmlProject proj, string qualified ) { UmlObject curr = proj.root; if( qualified.Length == 0 ) return curr; foreach( string s in qualified.Split( new char[] { '.' } ) ) { curr = SearchInTypeOrNS( curr, s ); if( curr == null ) break; } return curr; }
private static void CreateProjectFromXml( XmlNode n, UmlProject proj ) { string fname = null; if( n.Name.Equals( "File" ) ) { fname = n.Attributes["RelPath"].Value; if( !fname.EndsWith( ".cs" ) ) fname = null; else { fname = Path.GetFullPath( fname ); proj.files.Add( fname ); } } else if( n.Name.Equals( "CSHARP" ) ) { proj.guid = n.Attributes[ "ProjectGuid" ].Value; if( proj.guid != null && !proj.guid.StartsWith( "{" ) ) proj.guid = null; if( proj.guid != null ) proj.guid = proj.guid.ToLower(); } else if( n.Name.Equals( "Reference" ) ) { foreach( XmlAttribute attr in n.Attributes ) if( attr.Name.Equals( "Project" ) ) { // project reference proj.refs.Add( attr.Value.ToLower() ); } else if( attr.Name.Equals( "HintPath" ) ) { // external reference fname = attr.Value.ToLower(); if( !fname.EndsWith( ".dll" ) ) fname = null; else { fname = Path.GetFullPath( fname ).ToLower(); proj.refs.Add( fname ); } } } else if( n.Name.Equals( "Settings" ) ) { fname = n.Attributes["AssemblyName"].Value; if( fname != null && fname.Length > 0 ) proj.name = fname; } if( n.HasChildNodes ) { foreach( XmlNode sub in n ) CreateProjectFromXml( sub, proj ); } }
public void AssignUID( UmlProject p ) { string buid = p.name; if( buid.IndexOf( ',' ) != -1 ) buid = buid.Substring( 0, buid.IndexOf( ',' ) ); string uid = buid; int counter = 1; while( true ) { UmlProject f = null; foreach( UmlProject p2 in projects ) if( p2.uid != null && p2.uid.Equals( uid ) ) f = p2; foreach( UmlProject p3 in dllprojs ) if( p3.uid != null && p3.uid.Equals( uid ) ) f = p3; if( f == null ) { p.uid = uid; break; } counter++; uid = buid + counter.ToString(); } }