Exemplo n.º 1
0
        public static ResourceDatabase PrepareResources(
            BuildContext buildContext,
            ByteBuffer nullableByteCode) // CBX files will not have this in the resources
        {
            using (new PerformanceSection("Program.PrepareResources"))
            {
                // This really needs to go in a separate helper file.
                ResourceDatabase resourceDatabase = ResourceDatabaseBuilder.CreateResourceDatabase(buildContext);
                if (nullableByteCode != null)
                {
                    resourceDatabase.ByteCodeFile = new FileOutput()
                    {
                        Type        = FileOutputType.Text,
                        TextContent = ByteCodeEncoder.Encode(nullableByteCode),
                    };
                }

                using (new PerformanceSection("Program.PrepareResources/ImageSheetStuff"))
                {
                    Common.ImageSheets.ImageSheetBuilder imageSheetBuilder = new Common.ImageSheets.ImageSheetBuilder();
                    if (buildContext.TopLevelAssembly.ImageSheetIds != null)
                    {
                        foreach (string imageSheetId in buildContext.TopLevelAssembly.ImageSheetIds)
                        {
                            imageSheetBuilder.PrefixMatcher.RegisterId(imageSheetId);

                            foreach (string fileMatcher in buildContext.TopLevelAssembly.ImageSheetPrefixesById[imageSheetId])
                            {
                                imageSheetBuilder.PrefixMatcher.RegisterPrefix(imageSheetId, fileMatcher);
                            }
                        }
                    }
                    Common.ImageSheets.Sheet[] imageSheets = imageSheetBuilder.Generate(resourceDatabase);

                    resourceDatabase.AddImageSheets(imageSheets);
                }

                resourceDatabase.GenerateResourceMapping();

                return(resourceDatabase);
            }
        }