Пример #1
0
    static public void Main(string[] args)
    {
        try
        {
            if (args.Length != 2 || args[0].ToLower() == "-?" || args[0].ToLower() == "/?")
            {
                Console.WriteLine(usage);
            }
            else
            {
                CSScript.CCSharpParser ccs = new CSScript.CCSharpParser(args[0]);
                if (ccs.isClassless)
                {
                    using (StreamWriter sw = new StreamWriter(args[1]))
                        sw.Write(ccs.CSharpScriptCode);
                }
                else
                {
                    throw new Exception("Error: The file " + args[0] + " content is not recognised as a classless C# code.");
                }

                Console.WriteLine("Conversion successfully completed");
            }
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex);
        }
    }
Пример #2
0
        static void i_Main()
        {
            CCSharpParser ccs = new CCSharpParser(@"C:\cs-script\Dev\CC#\using.ccs");

            if (ccs.isClassless)
            {
                Console.WriteLine("CC#");
                Console.WriteLine(ccs.CSharpCode);
            }
            else
            {
                Console.WriteLine("C#");
            }
        }
Пример #3
0
        public CompilerResults CompileAssemblyFromFileBatch(CompilerParameters options, string[] fileNames)
        {
            string        tempFile;
            ArrayList     classlessFiles = new ArrayList();
            ArrayList     files          = new ArrayList();
            int           count          = 0;
            CCSharpParser ccs;

            foreach (string file in fileNames)
            {
                ccs = new CCSharpParser(file);
                if (!ccs.isClassless)
                {
                    files.Add(file);
                }
                else
                {
                    tempFile = ccs.ToTempFile(count > 0);
                    classlessFiles.Add(tempFile);
                    files.Add(tempFile);
                }
                count++;
            }



            CompilerResults retval;

            retval = (new Microsoft.CSharp.CSharpCodeProvider()).CreateCompiler().CompileAssemblyFromFileBatch(options, (string[])files.ToArray(typeof(string)));


            if (!retval.Errors.HasErrors)
            {
                foreach (string file in classlessFiles)
                {
                    try
                    {
                        File.Delete(file);
                    }
                    catch {}
                }
            }

            return(retval);
        }
Пример #4
0
		public CompilerResults CompileAssemblyFromFileBatch(CompilerParameters options, string[] fileNames)
		{
			string tempFile;
			ArrayList classlessFiles = new ArrayList(); 
			ArrayList files = new ArrayList();
			int count = 0;
			CCSharpParser ccs;
			foreach (string file in fileNames)
			{
				ccs = new CCSharpParser(file);
				if (!ccs.isClassless)
				{
					files.Add(file);
				}
				else
				{
					tempFile = ccs.ToTempFile(count > 0 );
					classlessFiles.Add(tempFile);
					files.Add(tempFile);
				}
				count++;
			}

			
				
			CompilerResults retval;

			retval = (new Microsoft.CSharp.CSharpCodeProvider()).CreateCompiler().CompileAssemblyFromFileBatch(options, (string[])files.ToArray(typeof(string)));
			
			
			if (!retval.Errors.HasErrors)
				foreach (string file in classlessFiles)
					try
					{ 
						File.Delete(file);
					} 
					catch{}

			return retval;
		}
Пример #5
0
    public static void Main(string[] args)
    {
        try
        {
            if (args.Length != 2 || args[0].ToLower() == "-?" || args[0].ToLower() == "/?")
                Console.WriteLine(usage);
            else
            {
                CSScript.CCSharpParser ccs = new CSScript.CCSharpParser(args[0]);
                if (ccs.isClassless)
                    using (StreamWriter sw = new StreamWriter(args[1]))
                        sw.Write(ccs.CSharpScriptCode);
                else
                    throw new Exception("Error: The file "+args[0]+" content is not recognised as a classless C# code.");

                Console.WriteLine("Conversion successfully completed");
            }
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex);
        }
    }
Пример #6
0
		static void i_Main()
		{
			CCSharpParser ccs = new CCSharpParser(@"C:\cs-script\Dev\CC#\using.ccs");
			if (ccs.isClassless)
			{
				Console.WriteLine("CC#");
				Console.WriteLine(ccs.CSharpCode);
			}
			else
				Console.WriteLine("C#");
		}