Exemplo n.º 1
0
        /// <summary>
        /// Writes the namespace (if it has one) and the class and all braces. This function
        /// will then call WriteNamespaceContent for stuff in that scope and WriteClassContent()
        /// for everything contained in that scope.
        /// </summary>
        public virtual void WriteClassOutline()
        {
            this.Write("//------------------------------------------------------------------------------\r" +
                       "\n// <auto-generated>\r\n// ");

            this.Write(this.ToStringHelper.ToStringWithCulture(Path.GetFileName(m_SaveLocation)));

            this.Write("\r\n// This code was generated by ScriptForge. To rebuild the code go to \r\n// Proje" +
                       "ct Settings ->Script Forge and on that window hit generate all. Any\r\n// changes " +
                       "made to this script will be overwritten.  \r\n// Asset Hash: ");

            this.Write(this.ToStringHelper.ToStringWithCulture(m_AssetHash));

            this.Write("\r\n// </auto-generated>\r\n//-------------------------------------------------------" +
                       "-----------------------\r\n");


            bool hasNamespace = !string.IsNullOrEmpty(m_Namespace);

            if (hasNamespace)
            {
                Write("namespace ");
                WriteLine(m_Namespace);
                WriteLine("{");
                PushIndent(m_Indent);
            }

            WriteNamespaceContent();

            WriteEnumContent();

            {   // Start class
                Write("public ");
                if (m_IsStaticClass)
                {
                    Write("static ");
                }

                if (m_IsPartialClass)
                {
                    Write("partial ");
                }
                Write("class ");
                WriteLine(m_ClassName);
                WriteLine("{");
                PushIndent(m_Indent);
                WriteEnumContent();
                WriteClassContent();
                WriteHelperFunctions();
                PopIndent();
                Write("}");
            } // End Class
            if (hasNamespace)
            {
                PopIndent();
                GenerationEnvironment.AppendLine();
                Write("}");
            }
        }
Exemplo n.º 2
0
 public void WriteLines(IEnumerable <string> strings)
 {
     foreach (var s in strings)
     {
         GenerationEnvironment.Append(currentIndent);
         GenerationEnvironment.AppendLine(s);
     }
 }
 protected void BlankLine(ref bool first)
 {
     if (first)
     {
         first = false;
     }
     else
     {
         GenerationEnvironment.AppendLine();
     }
 }
Exemplo n.º 4
0
        public void Initialize(EnvDTE.DTE dte, ITextTemplatingEngineHost host, string resourceModelFile)
        {
            _host            = host;
            MultiFile        = MultiFileManager.Create(dte, host, GenerationEnvironment);
            MultiFile.Header = $@"// This code is generated by NRestGen v1.0.0.
// Any changes to this file will be overwritten when regenerated.
// Generated at {DateTime.Now}
";

            GenerationEnvironment.AppendLine($"Generated at {DateTime.Now}");

            if (!String.IsNullOrEmpty(MultiFile.Error))
            {
                Error(MultiFile.Error);
            }

            var resourceModelPath = Path.Combine(ProjectFolder, resourceModelFile);

            GenerationEnvironment.AppendLine($"Reading Resource Model: {resourceModelPath}");
            ResourceModel = ResourceObjectModel.FromFile(resourceModelPath);
        }
Exemplo n.º 5
0
 public void WriteLine(string textToAppend = "")
 {
     Write(textToAppend);
     GenerationEnvironment.AppendLine();
     _endWithNewLine = true;
 }
Exemplo n.º 6
0
 public void Process()
 {
     MultiFile.Process(true);
     GenerationEnvironment.AppendLine("Done.");
 }
Exemplo n.º 7
0
 public void WriteLine(string format, params object[] args)
 {
     GenerationEnvironment.Append(currentIndent);
     GenerationEnvironment.AppendFormat(format, args);
     GenerationEnvironment.AppendLine();
 }
Exemplo n.º 8
0
 public void WriteLine(string textToAppend)
 {
     GenerationEnvironment.Append(currentIndent);
     GenerationEnvironment.AppendLine(textToAppend);
 }
Exemplo n.º 9
0
 /// <summary>
 /// Write text directly into the generated output
 /// </summary>
 /// <param name="textToAppend"></param>
 public void WriteLine(string textToAppend)
 {
     Write(textToAppend);
     GenerationEnvironment.AppendLine();
     endsWithNewline = true;
 }