internal TemplateFile InstGetCached(string path)
        {
            var templatePath = "";

            // Precedence of WebPages =
            // LangPreview > IntPreview > Lang > Int

            if (_thisIsPreviewRun)
            {
                var previewPath = Path.GetFileNameWithoutExtension(path) + "_Preview" + Path.GetExtension(path);

                if (transformationData.CurrentFolderDetails.Language.ToLower().Equals("int"))
                {
                    templatePath = Path.Combine(_defaultIntTemplateLocation, previewPath);
                }
                else
                {
                    templatePath = File.Exists(Path.Combine(_defaultLanguageTemplateLocation, previewPath))
                                       ? Path.Combine(_defaultLanguageTemplateLocation, previewPath)
                                       : Path.Combine(_defaultIntTemplateLocation, previewPath);
                }

                templatePath = File.Exists(templatePath) ? templatePath : "";
            }

            if (string.IsNullOrWhiteSpace(templatePath))
            {
                if (transformationData.CurrentFolderDetails.Language.ToLower().Equals("int"))
                {
                    templatePath = Path.Combine(_defaultIntTemplateLocation, path);
                }
                else
                {
                    templatePath = File.Exists(Path.Combine(_defaultLanguageTemplateLocation, path))
                                       ? Path.Combine(_defaultLanguageTemplateLocation, path)
                                       : Path.Combine(_defaultIntTemplateLocation, path);
                }
            }

            if (!_cache.ContainsKey(templatePath))
            {
                if (!File.Exists(templatePath))
                {
                    transformationData.ErrorList.Add(
                        new ErrorDetail(
                            Language.Message("TemplateWasNotFoundIn", path, _defaultLanguageTemplateLocation),
                            MessageClass.Error, "", "", 0, 0));

                    _cache[templatePath] = MissingTemplate;
                    return _cache[templatePath];
                }

                _cache[templatePath] = new TemplateFile(templatePath, transformationData);

                _cache[templatePath].TemplateChanged += () =>
                    {
                        if (TemplatesChanged != null)
                        {
                            TemplatesChanged();
                        }
                    };
            }

            return _cache[templatePath];
        }
Beispiel #2
0
        internal TemplateFile InstGetCached(string path)
        {
            var templatePath = "";

            // Precedence of WebPages =
            // LangPreview > IntPreview > Lang > Int

            if (_thisIsPreviewRun)
            {
                var previewPath = Path.GetFileNameWithoutExtension(path) + "_Preview" + Path.GetExtension(path);

                if (transformationData.CurrentFolderDetails.Language.ToLower().Equals("int"))
                {
                    templatePath = Path.Combine(_defaultIntTemplateLocation, previewPath);
                }
                else
                {
                    templatePath = File.Exists(Path.Combine(_defaultLanguageTemplateLocation, previewPath))
                                       ? Path.Combine(_defaultLanguageTemplateLocation, previewPath)
                                       : Path.Combine(_defaultIntTemplateLocation, previewPath);
                }

                templatePath = File.Exists(templatePath) ? templatePath : "";
            }

            if (string.IsNullOrWhiteSpace(templatePath))
            {
                if (transformationData.CurrentFolderDetails.Language.ToLower().Equals("int"))
                {
                    templatePath = Path.Combine(_defaultIntTemplateLocation, path);
                }
                else
                {
                    templatePath = File.Exists(Path.Combine(_defaultLanguageTemplateLocation, path))
                                       ? Path.Combine(_defaultLanguageTemplateLocation, path)
                                       : Path.Combine(_defaultIntTemplateLocation, path);
                }
            }

            if (!_cache.ContainsKey(templatePath))
            {
                if (!File.Exists(templatePath))
                {
                    transformationData.ErrorList.Add(
                        new ErrorDetail(
                            Language.Message("TemplateWasNotFoundIn", path, _defaultLanguageTemplateLocation),
                            MessageClass.Error, "", "", 0, 0));

                    _cache[templatePath] = MissingTemplate;
                    return(_cache[templatePath]);
                }

                _cache[templatePath] = new TemplateFile(templatePath, transformationData);

                _cache[templatePath].TemplateChanged += () =>
                {
                    if (TemplatesChanged != null)
                    {
                        TemplatesChanged();
                    }
                };
            }

            return(_cache[templatePath]);
        }