Beispiel #1
0
    private string GetPlaceholdContent(string PlaceholderName, HtmlReader LoadedHtmlReader)
    {
        string RetPlaceholderContent = "";

        switch (PlaceholderName)
        {
        case TemplatePlacholderInternal.FileName:
            RetPlaceholderContent = Path.GetFileName(LoadedHtmlReader.FullFilePath);
            break;

        case TemplatePlacholderInternal.FilePath:
            RetPlaceholderContent = Path.GetDirectoryName(LoadedHtmlReader.FullFilePath);
            break;

        default:
            string PlaceholderRegex = PlaceholderName.TrimStart(new char[] { '{' }).TrimEnd(new char[] { '}' });
            if (PlaceholderName.StartsWith("{{{"))
            {
                RetPlaceholderContent = LoadedHtmlReader.GetOuterHtmlContent(PlaceholderRegex);
            }
            else if (PlaceholderName.StartsWith("{{"))
            {
                RetPlaceholderContent = LoadedHtmlReader.GetInnerHtmlContent(PlaceholderRegex);
            }
            else if (PlaceholderName.StartsWith("{"))
            {
                string[] PlaceholderRegexArray = PlaceholderRegex.Split(',');

                if (PlaceholderRegexArray.Length == 1)
                {
                    RetPlaceholderContent = LoadedHtmlReader.GetCSVInnerHtmlContent(PlaceholderRegexArray[0]);
                }
                else if (PlaceholderRegexArray.Length == 2)
                {
                    RetPlaceholderContent = LoadedHtmlReader.GetAttributeHtmlContent(PlaceholderRegexArray[0], PlaceholderRegexArray[1]);


                    string[] RetPlaceholderContentArray = RetPlaceholderContent.Split(',');
                    for (int i = 0; i < RetPlaceholderContentArray.Length; i++)
                    {
                        RetPlaceholderContentArray[i] = Path.GetFileName(RetPlaceholderContentArray[i]);
                    }

                    RetPlaceholderContent = String.Join(",", RetPlaceholderContentArray);
                }
            }
            break;
        }

        return(RetPlaceholderContent);
    }
    private string GetPlaceholdContent(string PlaceholderName, HtmlReader LoadedHtmlReader)
    {
        string RetPlaceholderContent = "";

        switch (PlaceholderName)
        {
            case TemplatePlacholderInternal.FileName:
                RetPlaceholderContent = Path.GetFileName(LoadedHtmlReader.FullFilePath);
                break;
            case TemplatePlacholderInternal.FilePath:
                RetPlaceholderContent = Path.GetDirectoryName(LoadedHtmlReader.FullFilePath);
                break;
            default:
                string PlaceholderRegex = PlaceholderName.TrimStart(new char[] { '{' }).TrimEnd(new char[] { '}' });
                if (PlaceholderName.StartsWith("{{{"))
                {
                    RetPlaceholderContent = LoadedHtmlReader.GetOuterHtmlContent(PlaceholderRegex);
                }
                else if (PlaceholderName.StartsWith("{{"))
                {
                    RetPlaceholderContent = LoadedHtmlReader.GetInnerHtmlContent(PlaceholderRegex);
                }
                else if (PlaceholderName.StartsWith("{"))
                {
                    string[] PlaceholderRegexArray = PlaceholderRegex.Split(',');

                    if (PlaceholderRegexArray.Length == 1)
                    {
                        RetPlaceholderContent = LoadedHtmlReader.GetCSVInnerHtmlContent(PlaceholderRegexArray[0]);
                    }
                    else if (PlaceholderRegexArray.Length == 2)
                    {
                        RetPlaceholderContent = LoadedHtmlReader.GetAttributeHtmlContent(PlaceholderRegexArray[0], PlaceholderRegexArray[1]);

                        string[] RetPlaceholderContentArray = RetPlaceholderContent.Split(',');
                        for (int i = 0; i < RetPlaceholderContentArray.Length; i++)
                        {
                            RetPlaceholderContentArray[i] = Path.GetFileName(RetPlaceholderContentArray[i]);
                        }

                        RetPlaceholderContent = String.Join(",", RetPlaceholderContentArray);
                    }
                }
                break;
        }

        return RetPlaceholderContent;
    }