/// <summary> /// Finds the rule. /// </summary> /// <param name="layer">The layer.</param> /// <returns></returns> protected LayerNamingRule FindRule(SoftwareLayer layer) { string layerTypeName = layer.GetType().Name; LayerNamingRule rule = _layersNamingRules.Find(delegate(LayerNamingRule r) { return(Utils.StringCompareEquals(r.LayerType, layerTypeName)); }); // Si n'existe pas, on en crée une par défaut if (rule == null) { rule = new LayerNamingRule(); rule.LayerType = layerTypeName; rule.AssemblyFormatString = "{2}"; rule.ProjectFolderFormatString = DefaultProjectFolderFormat; rule.FormatString = "{0}"; rule.ElementFormatString = "{0}"; rule.DefaultName = layer.GetType().Name; // Regles par défaut if (layer is DataLayer) { rule.DefaultName = "InfoLayer"; rule.ElementFormatString = "{0}Info"; } else if (layer is InterfaceLayer) { rule.DefaultName = "Interfaces"; rule.ElementFormatString = "I{0}"; rule.FormatString = "I{4}"; } else if (layer is DataAccessLayer) { rule.DefaultName = "DAO"; rule.ElementFormatString = "{0}DAO"; } else if (layer is BusinessLayer) { rule.DefaultName = "Services"; rule.ElementFormatString = "{0}BLL"; } else if (layer is PresentationLayer) { rule.DefaultName = "UILayer"; rule.ElementFormatString = "{0}"; } else { rule.DefaultName = "UILayer"; rule.ElementFormatString = "{0}"; } _layersNamingRules.Add(rule); } return(rule); }
/// <summary> /// Nom par défaut d'une couche /// </summary> /// <param name="layerPackage">The layer package.</param> /// <param name="element">Type de la couche</param> /// <param name="associatedName">Name of the associated.</param> /// <returns></returns> public virtual string CreateLayerName(LayerPackage layerPackage, SoftwareLayer element, string associatedName) { string typeName = element.GetType().Name; LayerNamingRule rule = FindRule(element); if (associatedName == null) { associatedName = rule.DefaultName; } return(string.Format(rule.FormatString, rule.DefaultName, element.Component.Name, element.Namespace, layerPackage != null ? layerPackage.Name : String.Empty, associatedName)); }