Skip to content

LiteHtmlSharp.Wpf example broken? #394

@KoliadaES-Release

Description

@KoliadaES-Release

DL code (as zip) -> does not dl litehtml folder content.

After correcting this and using Example.WPF, example builds but throws exception trying to find embedded resource "master.css" in LiteHtmlSharp.Wpf.IncludedMasterCss.GetMasterCssResource().

It was unclear if the resource was supposed to be in LiteHtmlSharp.Wpf (which it is not), LiteHtmlSharp (which it is) or both.

I hacked it to read the file directly and the WPF example worked (nicely)!

A 'cleaner' hack is;

namespace LiteHtmlSharp.Wpf
    {
    public static class IncludedMasterCss
        {
        public static string CssString => _includedMasterCss.Value;

        static Lazy<string> _includedMasterCss = new Lazy<string>(GetMasterCssResource);

        static string GetMasterCssResource()
            {
#if gtrm
            var assembly = Assembly.GetExecutingAssembly();
            var masterCssResourceName = assembly.GetManifes‌​tResourceNames().FirstOrDefault(s => s.Contains("master.css"));
            using (var reader = new StreamReader(assembly.GetManifestResourceStream(masterCssResourceName), Encoding.UTF8))
                {
                return reader.ReadToEnd();
                }
#else
            return LiteHtmlSharp.IncludedMasterCss.CssString;
#endif
            }
        }
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions