Esempio n. 1
0
        public void SwitchToFileBlock(string fileName, string blockName)
        {
            EndCurrentBlock();

            // Put current one file block on the stack...
            if (CurrentBlockPart != null)
            {
                PendingBlocks.Push(CurrentBlockPart.Parent);
            }

            // Create object for provided file name
            FileBlocks fileBlocks = new FileBlocks(fileName);

            // If it exists already just use it...
            if (m_FilesDictionary.ContainsKey(fileName))
            {
                fileBlocks = m_FilesDictionary[fileName];
            }
            else
            {
                m_FilesDictionary.Add(fileName, fileBlocks);
                m_OrderedFiles.Add(fileName);
            }

            // Create a holder for a new one piece of the text/code
            CurrentBlockPart = fileBlocks.GetBlock(blockName).GetNewBlockPart();
        }
Esempio n. 2
0
        public FileBlockInfo(FileBlocks parent, string blockName)
        {
            Parent    = parent;
            BlockName = blockName;

            FileBlockParts = new List <FileBlockPart>();
        }
Esempio n. 3
0
        public virtual void GenerateOutput(bool splitIntoMultipleFiles = false, bool sortFileOrder = false, bool sortBlockOrder = false)
        {
            // If we want to leave it as it is then don't process the files
            if (!splitIntoMultipleFiles)
            {
                return;
            }

            // Should we sort generated files?
            if (sortFileOrder)
            {
                m_OrderedFiles.Sort();
            }

            // Reverse files order to insert into project in proper order
            m_OrderedFiles.Reverse();

            // Template file output path
            String outputPath = Path.GetDirectoryName(m_Host.TemplateFile);

            // Generate output for each file
            foreach (string orderedFileName in m_OrderedFiles)
            {
                FileBlocks fileBlocks = m_FilesDictionary[orderedFileName];
                fileBlocks.GenerateOutput(sortBlockOrder);

                // All the files except for default one
                if (orderedFileName != m_DefaultName)
                {
                    String fileName = Path.Combine(outputPath, fileBlocks.FileName);
                    GeneratedFileNames.Add(fileName);
                    CreateFile(fileName, fileBlocks.Output);
                }
            }

            // Leave default output with default file content
            m_Template.Clear();
            m_Template.Append(m_FilesDictionary[m_DefaultName].Output);
        }