Exemplo n.º 1
0
        public void GenerateAssemblyCodeFromTemplate(AssemblyFacet assemblyFacet)
        {
            string templateFileName = null;

            // Create the template host
            TemplatingEngineHost templateHost = new TemplatingEngineHost();

            templateHost.TemplateFileValue = "Net2ObjC.tt";

            // utilise the runtime template
            N2ObjC               = new Net2ObjC();
            N2ObjC.Host          = templateHost;
            N2ObjC.AssemblyFacet = assemblyFacet;
            N2ObjC.XMLFilePath   = XMLFile;

            // run the template
            LogText = N2ObjC.TransformText();

            bool saveLog = false;

            // save the logOutput if required
            if (saveLog)
            {
                string outputFileName = Path.GetFileNameWithoutExtension(templateFileName);
                outputFileName = Path.Combine(Path.GetDirectoryName(templateFileName), outputFileName);
                outputFileName = outputFileName + "1" + templateHost.FileExtension;
                File.WriteAllText(outputFileName, LogText);
            }

            // format errors
            if (templateHost.Errors != null)
            {
                StringBuilder errors = new StringBuilder();
                foreach (CompilerError error in templateHost.Errors)
                {
                    errors.AppendLine(error.ToString());
                    errors.AppendLine(" ");
                }
                ErrorText = errors.ToString();
            }
        }
Exemplo n.º 2
0
        public void GenerateAssemblyCodeFromTemplate(AssemblyFacet assemblyFacet)
        {
            string templateFileName = null;

            // Create the template host
            TemplatingEngineHost templateHost = new TemplatingEngineHost();
            templateHost.TemplateFileValue = "Net2ObjC.tt";

            // utilise the runtime template
            N2ObjC = new Net2ObjC();
            N2ObjC.Host = templateHost;
            N2ObjC.AssemblyFacet = assemblyFacet;
            N2ObjC.XMLFilePath = XMLFile;

            // run the template
            LogText =  N2ObjC.TransformText();

            bool saveLog = false;

            // save the logOutput if required
            if (saveLog)
            {
                string outputFileName = Path.GetFileNameWithoutExtension(templateFileName);
                outputFileName = Path.Combine(Path.GetDirectoryName(templateFileName), outputFileName);
                outputFileName = outputFileName + "1" + templateHost.FileExtension;
                File.WriteAllText(outputFileName, LogText, templateHost.FileEncoding);
            }

            // format errors
            if (templateHost.Errors != null)
            {
                StringBuilder errors = new StringBuilder();
                foreach (CompilerError error in templateHost.Errors) {
                    errors.AppendLine(error.ToString());
                    errors.AppendLine(" ");
                }
                ErrorText = errors.ToString();
            }
        }