Exemplo n.º 1
0
        static void Main(string[] args)
        {
            try
            {
                Configuration = new ProgramConfiguration(args);
                Configuration.ParseArgs();

                if (Configuration.SelectedTargets.Count == 0)
                {
                    Configuration.ShowHelpAndExit();
                }

                foreach (var t in Configuration.SelectedTargets)
                {
                    var ctor   = t.Key.GetConstructor(new Type[] { });
                    var obj    = ctor.Invoke(new object[] { });
                    var target = obj as Target;

                    string outputFilepath;
                    if (string.IsNullOrEmpty(t.Value))
                    {
                        outputFilepath = Path.GetFullPath(Path.Combine(Configuration.OutputDir, target.Filename));
                    }
                    else
                    {
                        outputFilepath = Path.GetFullPath(t.Value);
                    }

                    using (var outFile = new StreamWriter(outputFilepath))
                    {
                        System.Console.WriteLine("Generating {0}...".Formatted(outputFilepath));

                        target.AddMetadata("Generator class: {0}".Formatted(t.Key.FullName));
                        target.AddMetadata("Output File: {0}".Formatted(outputFilepath));

                        target.Generate(outFile);
                    }
                }

                //Generate(args);
            }
            catch (Exception e)
            {
                Console.WriteLine("ERROR: {0}", e);
            }
        }
Exemplo n.º 2
0
    static void Main(string[] args)
    {
      try
      {
        Configuration = new ProgramConfiguration(args);
        Configuration.ParseArgs();

        if (Configuration.SelectedTargets.Count == 0)
          Configuration.ShowHelpAndExit();

        foreach (var t in Configuration.SelectedTargets)
        {
          var ctor = t.Key.GetConstructor(new Type[] { });
          var obj = ctor.Invoke(new object[] { });
          var target = obj as Target;

          string outputFilepath;
          if (string.IsNullOrEmpty(t.Value))
            outputFilepath = Path.GetFullPath(Path.Combine(Configuration.OutputDir, target.Filename));
          else
            outputFilepath = Path.GetFullPath(t.Value);

          using (var outFile = new StreamWriter(outputFilepath))
          {
            System.Console.WriteLine("Generating {0}...".Formatted(outputFilepath));

            target.AddMetadata("Generator class: {0}".Formatted(t.Key.FullName));
            target.AddMetadata("Output File: {0}".Formatted(outputFilepath));

            target.Generate(outFile);
          }
        }

        //Generate(args);
      }
      catch (Exception e)
      {
        Console.WriteLine("ERROR: {0}", e);
      }
    }