Esempio n. 1
0
        //---------------------------------------------------------------------

        /// <summary>
        /// Initializes a new instance.
        /// </summary>
        public Model(PlugIns.IDataset plugInDataset,
                     IDriverManager rasterDriverMgr)
        {
            this.plugInDataset   = plugInDataset;
            this.rasterDriverMgr = rasterDriverMgr;
            siteVarRegistry      = new SiteVarRegistry();
        }
Esempio n. 2
0
        public static int Main(string[] args)
        {
            try {
                UI.TextWriter = Console.Out;

                Assembly       assembly       = Assembly.GetExecutingAssembly();
                VersionRelease versionRelease = new VersionRelease(assembly);
                UI.WriteLine("Landis-II {0}", versionRelease);
                UI.WriteLine("Copyright 2004-2005 University of Wisconsin");
                UI.WriteLine();

                if (args.Length == 0)
                {
                    UI.WriteLine("Error: No scenario file specified.");
                    return(1);
                }
                if (args.Length > 1)
                {
                    UI.WriteLine("Error: Extra argument(s) on command line:");
                    StringBuilder argsList = new StringBuilder();
                    argsList.Append(" ");
                    for (int i = 1; i < args.Length; ++i)
                    {
                        argsList.AppendFormat(" {0}", args[i]);
                    }
                    UI.WriteLine(argsList.ToString());
                    return(1);
                }

                string                 appDir    = Application.Directory;
                PlugIns.IDataset       plugIns   = PlugIns.Admin.Dataset.LoadOrCreate(PlugIns.Admin.Dataset.DefaultPath);
                RasterIO.DriverManager driverMgr = new RasterIO.DriverManager(Path.Combine(appDir, "raster-drivers.xml"));
                Model model = new Model(plugIns, driverMgr);
                model.Run(args[0]);
                return(0);
            }
            catch (ApplicationException exc) {
                UI.WriteLine(exc.Message);
                return(1);
            }
            catch (Exception exc) {
                UI.WriteLine("Internal error occurred within the program:");
                UI.WriteLine("  {0}", exc.Message);
                if (exc.InnerException != null)
                {
                    UI.WriteLine("  {0}", exc.InnerException.Message);
                }
                UI.WriteLine();
                UI.WriteLine("Stack trace:");
                UI.WriteLine(exc.StackTrace);
                return(1);
            }
        }
		//---------------------------------------------------------------------

		/// <summary>
		/// Registers a read method for plug-in names with the input values
		/// modules in the FLEL utility library.
		/// </summary>
		/// <param name="installedPlugIns">
		/// The dataset of information about plug-ins installed on the local
		/// machine.  Used by the read method to validate plug-in names.
		/// </param>
		public static void RegisterReadMethod(PlugIns.IDataset installedPlugIns)
		{
		    if (installedPlugIns == null)
		        throw new System.ArgumentNullException();
		    PlugInInfo.installedPlugIns = installedPlugIns;

		    if (! registered) {
				Type.SetDescription<PlugIns.PlugInInfo>("plug-in name");
				InputValues.Register<PlugIns.PlugInInfo>(Read);
				registered = true;
			}
		}
Esempio n. 4
0
        //---------------------------------------------------------------------

        /// <summary>
        /// Registers a read method for plug-in names with the input values
        /// modules in the FLEL utility library.
        /// </summary>
        /// <param name="installedPlugIns">
        /// The dataset of information about plug-ins installed on the local
        /// machine.  Used by the read method to validate plug-in names.
        /// </param>
        public static void RegisterReadMethod(PlugIns.IDataset installedPlugIns)
        {
            if (installedPlugIns == null)
            {
                throw new System.ArgumentNullException();
            }
            PlugInInfo.installedPlugIns = installedPlugIns;

            if (!registered)
            {
                Type.SetDescription <PlugIns.PlugInInfo>("plug-in name");
                InputValues.Register <PlugIns.PlugInInfo>(Read);
                registered = true;
            }
        }
        //---------------------------------------------------------------------

        public ScenarioParser(PlugIns.IDataset installedPlugIns)
        {
            PlugInInfo.RegisterReadMethod(installedPlugIns);
            nameLineNumbers = new Dictionary <string, int>();
        }
Esempio n. 6
0
        public static int Main(string[] args)
        {
            try {
                // The log4net section in the application's configuration file
                // requires the environment variable WORKING_DIR be set to the
                // current working directory.
                Environment.SetEnvironmentVariable("WORKING_DIR", Environment.CurrentDirectory);
                log4net.Config.XmlConfigurator.Configure();

                UI.TextWriter = Console.Out;

                string version = GetAppSetting("version");
                if (version == "")
                {
                    throw new Exception("The application setting \"version\" is empty or blank");
                }
                string release = GetAppSetting("release");
                if (release != "")
                {
                    release = string.Format(" ({0})", release);
                }
                UI.WriteLine("LANDIS-II {0}{1}", version, release);

                Assembly assembly = Assembly.GetExecutingAssembly();
                foreach (object attribute in assembly.GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false))
                {
                    UI.WriteLine(((AssemblyCopyrightAttribute)attribute).Copyright);
                }
                UI.WriteLine();

                if (args.Length == 0)
                {
                    UI.WriteLine("Error: No scenario file specified.");
                    return(1);
                }
                if (args.Length > 1)
                {
                    UI.WriteLine("Error: Extra argument(s) on command line:");
                    StringBuilder argsList = new StringBuilder();
                    argsList.Append(" ");
                    for (int i = 1; i < args.Length; ++i)
                    {
                        argsList.AppendFormat(" {0}", args[i]);
                    }
                    UI.WriteLine(argsList.ToString());
                    return(1);
                }

                string                 appDir    = Application.Directory;
                PlugIns.IDataset       plugIns   = PlugIns.Admin.Dataset.LoadOrCreate(PlugIns.Admin.Dataset.DefaultPath);
                RasterIO.DriverManager driverMgr = new RasterIO.DriverManager(Path.Combine(appDir, "raster-drivers.xml"));
                Model model = new Model(plugIns, driverMgr);
                model.Run(args[0]);
                return(0);
            }
            catch (ApplicationException exc) {
                UI.WriteLine(exc.Message);
                return(1);
            }
            catch (Exception exc) {
                UI.WriteLine("Internal error occurred within the program:");
                UI.WriteLine("  {0}", exc.Message);
                if (exc.InnerException != null)
                {
                    UI.WriteLine("  {0}", exc.InnerException.Message);
                }
                UI.WriteLine();
                UI.WriteLine("Stack trace:");
                UI.WriteLine(exc.StackTrace);
                return(1);
            }
        }