Ejemplo n.º 1
0
        public string[] getElementID(string[] types, string[] groups, string[] views, string[] projects)
        {
            List <string> list = new List <string>();

            // Get all elements in selected views
            foreach (var i in views)
            {
                string id_view = archiDocument.Dict_view_name.FirstOrDefault(x => x.Value.Equals(i)).Key;
                if (id_view != null)
                {
                    list.AddRange(archiDocument.Dict_view[id_view]);
                }
            }

            // Get all elements in selected groups
            foreach (var i in groups)
            {
                string id_group = archiDocument.Dict_namespace[i];
                list.AddRange(archiDocument.Dict_group[id_group]["interface"]);
                list.AddRange(archiDocument.Dict_group[id_group]["class"]);
            }

            // Get all elements in selected components
            List <string> list_idProject = new List <string>();

            foreach (var i in projects)
            {
                string id_project = archiDocument.Dict_project_elements.FirstOrDefault(x => dict_element[x.Key].Class_name_.Equals(i)).Key;
                if (id_project != null)
                {
                    list.AddRange(archiDocument.Dict_project_elements[id_project]);
                    list_idProject.Add(id_project);
                }
            }

            list.AddRange(list_idProject);
            // Remove dublication
            list = list.Distinct().ToList();
            // Remove elements with unselected type
            list.RemoveAll(x => !types.Contains(Dict_element[x].Type_));
            // Remove elements don't exist
            list.RemoveAll(x => !Dict_element.ContainsKey(x));
            // Remove new elements because of $interface
            list.RemoveAll(x => !x.StartsWith("id"));
            // Remove elements not belong to selected components
            if (list_idProject.Count() > 0)
            {
                list.RemoveAll(x => archiDocument.Dict_element_project.Keys.Contains(x) && !list_idProject.Contains(archiDocument.Dict_element_project[x]));
            }

            List <string> list_element_name = new List <string>();

            list.ForEach(x => list_element_name.Add(Dict_element[x].Name_));

            return(list.ToArray());
        }
Ejemplo n.º 2
0
        public string[] getElements(string[] types, string[] groups, string[] views, string[] projects)
        {
            List <string> list = new List <string>();

            // Get all elements in selected views
            foreach (var i in views)
            {
                string id_view = archiDocument.Dict_view_name.FirstOrDefault(x => x.Value.Equals(i)).Key;
                if (id_view != null)
                {
                    list.AddRange(archiDocument.Dict_view[id_view]);
                }
            }

            // Get all elements in selected groups
            foreach (var i in groups)
            {
                string id_group = archiDocument.Dict_namespace[i];
                list.AddRange(archiDocument.Dict_group[id_group]["interface"]);
                list.AddRange(archiDocument.Dict_group[id_group]["class"]);
            }

            // Get all elements in selected components
            List <string> list_idProject = new List <string>();

            foreach (var i in projects)
            {
                string id_project = archiDocument.Dict_project_elements.FirstOrDefault(x => dict_element[x.Key].Class_name_.Equals(i)).Key;
                if (id_project != null)
                {
                    list.AddRange(archiDocument.Dict_project_elements[id_project]);
                    list_idProject.Add(id_project);
                }
            }

            // Remove dublication
            list = list.Distinct().ToList();
            // Remove elements with unselected type
            list.RemoveAll(x => !types.Contains(Dict_element[x].Type_));
            // Remove elements don't exist
            list.RemoveAll(x => !Dict_element.ContainsKey(x));
            // Remove new elements because of $interface
            list.RemoveAll(x => !x.StartsWith("id"));
            // Remove elements with $generation = false
            list.RemoveAll(x => Dict_element[x].Properties_.ContainsKey("$generation") && Dict_element[x].Properties_["$generation"].Equals("false"));
            // Remove elements not belong to selected components
            if (list_idProject.Count() > 0)
            {
                list.RemoveAll(x => archiDocument.Dict_element_project.Keys.Contains(x) && !list_idProject.Contains(archiDocument.Dict_element_project[x]));
            }

            List <string> list_element_name = new List <string>();

            list.ForEach(x => list_element_name.Add(Dict_element[x].Name_));

            // If only choose the Application Component as type, ze generate projects instead of classes
            //if (types.Count() == 1 && types[0].Equals(ElementConstants.ApplicationComponent))
            //{
            //    list.AddRange(GetProjects(solution));
            //    return list.ToArray();
            //}
            return(list_element_name.ToArray());
        }