/// <summary> /// Finds model with name "Phase Iteration Model" /// </summary> /// <param name="model"></param> /// <returns></returns> private bool FindLogicalView(UMLModel model) { //if (model.Name == "Logical View") if (model.Name == "Phase Iteration Model") { return(true); } return(false); }
/// <summary> /// Finds model with name "Design Model" /// </summary> /// <param name="model"></param> /// <returns></returns> private bool FindDesignView(UMLModel model) { //if (model.Name == "Logical View") if (model.Name == "Design Model") { return(true); } return(false); }
/// <summary> /// Finds model with name "Use Case Model" /// </summary> /// <param name="model"></param> /// <returns></returns> private bool FindScenarios(UMLModel model) { //if (model.Name == "Scenarios") if (model.Name == "Use Case Model") { return(true); } return(false); }
public static void OpenSolution(object sender, DoWorkEventArgs e) { bwAsync = sender as BackgroundWorker; EnvDTE80.DTE2 dte = null; Dictionary <string, IUMLElement> listElements = new Dictionary <string, IUMLElement>(); try { dte = (EnvDTE80.DTE2)Microsoft.VisualBasic.Interaction.CreateObject("VisualStudio.DTE.8.0", ""); Solution2 soln = (Solution2)dte.Solution; soln.Open(File); SolutionBuild2 build = (SolutionBuild2)soln.SolutionBuild; addMessageBackgroundWorker(0, "Building Solution..."); build.SolutionConfigurations.Item("Debug").Activate(); build.Clean(true); build.Build(true); UMLModel model = Helper.GetCurrentElement <UMLModel>(); if (build.LastBuildInfo == 0 && model != null) { IUMLElement solutionUML = new UMLPackage(); solutionUML.Name = Path.GetFileName(soln.FileName); solutionUML.Owner = model; listElements.Add(solutionUML.Name, solutionUML); for (int i = 1; i <= soln.Projects.Count; i++) { Project project = soln.Projects.Item(i); if (project.Properties != null) { string fullPath = (string)project.Properties.Item("FullPath").Value; string outputfileName = (string)project.Properties.Item("OutputFileName").Value; Assembly assembly = Assembly.LoadFile(fullPath + @"Bin\Debug\" + outputfileName); IUMLElement projectUML = new UMLPackage(); projectUML.Name = project.Name; listElements.Add(project.Name, projectUML); projectUML.Owner = solutionUML; addMessageBackgroundWorker(0, "Processing Types: \n" + project.Name); foreach (Type type in assembly.GetTypes()) { if (type.MemberType == MemberTypes.TypeInfo) { IUMLElement element = null; if (type.IsEnum && IncludeEnumeration) { element = new UMLEnumeration(); element.Name = type.Name; ((UMLEnumeration)element).Literals = GetLiterals(type); } else { if (type.IsClass && IncludeClass) { element = new UMLClass(); element.Name = type.Name; ((UMLClass)element).Attributes = GetProperties(type); ((UMLClass)element).Attributes.AddRange(GetStaticAndConstants(type)); ((UMLClass)element).Methods = GetMethods(type); if (type.IsGenericType) { element.Name = element.Name.Substring(0, element.Name.IndexOf("`")); element.Name += "<"; foreach (Type t in type.GetGenericArguments()) { element.Name += t.Name + ","; } element.Name = element.Name.TrimEnd(','); element.Name += ">"; } } else if (type.IsInterface && IncludeInterface) { element = new UMLInterface(); element.Name = type.Name; ((UMLInterface)element).Attributes = GetProperties(type); } } if (element != null) { IUMLElement owner = null; if (type.Namespace == null) { owner = projectUML; } else if (listElements.ContainsKey(type.Namespace)) { owner = listElements[type.Namespace]; } else { owner = new UMLPackage(); //if(type.Namespace.Contains(projectUML.Name)) //{ // owner.Name = type.Namespace.Replace(projectUML.Name, ""); //} owner.Stereotype = "ClassPackage"; owner.Name = type.Namespace; owner.Owner = projectUML; listElements.Add(type.Namespace, owner); } element.Owner = owner; if ((type.Attributes & TypeAttributes.Public) == TypeAttributes.Public) { element.Visibility = Visibility.Public; } else { element.Visibility = Visibility.Private; } XmlNode node = DocsByReflection.XMLFromType(type); if (node != null) { element.Documentation = node.InnerXml.Trim(); } if (!listElements.ContainsKey(type.Namespace + "." + type.Name)) { listElements.Add(type.Namespace + "." + type.Name, element); } } } } } } } else { // Error Build } soln.Close(true); } catch (SystemException ex) { //MessageBox.Show("ERROR: " + ex); } finally { if (dte != null) { dte.Quit(); } } Helper.BeginUpdate(); addMessageBackgroundWorker(0, "Init import..."); int pos = 0; foreach (IUMLElement element in listElements.Values) { pos++; addMessageBackgroundWorker((pos * 100) / listElements.Count, "Creating: \n" + element.Name); element.GetType().InvokeMember("Save", BindingFlags.Default | BindingFlags.InvokeMethod, null, element, new object[] { }); } addMessageBackgroundWorker(100, "End import"); Helper.EndUpdate(); }