Пример #1
0
        /// <summary>
        /// Recherche le modèle associé à la solution courante
        /// </summary>
        /// <returns></returns>
        /// <remarks>
        /// Le modèle associé est contenu dans un fichier portant le même nom que la solution
        /// </remarks>
        public static CandleModel GetModelFromCurrentSolution()
        {
            try
            {
                IShellHelper shell = ServiceLocator.Instance.GetService <IShellHelper>();
                if (shell == null)
                {
                    return(null);
                }

                // On cherche d'abord si le nom est enregistré dans la solution
                string candleModelPath = shell.GetSolutionAssociatedModelName();
                if (candleModelPath == null)
                {
                    // Si pas trouvé, on le déduit à partir du nom de la solution
                    string solutionName = (string)shell.Solution.Properties.Item("Name").Value;
                    candleModelPath =
                        System.IO.Path.Combine(shell.SolutionFolder,
                                               String.Concat(solutionName, ModelConstants.FileNameExtension));
                }
                // Recherche dans la RDT
                CandleModel model = GetModelFromCurrentSolution(candleModelPath);
                // Si tjs null, on essaye de le charger directement
                if (model == null)
                {
                    ModelLoader loader = ModelLoader.GetLoader(candleModelPath, true);
                    if (loader != null)
                    {
                        model = loader.Model;
                    }
                }
                return(model);
            }
            catch
            {
            }

            return(null);
        }