Exemple #1
0
 public override void Write(FileTemplate file, IOutput output)
 {
     if (file is ForwardFileTemplate forwardFile)
     {
         forwardFile.Language.Write(forwardFile.File, output);
     }
     else
     {
         throw new NotImplementedException($"The method {nameof(Write)} for type {file.GetType().Name} is not implemented in {this.Name}.");
     }
 }
        public override void Write(FileTemplate fileTemplate, IOutput output)
        {
            if (string.IsNullOrEmpty(fileTemplate.Name))
            {
                Logger.Trace("Empty file skipped");
                return;
            }
            if (fileTemplate.Header.Description != null)
            {
                AssemblyName assemblyName = (Assembly.GetEntryAssembly() ?? Assembly.GetCallingAssembly()).GetName();
                fileTemplate.Header.Description = string.Format(fileTemplate.Header.Description, $"{assemblyName.Name} {assemblyName.Version}");
            }
            StaticFileTemplate staticFile = fileTemplate as StaticFileTemplate;

            if (staticFile == null)
            {
                throw new NotImplementedException($"The method {nameof(Write)} for type {fileTemplate.GetType().Name} is not implemented in {this.Name}.");
            }

            FileWriter fileWriter = new FileWriter(this);

            fileWriter.Add(fileTemplate.Header)
            .BreakLine()
            .Add(staticFile.Content, true);

            string fileName = FileSystem.Combine(fileTemplate.RelativePath, fileTemplate.Name);

            output.Write(fileName, fileWriter.ToString());
        }
 public virtual void Write(FileTemplate file, IOutput output)
 {
     throw new NotImplementedException($"The method {nameof(Write)} for type {file.GetType().Name} is not implemented in {this.Name}.");
 }