private static UMLAttributeCollection GetProperties(Type type) { UMLAttributeCollection attributes = new UMLAttributeCollection(); foreach (PropertyInfo property in type.GetProperties(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance)) { if (property.DeclaringType == type && !property.IsSpecialName) { MethodInfo methodInfo = property.GetGetMethod(true); if (methodInfo != null) { UMLAttribute attribute = new UMLAttribute(); attribute.Name = property.Name; attribute.Type = property.PropertyType.Name; if (methodInfo.IsPublic) { attribute.Visibility = Visibility.Public; } if (methodInfo.IsPrivate) { attribute.Visibility = Visibility.Private; } if (methodInfo.IsFamily) { attribute.Visibility = Visibility.Protected; } attributes.Add(attribute); } } } return(attributes); }
/// <summary> /// Loads the files /// </summary> public void LoadFilesExcel() { DataTable dtResult = new DataTable(); dtResult = GetDataTable(_fileName, FILE_SHEET, "Name <> '' AND AttributesList <> ''"); UMLPackage pack = new UMLPackage(); pack.Name = "FileImport"; pack.Owner = _designModel; Packages.Add(pack); foreach (DataRow dr in dtResult.Rows) { UMLFile file = new UMLFile(); file.Name = dr["Name"].ToString().Trim(); string test = file.Name.GetType().Name; file.Dets = Convert.ToInt32(dr["Dets"].ToString()); file.Rets = Convert.ToInt32(dr["Rets"].ToString()); file.Type = dr["Type"].ToString(); file.Owner = pack; string[] attributes = dr["AttributesList"].ToString().Split(','); foreach (string a in attributes) { UMLAttribute attri = new UMLAttribute(); attri.Name = a.Trim(); attri.Owner = file; file.Attributes.Add(attri); } AddFile(file); } }
/// <summary> /// Adds a new det /// </summary> /// <param name="attribute"></param> public void AddDet(UMLAttribute attribute) { if (!Dets.Contains(attribute)) { Dets.Add(attribute); NotifyPropertyChanged("AddDet"); } }
/// <summary> /// Removes a det /// </summary> /// <param name="attribute"></param> public void RemoveDet(UMLAttribute attribute) { foreach (UMLAttribute det in Dets) { if (det.Guid == attribute.Guid) { Dets.Remove(det); NotifyPropertyChanged("RemoveDet"); break; } } }
private static UMLAttributeCollection GetStaticAndConstants(Type type) { UMLAttributeCollection attributes = new UMLAttributeCollection(); foreach (FieldInfo filed in type.GetFields(BindingFlags.Public | BindingFlags.Static)) { if (filed.DeclaringType == type && !filed.IsSpecialName) { UMLAttribute attribute = new UMLAttribute(); attribute.Name = filed.Name; attribute.Type = filed.FieldType.Name; attributes.Add(attribute); } } return(attributes); }