TransformText() публичный Метод

public TransformText ( ) : string
Результат string
Пример #1
0
        static void CreateAssembly(PackageInfo package)
        {
            // Save the snk file from the embedded resource to the disk so we can use it when we compile
            using (var resStream = typeof(Program).Assembly.GetManifestResourceStream("GenerateTestPackages." + keyFileName)) {
                using (var snkStream = File.Create(keyFileName)) {
                    resStream.CopyTo(snkStream);
                }
            }


            var codeProvider   = new CSharpCodeProvider();
            var compilerParams = new CompilerParameters()
            {
                OutputAssembly  = Path.GetFullPath(GetAssemblyFullPath(package.FullName)),
                CompilerOptions = "/keyfile:" + keyFileName
            };

            // Add all the dependencies as referenced assemblies
            foreach (DependencyInfo dependency in package.Dependencies)
            {
                compilerParams.ReferencedAssemblies.Add(GetAssemblyFullPath(dependency.FullName));
            }

            // Create the source code and compile it using CodeDom
            var generator = new AssemblySourceFileGenerator()
            {
                Package = package
            };
            CompilerResults results = codeProvider.CompileAssemblyFromSource(compilerParams, generator.TransformText());

            if (results.Errors.HasErrors)
            {
                Console.WriteLine(results.Errors[0]);
            }

            File.Delete(keyFileName);
        }
Пример #2
0
        static void CreateAssembly(PackageInfo package, string outputPath = null)
        {

            // Save the snk file from the embedded resource to the disk so we can use it when we compile
            using (var resStream = typeof(Program).Assembly.GetManifestResourceStream("GenerateTestPackages." + keyFileName))
            {
                using (var snkStream = File.Create(keyFileName))
                {
                    resStream.CopyTo(snkStream);
                }
            }


            var codeProvider = new CSharpCodeProvider();
            var compilerParams = new CompilerParameters()
            {
                OutputAssembly = outputPath ?? Path.GetFullPath(GetAssemblyFullPath(package.FullName)),
                CompilerOptions = "/keyfile:" + keyFileName
            };

            // Add all the dependencies as referenced assemblies
            foreach (DependencyInfo dependency in package.Dependencies)
            {
                compilerParams.ReferencedAssemblies.Add(GetAssemblyFullPath(dependency.FullName));
            }

            // Create the source code and compile it using CodeDom
            var generator = new AssemblySourceFileGenerator() { Package = package };
            CompilerResults results = codeProvider.CompileAssemblyFromSource(compilerParams, generator.TransformText());

            if (results.Errors.HasErrors)
            {
                Console.WriteLine(results.Errors[0]);
            }

            File.Delete(keyFileName);
        }