Exemple #1
0
        void EncodeResource(AbstractResource resource, StringBuilder sb)
        {
            switch (resource.Type)
            {
                case ResourceType.Image:
                    ImageResource imgResource = (ImageResource)resource;
                    string outputFilePath = basePath + "\\resources\\" + GetFileName(imgResource.Uri.LocalPath);
                    File.Copy(imgResource.Uri.LocalPath, outputFilePath, true);
                    sb.AppendLine("\t<img class=\"image\" src=\"" + outputFilePath + "\"/>");
                    sb.AppendLine("\t<h1 class=\"pageTitle\">" + Common.HtmlEncode(imgResource.Title) + "</h1>");
                    break;

                case ResourceType.Text:
                    TextResource trResource = (TextResource)resource;
                    using (StreamReader sr = File.OpenText(trResource.Uri.LocalPath))
                    {
                        sb.AppendLine("\t<p class=\"text\">" + Common.HtmlEncode(sr.ReadToEnd()) + "</p>");
                    }
                    break;

            }
        }
Exemple #2
0
        void AddResource(AbstractResource resource)
        {
            switch (resource.Type)
            {
                case ResourceType.Audio:
                    audios.Add((AudioResource)resource);
                    break;

                case ResourceType.Image:
                    images.Add((ImageResource)resource);
                    break;

                default:

                case ResourceType.Text:
                    texts.Add((TextResource)resource);
                    break;
            }
        }