Example #1
0
        /// <summary>
        /// Creates the name of the project folder.
        /// </summary>
        /// <param name="layer">The layer.</param>
        /// <param name="packageLayerName">Name of the package layer.</param>
        /// <returns></returns>
        public virtual string CreateProjectFolderName(SoftwareLayer layer, string packageLayerName)
        {
            if (packageLayerName == null)
            {
                packageLayerName = layer.Name;
            }
            LayerNamingRule rule = FindRule(layer);

            return(string.Format(rule.ProjectFolderFormatString, packageLayerName, layer.VSProjectName, layer.Component.Namespace, rule.DefaultName));
        }
Example #2
0
        /// <summary>
        /// Creates the name of the assembly.
        /// </summary>
        /// <param name="layer">The layer.</param>
        /// <returns></returns>
        public virtual string CreateAssemblyName(SoftwareLayer layer)
        {
            LayerNamingRule rule = FindRule(layer);
            string          fmt  = rule.AssemblyFormatString;

            if ((layer is PresentationLayer || layer is UIWorkflowLayer) && ((Layer)layer).HostingContext == HostingContext.Standalone)
            {
                fmt = "{4}";
            }
            return(string.Format(fmt, layer.VSProjectName, layer.Namespace, layer.Name, layer.Component.Model.Name, layer.Component.Name));
        }
Example #3
0
        /// <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));
        }
Example #4
0
        /// <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);
        }
Example #5
0
        /// <summary>
        /// Creates the name of the element.
        /// </summary>
        /// <param name="layer">The layer.</param>
        /// <param name="initialName">The initial name.</param>
        /// <returns></returns>
        public virtual string CreateElementName(SoftwareLayer layer, string initialName)
        {
            if (layer == null)
            {
                return(initialName);
            }
            if (initialName == null)
            {
                initialName = String.Empty;
            }

            LayerNamingRule rule = FindRule(layer);

            return(string.Format(rule.ElementFormatString, ToPascalCasing(initialName), layer.Name));
        }
Example #6
0
        /// <summary>
        /// Nom du layer package
        /// </summary>
        /// <param name="layer">The layer.</param>
        /// <returns></returns>
        public virtual string GetLayerName(Layer layer)
        {
            LayerNamingRule rule = FindRule(layer);

            return(rule.DefaultName);
        }