Ejemplo n.º 1
0
        /// <summary>
        /// Create
        /// </summary>
        /// <param name="pv">printer version</param>
        /// <returns>printer object</returns>
        public static PrinterObject Create(PrinterVersion pv)
        {
            PrinterObject po = new PrinterObject(Path.GetDirectoryName(pv.FullName), pv.LatestVersion);

            PrinterObject.Save(po, pv.FullName);
            return(po);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Add a new version
 /// </summary>
 /// <param name="po">printer object</param>
 public void AddVersion(PrinterObject po)
 {
     if (this.currentMinorVersion == 0 && this.currentMajorVersion == 1)
     {
         PrinterObject.Save(po, Path.Combine(this.path, String.Format("{0}.prt", this.fileName)));
     }
     else
     {
         PrinterObject.Save(po, Path.Combine(this.path, String.Format("{0}-{1}.prt", this.fileName, this.LatestVersion)));
     }
     if (this.currentMinorVersion == 9)
     {
         this.currentMinorVersion = 0;
         ++this.currentMajorVersion;
     }
     else
     {
         ++this.currentMinorVersion;
     }
 }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            try
            {
                if (args.Length == 0)
                {
                    throw new ArgumentException("USAGE : printer file.prt");
                }
                PrinterObject po = null;
                FileInfo      fi = new FileInfo(args[0]);
                if (fi.Exists)
                {
                    po = PrinterObject.Load(args[0]);
                }
                else
                {
                    po = PrinterObject.Create(new PrinterVersion(Path.GetDirectoryName(args[0]), Path.GetFileName(args[0])));
                    po.AddData(@"using System;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;

namespace ");
                    po.AddData("[Printer]");
                    po.AddData(@"
{
    class ");
                    po.AddData("[Program]");
                    po.AddData(@"
    {
        static void Main(string[] args)
        {
            //");

                    PrinterVariable pv = new PrinterVariable();
                    pv.Name    = "condition";
                    pv.Include = true;
                    pv.Indent  = true;
                    pv.AddVariable("expression", "true");
                    pv.AddVariable("then", "code");
                    pv.AddVariable("else", "code");
                    pv.Value = "C/if.prt";

                    po.AddVariable("condition", pv);

                    po.UseVariable("condition");
                    po.AddData(@"
        }
    }
}
");
                }


                Console.WriteLine(po.Execute());

                Console.WriteLine("code:");
                Console.WriteLine(po.ToString());

                PrinterObject.Save(po, args[0]);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                Console.WriteLine("Touch your keyboard");
                Console.ReadKey();
            }
        }