Adapted from the StylesExplorer project on codeplex. The original class is able to fully parse the BAML. This class is reduced to read the root element to identify whether it is a ResourceDictionary or not. That way we can skip instantiating things that we shouldn't instantiate.
Exemple #1
0
        private IEnumerable <string> GetRawResourceNames()
        {
            var asm     = _assembly;
            var resName = asm.GetName().Name + ".g.resources";

            using (var stream = asm.GetManifestResourceStream(resName))
            {
                if (stream == null)
                {
                    yield break;
                }

                using (var reader = new System.Resources.ResourceReader(stream))
                {
                    foreach (DictionaryEntry entry in reader)
                    {
                        var rawResourceName = (string)entry.Key;
                        if (HasImageExtension(rawResourceName))
                        {
                            continue;
                        }
                        var binReader = new BamlBinaryReader((Stream)entry.Value);
                        var r         = new BamlRootElementCheck(binReader);
                        var element   = r.RootElement();
                        if (element == "ResourceDictionary")
                        {
                            yield return(rawResourceName);
                        }
                    }
                }
            }
        }
Exemple #2
0
        private IEnumerable<string> GetRawResourceNames()
        {
            var asm = _assembly;
            var resName = asm.GetName().Name + ".g.resources";
            using (var stream = asm.GetManifestResourceStream(resName))
            {
                if (stream == null)
                    yield break;

                using (var reader = new System.Resources.ResourceReader(stream))
                {
                    foreach (DictionaryEntry entry in reader)
                    {
                        var rawResourceName = (string) entry.Key;
                        if (HasImageExtension(rawResourceName)) continue;
                        var binReader = new BamlBinaryReader((Stream) entry.Value);
                        var r = new BamlRootElementCheck(binReader);
                        var element = r.RootElement();
                        if (element == "ResourceDictionary")
                          yield return rawResourceName;
                    }
                }
            }
        }