Пример #1
0
        private void AddNewGenericThemesXaml(
            ResourceWriter resourceWriter, IEnumerable <string> genericThemeResources)
        {
            _logger.Info("Creating new themes/generic.xaml");
            var newBamlDocument = _bamlGenerator.GenerateThemesGenericXaml(genericThemeResources);

            resourceWriter.AddResourceData(
                GenericThemesBamlName, "ResourceTypeCode.Stream",
                BamlUtils.ToResourceBytes(newBamlDocument));
        }
Пример #2
0
        private void PatchExistingGenericThemesXaml(
            ResourceWriter resourceWriter, BamlDocument bamlDocument, IEnumerable <string> genericThemeResources)
        {
            _logger.Info("Patching existing themes/generic.xaml");

            _bamlGenerator.AddMergedDictionaries(bamlDocument, genericThemeResources);

            SetPreserializedData(resourceWriter, GenericThemesBamlName,
                                 BamlUtils.ToResourceBytes(bamlDocument));
        }
Пример #3
0
        private byte[] GetProcessedResource(Res resource, AssemblyDefinition containingAssembly)
        {
            BamlDocument bamlDocument = BamlUtils.FromResourceBytes(resource.data);

            foreach (dynamic node in bamlDocument)
            {
                ProcessRecord(node, containingAssembly);
            }

            //TODO: diminishing return optimisation: remove duplications + update assembly ids

            return(BamlUtils.ToResourceBytes(bamlDocument));
        }
Пример #4
0
        private byte[] GetProcessedResource(Res resource, AssemblyDefinition containingAssembly)
        {
            BamlDocument bamlDocument = BamlUtils.FromResourceBytes(resource.data);

            foreach (BamlRecord node in bamlDocument)
            {
                ProcessRecord(node as PropertyWithConverterRecord, containingAssembly);
                ProcessRecord(node as TextWithConverterRecord, containingAssembly);
                ProcessRecord(node as AssemblyInfoRecord, containingAssembly);
                ProcessRecord(node as XmlnsPropertyRecord, containingAssembly);
                ProcessRecord(node as TypeInfoRecord, containingAssembly);
            }

            //TODO: diminishing return optimisation: remove duplications + update assembly ids

            return(BamlUtils.ToResourceBytes(bamlDocument));
        }
Пример #5
0
        private byte[] GetProcessedResource(Res resource, AssemblyDefinition containingAssembly)
        {
            BamlDocument bamlDocument = BamlUtils.FromResourceBytes(resource.data);

            foreach (BamlRecord node in bamlDocument)
            {
                Action <BamlRecord, AssemblyDefinition> recordProcessor;

                if (_nodeProcessors.TryGetValue(node.GetType(), out recordProcessor))
                {
                    recordProcessor(node, containingAssembly);
                }
            }

            //TODO: diminishing return optimisation: remove duplications + update assembly ids

            return(BamlUtils.ToResourceBytes(bamlDocument));
        }
Пример #6
0
        private void PatchGenericThemesBaml(ResourceWriter resourceWriter)
        {
            byte[] existingGenericBaml;

            var genericThemeResources = _bamlStreams
                                        .Where(e => e.Key.name.EndsWith(GenericThemesBamlName, StringComparison.OrdinalIgnoreCase))
                                        .Select(e => GetResourceName(e.Key, e.Value).Replace(".baml", ".xaml"));

            if (!TryGetPreserializedData(resourceWriter, GenericThemesBamlName, out existingGenericBaml))
            {
                AddNewGenericThemesXaml(resourceWriter, genericThemeResources);
            }
            else
            {
                PatchExistingGenericThemesXaml(
                    resourceWriter, BamlUtils.FromResourceBytes(existingGenericBaml), genericThemeResources);
            }
        }