WriteLine() public static method

Writes the line.
public static WriteLine ( string message ) : void
message string The message.
return void
Exemplo n.º 1
0
        /// <summary>
        /// Activates this instance.
        /// </summary>
        /// <param name="objectName">Name of the object.</param>
        /// <returns>An instance of Visual Studio.</returns>
        public static DTE2 Activate(string objectName)
        {
            DTE2 dte2;

            try
            {
                TraceService.WriteLine("VSActivatorService::Activate " + objectName);
                dte2 = (DTE2)System.Runtime.InteropServices.Marshal.GetActiveObject(objectName);
            }
            catch (Exception exception)
            {
                TraceService.WriteError(exception.Message);

                TraceService.WriteLine("VSActivatorService::Activate " + ScorchioConstants.VisualStudio);
                dte2 = (DTE2)System.Runtime.InteropServices.Marshal.GetActiveObject(ScorchioConstants.VisualStudio);
            }

            TraceService.WriteLine("VSActivatorService::Activate Register");
            MessageFilterService.Register();

            TraceService.WriteLine("VSActivatorService::Activate Activate");
            dte2.Activate();

            return(dte2);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Transforms the specified source file.
        /// </summary>
        /// <param name="textTransformationRequest">The text transformation request.</param>
        /// <returns>The Text Transformation.</returns>
        public TextTransformation Transform(TextTransformationRequest textTransformationRequest)
        {
            TraceService.WriteLine("TextTransformationService::Transform sourceFile=" + textTransformationRequest.SourceFile);

            string sourceText = this.GetText(textTransformationRequest.SourceFile);

            TraceService.WriteDebugLine("sourceText=" + sourceText);

            SimpleTextTemplatingEngine engine = new SimpleTextTemplatingEngine();

            TraceService.WriteLine("Before processing template via SimpleTextTemplatingEngine");

            TextTransformation textTransformation = engine.ProcessTemplate(
                sourceText,
                textTransformationRequest.Parameters,
                textTransformationRequest.RemoveFileHeaders,
                textTransformationRequest.RemoveXmlComments,
                textTransformationRequest.RemoveThisPointer);

            TraceService.WriteLine("After processing template via SimpleTextTemplatingEngine = SUCCESS!");

            TraceService.WriteDebugLine("output=" + textTransformation.Output);

            return(textTransformation);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Gets the text.
        /// </summary>
        /// <param name="sourceFile">The source file.</param>
        /// <returns>The text of the source file.</returns>
        internal string GetText(string sourceFile)
        {
            if (this.cache.Files.ContainsKey(sourceFile))
            {
                string cachedFile = this.cache.Files[sourceFile];

                TraceService.WriteLine("Using cached version of " + sourceFile);
                return(cachedFile);
            }

            if (sourceFile.Contains("http") == false)
            {
                return(File.ReadAllText(sourceFile));
            }

            WebClient client = new WebClient();
            Stream    stream = client.OpenRead(sourceFile);

            if (stream != null)
            {
                StreamReader reader = new StreamReader(stream);
                return(reader.ReadToEnd());
            }

            return(string.Empty);
        }
        /// <summary>
        /// Sets the global variable.
        /// </summary>
        /// <param name="key">The key.</param>
        /// <param name="value">The value.</param>
        public void SetGlobalVariable(
            string key,
            object value)
        {
            TraceService.WriteLine("****SetGlobalVariable " + key + "=" + value);

            this.solution.Globals[key] = value;
        }
Exemplo n.º 5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TextTransformationService" /> class.
        /// </summary>
        public TextTransformationService()
        {
            TraceService.WriteLine("TextTransformationService::Constructor");

            this.cache = new T4Cache();

            TraceService.WriteLine("TextTransformationService::Constructor END");
        }
        /// <summary>
        /// Adds the item.
        /// </summary>
        /// <param name="solutionFolder">The solution folder.</param>
        /// <param name="path">The path.</param>
        public void AddSolutionItem(
            string solutionFolder,
            string path)
        {
            TraceService.WriteLine("****AddSolutionItem");

            this.solution2.AddSolutionItem(solutionFolder, path);
        }
        /// <summary>
        /// Creates the empty solution.
        /// </summary>
        /// <param name="solutionPath">The solution path.</param>
        /// <param name="solutionName">Name of the solution.</param>
        public void CreateEmptySolution(
            string solutionPath,
            string solutionName)
        {
            TraceService.WriteLine("SolutionService::CreateEmptySolution");

            this.solution2.CreateEmptySolution(solutionPath, solutionName);
        }
        /// <summary>
        /// Removes the global variables.
        /// </summary>
        public void RemoveGlobalVariables()
        {
            TraceService.WriteLine("****RemoveGlobalVariables");

            if (this.HasGlobals)
            {
                foreach (string variable in (Array)this.solution.Globals.VariableNames)
                {
                    this.solution.Globals[variable] = null;
                }
            }
        }
        /// <summary>
        /// Gets the global variables.
        /// </summary>
        /// <returns>The global variables.</returns>
        public Dictionary <string, string> GetGlobalVariables()
        {
            TraceService.WriteLine("GetGlobalVariables");

            Dictionary <string, string> dictionary = new Dictionary <string, string>();

            foreach (string variable in (Array)this.solution.Globals.VariableNames)
            {
                string value = this.solution.Globals[variable];

                dictionary.Add(variable, value);
            }

            return(dictionary);
        }
        /// <summary>
        /// Activates this instance.
        /// </summary>
        /// <returns>An instance of Visual Studio.</returns>
        public static DTE2 Activate()
        {
            DTE2 dte2;

            try
            {
                TraceService.WriteLine("VSActivatorService::Activate " + ObjectName);
                dte2 = (DTE2)System.Runtime.InteropServices.Marshal.GetActiveObject(ObjectName);
            }
            catch (Exception)
            {
                TraceService.WriteLine("VSActivatorService::Activate " + ObjectName2);
                dte2 = (DTE2)System.Runtime.InteropServices.Marshal.GetActiveObject(ObjectName2);
            }

            TraceService.WriteLine("VSActivatorService::Activate Register");
            MessageFilterService.Register();

            TraceService.WriteLine("VSActivatorService::Activate Activate");
            dte2.Activate();

            return(dte2);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Processes the template.
        /// </summary>
        /// <param name="sourceText">The source text.</param>
        /// <param name="parameters">The parameters.</param>
        /// <param name="removeFileHeaders">if set to <c>true</c> [remove file headers].</param>
        /// <param name="removeXmlComments">if set to <c>true</c> [remove XML comments].</param>
        /// <param name="removeThisPointer">if set to <c>true</c> [remove this pointer].</param>
        /// <returns></returns>
        public TextTransformation ProcessTemplate(
            string sourceText,
            IDictionary <string, string> parameters,
            bool removeFileHeaders,
            bool removeXmlComments,
            bool removeThisPointer)
        {
            TraceService.WriteLine("SimpleTextTemplatingEngine::ProcessTemplate");

            TextTransformation textTransformation = new TextTransformation();

            //// first remove the this pointer if required

            if (removeThisPointer)
            {
                sourceText = sourceText.Replace("this.", string.Empty);
            }

            //// now remove all the parameter definitions!

            string[] lines = sourceText.Split('\n');

            //// by default make it a standard csharp source file!

            textTransformation.FileExtension = "cs";

            string extensionLine = lines.FirstOrDefault(x => x.StartsWith("<#@ Output Extension="));

            if (string.IsNullOrEmpty(extensionLine) == false)
            {
                ///// <#@ Output Extension="cs" #>

                string[] parts = extensionLine.Split('"');

                if (parts.Length > 1)
                {
                    textTransformation.FileExtension = parts[1];
                }
            }

            IEnumerable <string> newLines = lines.Where(x => x.StartsWith("<#@ ") == false);

            if (removeFileHeaders)
            {
                newLines = newLines.Where(x => x.TrimStart().StartsWith("//") == false);
            }

            if (removeXmlComments)
            {
                newLines = newLines.Where(x => x.TrimStart().StartsWith("///") == false);
            }

            string output = string.Empty;

            foreach (string newLine in newLines)
            {
                output += newLine + "\n";
            }

            if (parameters != null)
            {
                foreach (KeyValuePair <string, string> parameter in parameters)
                {
                    string t4Parameter = $"<#= {parameter.Key} #>";

                    output = output.Replace(t4Parameter, parameter.Value);
                }
            }

            //// sort out single LF and replace with CR LF!
            textTransformation.Output = Regex.Replace(output, @"\r\n|\r|\n", "\r\n");

            return(textTransformation);
        }
        /// <summary>
        /// Gets the global variable.
        /// </summary>
        /// <param name="key">The key.</param>
        /// <returns>The global variable.</returns>
        public object GetGlobalVariable(string key)
        {
            TraceService.WriteLine("GetGlobalVariable key =" + key);

            return(this.solution.Globals[key]);
        }
        /// <summary>
        /// Globals the variable exists.
        /// </summary>
        /// <param name="key">The key.</param>
        /// <returns>True or false.</returns>
        public bool GlobalVariableExists(string key)
        {
            TraceService.WriteLine("GlobalVariableExists key =" + key);

            return(this.solution.Globals.VariableExists[key]);
        }