コード例 #1
0
        static void CreateThemes(string sourcePath, string version, string outputPath)
        {
            Directory.CreateDirectory(outputPath);

            var lessCache = new CompiledLessCache(sourcePath);

            lessCache.Inflate(PersistentCache.Instance);

            foreach (var distributionName in LessRegistry.CssDistributions.Keys)
            {
                var aggregate = LessAggregation.EnumerateAllItems(sourcePath, distributionName);
                foreach (var item in aggregate)
                {
                    using (var stream = File.Create(Path.Combine(outputPath, item.CssFile.GetFileName())))
                        using (var writer = new StreamWriter(stream))
                        {
                            writer.WriteLine(LicenseHeaderHelper.FormatForCssDistribution(distributionName, version));

                            foreach (var segment in item.Segments)
                            {
                                writer.WriteLine(lessCache.GetCssForSegment(segment.Key));
                            }
                        }
                }
            }

            CopyFonts(sourcePath, outputPath, "icons");
            CopyFonts(sourcePath, outputPath, "fonts");
        }
コード例 #2
0
        static void CreateThemes(string sourcePath, string version, string outputPath)
        {
            Directory.CreateDirectory(outputPath);

            var lessCache = new CompiledLessCache(sourcePath);

            lessCache.Inflate(PersistentCache.Instance);

            foreach (var distributionName in LessRegistry.CssDistributions.Keys)
            {
                var aggregate = LessAggregation.EnumerateAllItems(sourcePath, distributionName);
                foreach (var item in aggregate)
                {
                    using (var stream = File.Create(Path.Combine(outputPath, item.CssFile.GetFileName())))
                        using (var writer = new StreamWriter(stream))
                        {
                            writer.WriteLine(LicenseHeaderHelper.FormatForCssDistribution(distributionName, version));

                            foreach (var segment in item.Segments)
                            {
                                writer.WriteLine(lessCache.GetCssForSegment(segment.Key));
                            }
                        }
                }
            }

            var iconsSrcFolder  = LessRegistry.GetIconsPath(sourcePath);
            var iconsDestFolder = Path.Combine(outputPath, "icons");

            Directory.GetFiles(iconsSrcFolder, "*.*", SearchOption.AllDirectories).ToList()
            .ForEach(fileName =>
            {
                string relativePath = fileName.Remove(0, iconsSrcFolder.Length);
                string destFileName = iconsDestFolder + relativePath;
                if (!Directory.Exists(Path.GetDirectoryName(destFileName)))
                {
                    Directory.CreateDirectory(Path.GetDirectoryName(destFileName));
                }

                File.Copy(fileName, destFileName, true);
            });
        }