本文整理汇总了C#中Model.Run方法的典型用法代码示例。如果您正苦于以下问题:C# Model.Run方法的具体用法?C# Model.Run怎么用?C# Model.Run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Model
的用法示例。
在下文中一共展示了Model.Run方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
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.Dataset plugIns = new PlugIns.Dataset(Path.Combine(appDir, "plug-ins.xml"));
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;
}
}
示例2: Main
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;
}
}
示例3: Main
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();
ConsoleInterface ci = new ConsoleInterface();
ci.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);
ci.WriteLine("LANDIS-II {0}{1}", version, release);
Assembly assembly = Assembly.GetExecutingAssembly();
foreach (object attribute in assembly.GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false))
ci.WriteLine(((AssemblyCopyrightAttribute) attribute).Copyright);
ci.WriteLine();
if (args.Length == 0) {
ci.WriteLine("Error: No scenario file specified.");
return 1;
}
if (args.Length > 1) {
ci.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]);
ci.WriteLine(argsList.ToString());
return 1;
}
//Warn if user's computer is not using United States number format
string decimal_separator = System.Globalization.CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator;
string period = ".";
if (decimal_separator != period)
{
ci.WriteLine("Warning: The decimal separator of your system is '" + decimal_separator + "'. Most LANDIS-II");
ci.WriteLine("Warning: scenario files use '" + period + "' for the decimal separator. The scenario");
ci.WriteLine("Warning: files may not run or your results could be inaccurate.");
ci.WriteLine();
}
IExtensionDataset extensions = Landis.Extensions.Dataset.LoadOrCreate();
//Pre-pending the GDAL directory is required to run the Console in debug mode
//string path = Environment.GetEnvironmentVariable("PATH");
//string newPath = "C:\\Program Files\\LANDIS-II\\GDAL\\1.9;" + path;
//Environment.SetEnvironmentVariable("PATH", newPath);
RasterFactory rasterFactory = new RasterFactory();
LandscapeFactory landscapeFactory = new LandscapeFactory();
Model model = new Model(extensions, rasterFactory, landscapeFactory);
model.Run(args[0], ci);
return 0;
}
catch (ApplicationException exc) {
ConsoleInterface ci = new ConsoleInterface();
ci.WriteLine(exc.Message);
return 1;
}
catch (Exception exc) {
ConsoleInterface ci = new ConsoleInterface();
ci.WriteLine("Internal error occurred within the program:");
ci.WriteLine(" {0}", exc.Message);
if (exc.InnerException != null) {
ci.WriteLine(" {0}", exc.InnerException.Message);
}
ci.WriteLine();
ci.WriteLine("Stack trace:");
ci.WriteLine(exc.StackTrace);
return 1;
}
}