Ejemplo n.º 1
0
        public SwatchesProvider(Assembly assembly)
        {
            var resourcesName     = assembly.GetName().Name + ".g";
            var manager           = new ResourceManager(resourcesName, assembly);
            var resourceSet       = manager.GetResourceSet(CultureInfo.CurrentUICulture, true, true);
            var dictionaryEntries = resourceSet.OfType <DictionaryEntry>().ToList();
            var assemblyName      = assembly.GetName().Name;

            var regex = new Regex(@"instat\/colors\/(?<fileName>[a-z]+).baml$");

            IGrouping <string, SelBaml>[] groupRes = dictionaryEntries
                                                     .Select(x => new SelBaml {
                key = x.Key.ToString(), match = regex.Match(x.Key.ToString())
            })
                                                     .Where(x => x.match.Success)
                                                     .GroupBy(x => x.match.Groups["fileName"].Value).ToArray();

            Swatch classicColors = GetClassicColorsList(groupRes, assemblyName);

            Swatches = GetSwatches(classicColors, groupRes, assemblyName);
        }