Click here to Skip to main content
15,896,154 members
Articles / Programming Languages / XML

netTierGenerator

Rate me:
Please Sign up or sign in to vote.
4.81/5 (20 votes)
30 Nov 2008CPOL14 min read 67.7K   2.8K   108  
A 3-tier application framework and code generation tool - the way for rapid and effective development.
using System;
using System.Collections.Generic;
using System.Text;
using TierGenerator.Common.Util.Generate;
using TierGenerator.Common.Util.Settings;
using System.IO;

namespace Console
{
    class Program
    {
        private const string TIER_GENERATOR_SETTINGS_FILE_NAME = "TierGeneratorSettings.xml";

        private static string TierGeneratorSettingsPath
        {
            get
            {
                return AppDomain.CurrentDomain.SetupInformation.ApplicationBase + TIER_GENERATOR_SETTINGS_FILE_NAME;
            }
        }

        static void Main(string[] args)
        {
            Environment.ExitCode = -1;

            System.Console.WriteLine(String.Format("TierGenerator v.{0}", System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString()));
            if (args.Length < 1)
            {
                System.Console.WriteLine("Need xml model file!");
                return;
            }

            string path = String.Empty;
            path = args[0];
            System.Console.WriteLine(string.Format("Using tier model file {0}", path));

            bool isDebug = false;
            if (args.Length > 1 && args[1].Equals("yes"))
            {
                isDebug = true;
            }

            if (!File.Exists(path))
            {
                System.Console.WriteLine("Can not find document file!");
                return;
            }

            try
            {
                TierGeneratorSettings settings = TierGeneratorSettingsHelper.LoadSettings(TierGeneratorSettingsPath, AppDomain.CurrentDomain.SetupInformation.ApplicationBase);
                System.Console.WriteLine(String.Concat("DAL Dialect: ", settings.DalDialect));
                settings.IsDebug = isDebug;

                ServiceBuilder serviceBuilder = new ServiceBuilder(settings);
                serviceBuilder.GenerateService(path);

                System.Console.WriteLine("Processed successfully.");
                Environment.ExitCode = 0;
            }
            catch (Exception ex)
            {
                System.Console.WriteLine(
                        String.Format(
                                "Message: {0}\nTargetSite: {1}\nStackTrace: {2}", 
                                ex.Message,
                                ex.TargetSite,
                                ex.StackTrace
                            )
                    );
            }
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions