mirror of
https://github.com/opensim/opensim.git
synced 2026-08-05 08:55:56 +08:00
mass update of files to have native line endings
This commit is contained in:
@@ -1,379 +1,379 @@
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Net;
|
||||
|
||||
using libsecondlife;
|
||||
|
||||
using OpenSim.Framework.Console;
|
||||
using OpenSim.Framework.Configuration.Interfaces;
|
||||
|
||||
namespace OpenSim.Framework.Configuration
|
||||
{
|
||||
public class ConfigurationMember
|
||||
{
|
||||
public delegate bool ConfigurationOptionResult(string configuration_key, object configuration_result);
|
||||
public delegate void ConfigurationOptionsLoad();
|
||||
|
||||
private List<ConfigurationOption> configurationOptions = new List<ConfigurationOption>();
|
||||
private string configurationFilename = "";
|
||||
private string configurationDescription = "";
|
||||
|
||||
private ConfigurationOptionsLoad loadFunction;
|
||||
private ConfigurationOptionResult resultFunction;
|
||||
|
||||
private IGenericConfig configurationPlugin = null;
|
||||
/// <summary>
|
||||
/// This is the default configuration DLL loaded
|
||||
/// </summary>
|
||||
private string configurationPluginFilename = "OpenSim.Framework.Configuration.XML.dll";
|
||||
public ConfigurationMember(string configuration_filename, string configuration_description, ConfigurationOptionsLoad load_function, ConfigurationOptionResult result_function)
|
||||
{
|
||||
this.configurationFilename = configuration_filename;
|
||||
this.configurationDescription = configuration_description;
|
||||
this.loadFunction = load_function;
|
||||
this.resultFunction = result_function;
|
||||
}
|
||||
|
||||
public void setConfigurationFilename(string filename)
|
||||
{
|
||||
configurationFilename = filename;
|
||||
}
|
||||
public void setConfigurationDescription(string desc)
|
||||
{
|
||||
configurationDescription = desc;
|
||||
}
|
||||
|
||||
public void setConfigurationResultFunction(ConfigurationOptionResult result)
|
||||
{
|
||||
resultFunction = result;
|
||||
}
|
||||
|
||||
public void forceConfigurationPluginLibrary(string dll_filename)
|
||||
{
|
||||
configurationPluginFilename = dll_filename;
|
||||
}
|
||||
public void addConfigurationOption(string configuration_key, ConfigurationOption.ConfigurationTypes configuration_type, string configuration_question, string configuration_default, bool use_default_no_prompt)
|
||||
{
|
||||
ConfigurationOption configOption = new ConfigurationOption();
|
||||
configOption.configurationKey = configuration_key;
|
||||
configOption.configurationQuestion = configuration_question;
|
||||
configOption.configurationDefault = configuration_default;
|
||||
configOption.configurationType = configuration_type;
|
||||
configOption.configurationUseDefaultNoPrompt = use_default_no_prompt;
|
||||
|
||||
if (configuration_key != "" && configuration_question != "")
|
||||
{
|
||||
if (!configurationOptions.Contains(configOption))
|
||||
{
|
||||
configurationOptions.Add(configOption);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MainLog.Instance.Notice("Required fields for adding a configuration option is invalid. Will not add this option (" + configuration_key + ")");
|
||||
}
|
||||
}
|
||||
|
||||
public void performConfigurationRetrieve()
|
||||
{
|
||||
configurationPlugin = this.LoadConfigDll(configurationPluginFilename);
|
||||
configurationOptions.Clear();
|
||||
if(loadFunction == null)
|
||||
{
|
||||
MainLog.Instance.Error("Load Function for '" + this.configurationDescription + "' is null. Refusing to run configuration.");
|
||||
return;
|
||||
}
|
||||
|
||||
if(resultFunction == null)
|
||||
{
|
||||
MainLog.Instance.Error("Result Function for '" + this.configurationDescription + "' is null. Refusing to run configuration.");
|
||||
return;
|
||||
}
|
||||
|
||||
MainLog.Instance.Verbose("Calling Configuration Load Function...");
|
||||
this.loadFunction();
|
||||
|
||||
if(configurationOptions.Count <= 0)
|
||||
{
|
||||
MainLog.Instance.Error("No configuration options were specified for '" + this.configurationOptions + "'. Refusing to continue configuration.");
|
||||
return;
|
||||
}
|
||||
|
||||
bool useFile = true;
|
||||
if (configurationPlugin == null)
|
||||
{
|
||||
MainLog.Instance.Error("Configuration Plugin NOT LOADED!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (configurationFilename.Trim() != "")
|
||||
{
|
||||
configurationPlugin.SetFileName(configurationFilename);
|
||||
configurationPlugin.LoadData();
|
||||
useFile = true;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
MainLog.Instance.Notice("XML Configuration Filename is not valid; will not save to the file.");
|
||||
useFile = false;
|
||||
}
|
||||
|
||||
foreach (ConfigurationOption configOption in configurationOptions)
|
||||
{
|
||||
bool convertSuccess = false;
|
||||
object return_result = null;
|
||||
string errorMessage = "";
|
||||
bool ignoreNextFromConfig = false;
|
||||
while (convertSuccess == false)
|
||||
{
|
||||
|
||||
string console_result = "";
|
||||
string attribute = null;
|
||||
if (useFile)
|
||||
{
|
||||
if (!ignoreNextFromConfig)
|
||||
{
|
||||
attribute = configurationPlugin.GetAttribute(configOption.configurationKey);
|
||||
}
|
||||
else
|
||||
{
|
||||
ignoreNextFromConfig = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (attribute == null)
|
||||
{
|
||||
if (configOption.configurationUseDefaultNoPrompt)
|
||||
{
|
||||
console_result = configOption.configurationDefault;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if (configurationDescription.Trim() != "")
|
||||
{
|
||||
console_result = MainLog.Instance.CmdPrompt(configurationDescription + ": " + configOption.configurationQuestion, configOption.configurationDefault);
|
||||
}
|
||||
else
|
||||
{
|
||||
console_result = MainLog.Instance.CmdPrompt(configOption.configurationQuestion, configOption.configurationDefault);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
console_result = attribute;
|
||||
}
|
||||
|
||||
switch (configOption.configurationType)
|
||||
{
|
||||
case ConfigurationOption.ConfigurationTypes.TYPE_STRING:
|
||||
return_result = console_result;
|
||||
convertSuccess = true;
|
||||
break;
|
||||
case ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY:
|
||||
if (console_result.Length > 0)
|
||||
{
|
||||
return_result = console_result;
|
||||
convertSuccess = true;
|
||||
}
|
||||
errorMessage = "a string that is not empty";
|
||||
break;
|
||||
case ConfigurationOption.ConfigurationTypes.TYPE_BOOLEAN:
|
||||
bool boolResult;
|
||||
if (Boolean.TryParse(console_result, out boolResult))
|
||||
{
|
||||
convertSuccess = true;
|
||||
return_result = boolResult;
|
||||
}
|
||||
errorMessage = "'true' or 'false' (Boolean)";
|
||||
break;
|
||||
case ConfigurationOption.ConfigurationTypes.TYPE_BYTE:
|
||||
byte byteResult;
|
||||
if (Byte.TryParse(console_result, out byteResult))
|
||||
{
|
||||
convertSuccess = true;
|
||||
return_result = byteResult;
|
||||
}
|
||||
errorMessage = "a byte (Byte)";
|
||||
break;
|
||||
case ConfigurationOption.ConfigurationTypes.TYPE_CHARACTER:
|
||||
char charResult;
|
||||
if (Char.TryParse(console_result, out charResult))
|
||||
{
|
||||
convertSuccess = true;
|
||||
return_result = charResult;
|
||||
}
|
||||
errorMessage = "a character (Char)";
|
||||
break;
|
||||
case ConfigurationOption.ConfigurationTypes.TYPE_INT16:
|
||||
short shortResult;
|
||||
if (Int16.TryParse(console_result, out shortResult))
|
||||
{
|
||||
convertSuccess = true;
|
||||
return_result = shortResult;
|
||||
}
|
||||
errorMessage = "a signed 32 bit integer (short)";
|
||||
break;
|
||||
case ConfigurationOption.ConfigurationTypes.TYPE_INT32:
|
||||
int intResult;
|
||||
if (Int32.TryParse(console_result, out intResult))
|
||||
{
|
||||
convertSuccess = true;
|
||||
return_result = intResult;
|
||||
|
||||
}
|
||||
errorMessage = "a signed 32 bit integer (int)";
|
||||
break;
|
||||
case ConfigurationOption.ConfigurationTypes.TYPE_INT64:
|
||||
long longResult;
|
||||
if (Int64.TryParse(console_result, out longResult))
|
||||
{
|
||||
convertSuccess = true;
|
||||
return_result = longResult;
|
||||
}
|
||||
errorMessage = "a signed 32 bit integer (long)";
|
||||
break;
|
||||
case ConfigurationOption.ConfigurationTypes.TYPE_IP_ADDRESS:
|
||||
IPAddress ipAddressResult;
|
||||
if (IPAddress.TryParse(console_result, out ipAddressResult))
|
||||
{
|
||||
convertSuccess = true;
|
||||
return_result = ipAddressResult;
|
||||
}
|
||||
errorMessage = "an IP Address (IPAddress)";
|
||||
break;
|
||||
case ConfigurationOption.ConfigurationTypes.TYPE_LLUUID:
|
||||
LLUUID uuidResult;
|
||||
if (LLUUID.TryParse(console_result, out uuidResult))
|
||||
{
|
||||
convertSuccess = true;
|
||||
return_result = uuidResult;
|
||||
}
|
||||
errorMessage = "a UUID (LLUUID)";
|
||||
break;
|
||||
case ConfigurationOption.ConfigurationTypes.TYPE_LLVECTOR3:
|
||||
LLVector3 vectorResult;
|
||||
if (LLVector3.TryParse(console_result, out vectorResult))
|
||||
{
|
||||
convertSuccess = true;
|
||||
return_result = vectorResult;
|
||||
}
|
||||
errorMessage = "a vector (LLVector3)";
|
||||
break;
|
||||
case ConfigurationOption.ConfigurationTypes.TYPE_UINT16:
|
||||
ushort ushortResult;
|
||||
if (UInt16.TryParse(console_result, out ushortResult))
|
||||
{
|
||||
convertSuccess = true;
|
||||
return_result = ushortResult;
|
||||
}
|
||||
errorMessage = "an unsigned 16 bit integer (ushort)";
|
||||
break;
|
||||
case ConfigurationOption.ConfigurationTypes.TYPE_UINT32:
|
||||
uint uintResult;
|
||||
if (UInt32.TryParse(console_result, out uintResult))
|
||||
{
|
||||
convertSuccess = true;
|
||||
return_result = uintResult;
|
||||
|
||||
}
|
||||
errorMessage = "an unsigned 32 bit integer (uint)";
|
||||
break;
|
||||
case ConfigurationOption.ConfigurationTypes.TYPE_UINT64:
|
||||
ulong ulongResult;
|
||||
if (UInt64.TryParse(console_result, out ulongResult))
|
||||
{
|
||||
convertSuccess = true;
|
||||
return_result = ulongResult;
|
||||
}
|
||||
errorMessage = "an unsigned 64 bit integer (ulong)";
|
||||
break;
|
||||
case ConfigurationOption.ConfigurationTypes.TYPE_FLOAT:
|
||||
float floatResult;
|
||||
if (float.TryParse(console_result, out floatResult))
|
||||
{
|
||||
convertSuccess = true;
|
||||
return_result = floatResult;
|
||||
}
|
||||
errorMessage = "a single-precision floating point number (float)";
|
||||
break;
|
||||
case ConfigurationOption.ConfigurationTypes.TYPE_DOUBLE:
|
||||
double doubleResult;
|
||||
if (Double.TryParse(console_result, out doubleResult))
|
||||
{
|
||||
convertSuccess = true;
|
||||
return_result = doubleResult;
|
||||
}
|
||||
errorMessage = "an double-precision floating point number (double)";
|
||||
break;
|
||||
}
|
||||
|
||||
if (convertSuccess)
|
||||
{
|
||||
if (useFile)
|
||||
{
|
||||
configurationPlugin.SetAttribute(configOption.configurationKey, console_result);
|
||||
}
|
||||
|
||||
|
||||
if (!this.resultFunction(configOption.configurationKey, return_result))
|
||||
{
|
||||
Console.MainLog.Instance.Notice("The handler for the last configuration option denied that input, please try again.");
|
||||
convertSuccess = false;
|
||||
ignoreNextFromConfig = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (configOption.configurationUseDefaultNoPrompt)
|
||||
{
|
||||
MainLog.Instance.Error("Default given for '" + configOption.configurationKey + "' is not valid; the configuration result must be " + errorMessage + ". Will skip this option...");
|
||||
convertSuccess = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
MainLog.Instance.Warn("configuration","Incorrect result given, the configuration option must be " + errorMessage + ". Prompting for same option...");
|
||||
ignoreNextFromConfig = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(useFile)
|
||||
{
|
||||
configurationPlugin.Commit();
|
||||
configurationPlugin.Close();
|
||||
}
|
||||
}
|
||||
|
||||
private IGenericConfig LoadConfigDll(string dllName)
|
||||
{
|
||||
Assembly pluginAssembly = Assembly.LoadFrom(dllName);
|
||||
IGenericConfig plug = null;
|
||||
|
||||
foreach (Type pluginType in pluginAssembly.GetTypes())
|
||||
{
|
||||
if (pluginType.IsPublic)
|
||||
{
|
||||
if (!pluginType.IsAbstract)
|
||||
{
|
||||
Type typeInterface = pluginType.GetInterface("IGenericConfig", true);
|
||||
|
||||
if (typeInterface != null)
|
||||
{
|
||||
plug = (IGenericConfig)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pluginAssembly = null;
|
||||
return plug;
|
||||
}
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Net;
|
||||
|
||||
using libsecondlife;
|
||||
|
||||
using OpenSim.Framework.Console;
|
||||
using OpenSim.Framework.Configuration.Interfaces;
|
||||
|
||||
namespace OpenSim.Framework.Configuration
|
||||
{
|
||||
public class ConfigurationMember
|
||||
{
|
||||
public delegate bool ConfigurationOptionResult(string configuration_key, object configuration_result);
|
||||
public delegate void ConfigurationOptionsLoad();
|
||||
|
||||
private List<ConfigurationOption> configurationOptions = new List<ConfigurationOption>();
|
||||
private string configurationFilename = "";
|
||||
private string configurationDescription = "";
|
||||
|
||||
private ConfigurationOptionsLoad loadFunction;
|
||||
private ConfigurationOptionResult resultFunction;
|
||||
|
||||
private IGenericConfig configurationPlugin = null;
|
||||
/// <summary>
|
||||
/// This is the default configuration DLL loaded
|
||||
/// </summary>
|
||||
private string configurationPluginFilename = "OpenSim.Framework.Configuration.XML.dll";
|
||||
public ConfigurationMember(string configuration_filename, string configuration_description, ConfigurationOptionsLoad load_function, ConfigurationOptionResult result_function)
|
||||
{
|
||||
this.configurationFilename = configuration_filename;
|
||||
this.configurationDescription = configuration_description;
|
||||
this.loadFunction = load_function;
|
||||
this.resultFunction = result_function;
|
||||
}
|
||||
|
||||
public void setConfigurationFilename(string filename)
|
||||
{
|
||||
configurationFilename = filename;
|
||||
}
|
||||
public void setConfigurationDescription(string desc)
|
||||
{
|
||||
configurationDescription = desc;
|
||||
}
|
||||
|
||||
public void setConfigurationResultFunction(ConfigurationOptionResult result)
|
||||
{
|
||||
resultFunction = result;
|
||||
}
|
||||
|
||||
public void forceConfigurationPluginLibrary(string dll_filename)
|
||||
{
|
||||
configurationPluginFilename = dll_filename;
|
||||
}
|
||||
public void addConfigurationOption(string configuration_key, ConfigurationOption.ConfigurationTypes configuration_type, string configuration_question, string configuration_default, bool use_default_no_prompt)
|
||||
{
|
||||
ConfigurationOption configOption = new ConfigurationOption();
|
||||
configOption.configurationKey = configuration_key;
|
||||
configOption.configurationQuestion = configuration_question;
|
||||
configOption.configurationDefault = configuration_default;
|
||||
configOption.configurationType = configuration_type;
|
||||
configOption.configurationUseDefaultNoPrompt = use_default_no_prompt;
|
||||
|
||||
if (configuration_key != "" && configuration_question != "")
|
||||
{
|
||||
if (!configurationOptions.Contains(configOption))
|
||||
{
|
||||
configurationOptions.Add(configOption);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MainLog.Instance.Notice("Required fields for adding a configuration option is invalid. Will not add this option (" + configuration_key + ")");
|
||||
}
|
||||
}
|
||||
|
||||
public void performConfigurationRetrieve()
|
||||
{
|
||||
configurationPlugin = this.LoadConfigDll(configurationPluginFilename);
|
||||
configurationOptions.Clear();
|
||||
if(loadFunction == null)
|
||||
{
|
||||
MainLog.Instance.Error("Load Function for '" + this.configurationDescription + "' is null. Refusing to run configuration.");
|
||||
return;
|
||||
}
|
||||
|
||||
if(resultFunction == null)
|
||||
{
|
||||
MainLog.Instance.Error("Result Function for '" + this.configurationDescription + "' is null. Refusing to run configuration.");
|
||||
return;
|
||||
}
|
||||
|
||||
MainLog.Instance.Verbose("Calling Configuration Load Function...");
|
||||
this.loadFunction();
|
||||
|
||||
if(configurationOptions.Count <= 0)
|
||||
{
|
||||
MainLog.Instance.Error("No configuration options were specified for '" + this.configurationOptions + "'. Refusing to continue configuration.");
|
||||
return;
|
||||
}
|
||||
|
||||
bool useFile = true;
|
||||
if (configurationPlugin == null)
|
||||
{
|
||||
MainLog.Instance.Error("Configuration Plugin NOT LOADED!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (configurationFilename.Trim() != "")
|
||||
{
|
||||
configurationPlugin.SetFileName(configurationFilename);
|
||||
configurationPlugin.LoadData();
|
||||
useFile = true;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
MainLog.Instance.Notice("XML Configuration Filename is not valid; will not save to the file.");
|
||||
useFile = false;
|
||||
}
|
||||
|
||||
foreach (ConfigurationOption configOption in configurationOptions)
|
||||
{
|
||||
bool convertSuccess = false;
|
||||
object return_result = null;
|
||||
string errorMessage = "";
|
||||
bool ignoreNextFromConfig = false;
|
||||
while (convertSuccess == false)
|
||||
{
|
||||
|
||||
string console_result = "";
|
||||
string attribute = null;
|
||||
if (useFile)
|
||||
{
|
||||
if (!ignoreNextFromConfig)
|
||||
{
|
||||
attribute = configurationPlugin.GetAttribute(configOption.configurationKey);
|
||||
}
|
||||
else
|
||||
{
|
||||
ignoreNextFromConfig = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (attribute == null)
|
||||
{
|
||||
if (configOption.configurationUseDefaultNoPrompt)
|
||||
{
|
||||
console_result = configOption.configurationDefault;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if (configurationDescription.Trim() != "")
|
||||
{
|
||||
console_result = MainLog.Instance.CmdPrompt(configurationDescription + ": " + configOption.configurationQuestion, configOption.configurationDefault);
|
||||
}
|
||||
else
|
||||
{
|
||||
console_result = MainLog.Instance.CmdPrompt(configOption.configurationQuestion, configOption.configurationDefault);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
console_result = attribute;
|
||||
}
|
||||
|
||||
switch (configOption.configurationType)
|
||||
{
|
||||
case ConfigurationOption.ConfigurationTypes.TYPE_STRING:
|
||||
return_result = console_result;
|
||||
convertSuccess = true;
|
||||
break;
|
||||
case ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY:
|
||||
if (console_result.Length > 0)
|
||||
{
|
||||
return_result = console_result;
|
||||
convertSuccess = true;
|
||||
}
|
||||
errorMessage = "a string that is not empty";
|
||||
break;
|
||||
case ConfigurationOption.ConfigurationTypes.TYPE_BOOLEAN:
|
||||
bool boolResult;
|
||||
if (Boolean.TryParse(console_result, out boolResult))
|
||||
{
|
||||
convertSuccess = true;
|
||||
return_result = boolResult;
|
||||
}
|
||||
errorMessage = "'true' or 'false' (Boolean)";
|
||||
break;
|
||||
case ConfigurationOption.ConfigurationTypes.TYPE_BYTE:
|
||||
byte byteResult;
|
||||
if (Byte.TryParse(console_result, out byteResult))
|
||||
{
|
||||
convertSuccess = true;
|
||||
return_result = byteResult;
|
||||
}
|
||||
errorMessage = "a byte (Byte)";
|
||||
break;
|
||||
case ConfigurationOption.ConfigurationTypes.TYPE_CHARACTER:
|
||||
char charResult;
|
||||
if (Char.TryParse(console_result, out charResult))
|
||||
{
|
||||
convertSuccess = true;
|
||||
return_result = charResult;
|
||||
}
|
||||
errorMessage = "a character (Char)";
|
||||
break;
|
||||
case ConfigurationOption.ConfigurationTypes.TYPE_INT16:
|
||||
short shortResult;
|
||||
if (Int16.TryParse(console_result, out shortResult))
|
||||
{
|
||||
convertSuccess = true;
|
||||
return_result = shortResult;
|
||||
}
|
||||
errorMessage = "a signed 32 bit integer (short)";
|
||||
break;
|
||||
case ConfigurationOption.ConfigurationTypes.TYPE_INT32:
|
||||
int intResult;
|
||||
if (Int32.TryParse(console_result, out intResult))
|
||||
{
|
||||
convertSuccess = true;
|
||||
return_result = intResult;
|
||||
|
||||
}
|
||||
errorMessage = "a signed 32 bit integer (int)";
|
||||
break;
|
||||
case ConfigurationOption.ConfigurationTypes.TYPE_INT64:
|
||||
long longResult;
|
||||
if (Int64.TryParse(console_result, out longResult))
|
||||
{
|
||||
convertSuccess = true;
|
||||
return_result = longResult;
|
||||
}
|
||||
errorMessage = "a signed 32 bit integer (long)";
|
||||
break;
|
||||
case ConfigurationOption.ConfigurationTypes.TYPE_IP_ADDRESS:
|
||||
IPAddress ipAddressResult;
|
||||
if (IPAddress.TryParse(console_result, out ipAddressResult))
|
||||
{
|
||||
convertSuccess = true;
|
||||
return_result = ipAddressResult;
|
||||
}
|
||||
errorMessage = "an IP Address (IPAddress)";
|
||||
break;
|
||||
case ConfigurationOption.ConfigurationTypes.TYPE_LLUUID:
|
||||
LLUUID uuidResult;
|
||||
if (LLUUID.TryParse(console_result, out uuidResult))
|
||||
{
|
||||
convertSuccess = true;
|
||||
return_result = uuidResult;
|
||||
}
|
||||
errorMessage = "a UUID (LLUUID)";
|
||||
break;
|
||||
case ConfigurationOption.ConfigurationTypes.TYPE_LLVECTOR3:
|
||||
LLVector3 vectorResult;
|
||||
if (LLVector3.TryParse(console_result, out vectorResult))
|
||||
{
|
||||
convertSuccess = true;
|
||||
return_result = vectorResult;
|
||||
}
|
||||
errorMessage = "a vector (LLVector3)";
|
||||
break;
|
||||
case ConfigurationOption.ConfigurationTypes.TYPE_UINT16:
|
||||
ushort ushortResult;
|
||||
if (UInt16.TryParse(console_result, out ushortResult))
|
||||
{
|
||||
convertSuccess = true;
|
||||
return_result = ushortResult;
|
||||
}
|
||||
errorMessage = "an unsigned 16 bit integer (ushort)";
|
||||
break;
|
||||
case ConfigurationOption.ConfigurationTypes.TYPE_UINT32:
|
||||
uint uintResult;
|
||||
if (UInt32.TryParse(console_result, out uintResult))
|
||||
{
|
||||
convertSuccess = true;
|
||||
return_result = uintResult;
|
||||
|
||||
}
|
||||
errorMessage = "an unsigned 32 bit integer (uint)";
|
||||
break;
|
||||
case ConfigurationOption.ConfigurationTypes.TYPE_UINT64:
|
||||
ulong ulongResult;
|
||||
if (UInt64.TryParse(console_result, out ulongResult))
|
||||
{
|
||||
convertSuccess = true;
|
||||
return_result = ulongResult;
|
||||
}
|
||||
errorMessage = "an unsigned 64 bit integer (ulong)";
|
||||
break;
|
||||
case ConfigurationOption.ConfigurationTypes.TYPE_FLOAT:
|
||||
float floatResult;
|
||||
if (float.TryParse(console_result, out floatResult))
|
||||
{
|
||||
convertSuccess = true;
|
||||
return_result = floatResult;
|
||||
}
|
||||
errorMessage = "a single-precision floating point number (float)";
|
||||
break;
|
||||
case ConfigurationOption.ConfigurationTypes.TYPE_DOUBLE:
|
||||
double doubleResult;
|
||||
if (Double.TryParse(console_result, out doubleResult))
|
||||
{
|
||||
convertSuccess = true;
|
||||
return_result = doubleResult;
|
||||
}
|
||||
errorMessage = "an double-precision floating point number (double)";
|
||||
break;
|
||||
}
|
||||
|
||||
if (convertSuccess)
|
||||
{
|
||||
if (useFile)
|
||||
{
|
||||
configurationPlugin.SetAttribute(configOption.configurationKey, console_result);
|
||||
}
|
||||
|
||||
|
||||
if (!this.resultFunction(configOption.configurationKey, return_result))
|
||||
{
|
||||
Console.MainLog.Instance.Notice("The handler for the last configuration option denied that input, please try again.");
|
||||
convertSuccess = false;
|
||||
ignoreNextFromConfig = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (configOption.configurationUseDefaultNoPrompt)
|
||||
{
|
||||
MainLog.Instance.Error("Default given for '" + configOption.configurationKey + "' is not valid; the configuration result must be " + errorMessage + ". Will skip this option...");
|
||||
convertSuccess = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
MainLog.Instance.Warn("configuration","Incorrect result given, the configuration option must be " + errorMessage + ". Prompting for same option...");
|
||||
ignoreNextFromConfig = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(useFile)
|
||||
{
|
||||
configurationPlugin.Commit();
|
||||
configurationPlugin.Close();
|
||||
}
|
||||
}
|
||||
|
||||
private IGenericConfig LoadConfigDll(string dllName)
|
||||
{
|
||||
Assembly pluginAssembly = Assembly.LoadFrom(dllName);
|
||||
IGenericConfig plug = null;
|
||||
|
||||
foreach (Type pluginType in pluginAssembly.GetTypes())
|
||||
{
|
||||
if (pluginType.IsPublic)
|
||||
{
|
||||
if (!pluginType.IsAbstract)
|
||||
{
|
||||
Type typeInterface = pluginType.GetInterface("IGenericConfig", true);
|
||||
|
||||
if (typeInterface != null)
|
||||
{
|
||||
plug = (IGenericConfig)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pluginAssembly = null;
|
||||
return plug;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,36 +1,36 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenSim.Framework.Configuration
|
||||
{
|
||||
public class ConfigurationOption
|
||||
{
|
||||
public enum ConfigurationTypes
|
||||
{
|
||||
TYPE_STRING,
|
||||
TYPE_STRING_NOT_EMPTY,
|
||||
TYPE_UINT16,
|
||||
TYPE_UINT32,
|
||||
TYPE_UINT64,
|
||||
TYPE_INT16,
|
||||
TYPE_INT32,
|
||||
TYPE_INT64,
|
||||
TYPE_IP_ADDRESS,
|
||||
TYPE_CHARACTER,
|
||||
TYPE_BOOLEAN,
|
||||
TYPE_BYTE,
|
||||
TYPE_LLUUID,
|
||||
TYPE_LLVECTOR3,
|
||||
TYPE_FLOAT,
|
||||
TYPE_DOUBLE
|
||||
};
|
||||
|
||||
public string configurationKey = "";
|
||||
public string configurationQuestion = "";
|
||||
public string configurationDefault = "";
|
||||
|
||||
public ConfigurationTypes configurationType = ConfigurationTypes.TYPE_STRING;
|
||||
public bool configurationUseDefaultNoPrompt = false;
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenSim.Framework.Configuration
|
||||
{
|
||||
public class ConfigurationOption
|
||||
{
|
||||
public enum ConfigurationTypes
|
||||
{
|
||||
TYPE_STRING,
|
||||
TYPE_STRING_NOT_EMPTY,
|
||||
TYPE_UINT16,
|
||||
TYPE_UINT32,
|
||||
TYPE_UINT64,
|
||||
TYPE_INT16,
|
||||
TYPE_INT32,
|
||||
TYPE_INT64,
|
||||
TYPE_IP_ADDRESS,
|
||||
TYPE_CHARACTER,
|
||||
TYPE_BOOLEAN,
|
||||
TYPE_BYTE,
|
||||
TYPE_LLUUID,
|
||||
TYPE_LLVECTOR3,
|
||||
TYPE_FLOAT,
|
||||
TYPE_DOUBLE
|
||||
};
|
||||
|
||||
public string configurationKey = "";
|
||||
public string configurationQuestion = "";
|
||||
public string configurationDefault = "";
|
||||
|
||||
public ConfigurationTypes configurationType = ConfigurationTypes.TYPE_STRING;
|
||||
public bool configurationUseDefaultNoPrompt = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,85 +1,85 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenSim.Framework.Configuration
|
||||
{
|
||||
public class GridConfig
|
||||
{
|
||||
public string GridOwner = "";
|
||||
public string DefaultAssetServer = "";
|
||||
public string AssetSendKey = "";
|
||||
public string AssetRecvKey = "";
|
||||
|
||||
public string DefaultUserServer = "";
|
||||
public string UserSendKey = "";
|
||||
public string UserRecvKey = "";
|
||||
|
||||
public string SimSendKey = "";
|
||||
public string SimRecvKey = "";
|
||||
|
||||
public string DatabaseProvider = "";
|
||||
|
||||
private ConfigurationMember configMember;
|
||||
public GridConfig(string description, string filename)
|
||||
{
|
||||
configMember = new ConfigurationMember(filename, description, this.loadConfigurationOptions, this.handleIncomingConfiguration);
|
||||
configMember.performConfigurationRetrieve();
|
||||
}
|
||||
|
||||
public void loadConfigurationOptions()
|
||||
{
|
||||
configMember.addConfigurationOption("grid_owner", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "OGS Grid Owner", "OGS development team", false);
|
||||
configMember.addConfigurationOption("default_asset_server", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "Default Asset Server URI", "http://127.0.0.1:8003/", false);
|
||||
configMember.addConfigurationOption("asset_send_key", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "Key to send to asset server", "null", false);
|
||||
configMember.addConfigurationOption("asset_recv_key", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "Key to expect from asset server", "null", false);
|
||||
|
||||
configMember.addConfigurationOption("default_user_server", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "Default User Server URI", "http://127.0.0.1:8002/", false);
|
||||
configMember.addConfigurationOption("user_send_key", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "Key to send to user server", "null", false);
|
||||
configMember.addConfigurationOption("user_recv_key", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "Key to expect from user server", "null", false);
|
||||
|
||||
configMember.addConfigurationOption("sim_send_key", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "Key to send to a simulator", "null", false);
|
||||
configMember.addConfigurationOption("sim_recv_key", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "Key to expect from a simulator", "null", false);
|
||||
configMember.addConfigurationOption("database_provider", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "DLL for database provider", "OpenSim.Framework.Data.MySQL.dll", false);
|
||||
}
|
||||
|
||||
public bool handleIncomingConfiguration(string configuration_key, object configuration_result)
|
||||
{
|
||||
switch (configuration_key)
|
||||
{
|
||||
case "grid_owner":
|
||||
this.GridOwner = (string)configuration_result;
|
||||
break;
|
||||
case "default_asset_server":
|
||||
this.DefaultAssetServer = (string)configuration_result;
|
||||
break;
|
||||
case "asset_send_key":
|
||||
this.AssetSendKey = (string)configuration_result;
|
||||
break;
|
||||
case "asset_recv_key":
|
||||
this.AssetRecvKey = (string)configuration_result;
|
||||
break;
|
||||
case "default_user_server":
|
||||
this.DefaultUserServer = (string)configuration_result;
|
||||
break;
|
||||
case "user_send_key":
|
||||
this.UserSendKey = (string)configuration_result;
|
||||
break;
|
||||
case "user_recv_key":
|
||||
this.UserRecvKey = (string)configuration_result;
|
||||
break;
|
||||
case "sim_send_key":
|
||||
this.SimSendKey = (string)configuration_result;
|
||||
break;
|
||||
case "sim_recv_key":
|
||||
this.SimRecvKey = (string)configuration_result;
|
||||
break;
|
||||
case "database_provider":
|
||||
this.DatabaseProvider = (string)configuration_result;
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenSim.Framework.Configuration
|
||||
{
|
||||
public class GridConfig
|
||||
{
|
||||
public string GridOwner = "";
|
||||
public string DefaultAssetServer = "";
|
||||
public string AssetSendKey = "";
|
||||
public string AssetRecvKey = "";
|
||||
|
||||
public string DefaultUserServer = "";
|
||||
public string UserSendKey = "";
|
||||
public string UserRecvKey = "";
|
||||
|
||||
public string SimSendKey = "";
|
||||
public string SimRecvKey = "";
|
||||
|
||||
public string DatabaseProvider = "";
|
||||
|
||||
private ConfigurationMember configMember;
|
||||
public GridConfig(string description, string filename)
|
||||
{
|
||||
configMember = new ConfigurationMember(filename, description, this.loadConfigurationOptions, this.handleIncomingConfiguration);
|
||||
configMember.performConfigurationRetrieve();
|
||||
}
|
||||
|
||||
public void loadConfigurationOptions()
|
||||
{
|
||||
configMember.addConfigurationOption("grid_owner", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "OGS Grid Owner", "OGS development team", false);
|
||||
configMember.addConfigurationOption("default_asset_server", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "Default Asset Server URI", "http://127.0.0.1:8003/", false);
|
||||
configMember.addConfigurationOption("asset_send_key", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "Key to send to asset server", "null", false);
|
||||
configMember.addConfigurationOption("asset_recv_key", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "Key to expect from asset server", "null", false);
|
||||
|
||||
configMember.addConfigurationOption("default_user_server", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "Default User Server URI", "http://127.0.0.1:8002/", false);
|
||||
configMember.addConfigurationOption("user_send_key", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "Key to send to user server", "null", false);
|
||||
configMember.addConfigurationOption("user_recv_key", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "Key to expect from user server", "null", false);
|
||||
|
||||
configMember.addConfigurationOption("sim_send_key", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "Key to send to a simulator", "null", false);
|
||||
configMember.addConfigurationOption("sim_recv_key", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "Key to expect from a simulator", "null", false);
|
||||
configMember.addConfigurationOption("database_provider", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "DLL for database provider", "OpenSim.Framework.Data.MySQL.dll", false);
|
||||
}
|
||||
|
||||
public bool handleIncomingConfiguration(string configuration_key, object configuration_result)
|
||||
{
|
||||
switch (configuration_key)
|
||||
{
|
||||
case "grid_owner":
|
||||
this.GridOwner = (string)configuration_result;
|
||||
break;
|
||||
case "default_asset_server":
|
||||
this.DefaultAssetServer = (string)configuration_result;
|
||||
break;
|
||||
case "asset_send_key":
|
||||
this.AssetSendKey = (string)configuration_result;
|
||||
break;
|
||||
case "asset_recv_key":
|
||||
this.AssetRecvKey = (string)configuration_result;
|
||||
break;
|
||||
case "default_user_server":
|
||||
this.DefaultUserServer = (string)configuration_result;
|
||||
break;
|
||||
case "user_send_key":
|
||||
this.UserSendKey = (string)configuration_result;
|
||||
break;
|
||||
case "user_recv_key":
|
||||
this.UserRecvKey = (string)configuration_result;
|
||||
break;
|
||||
case "sim_send_key":
|
||||
this.SimSendKey = (string)configuration_result;
|
||||
break;
|
||||
case "sim_recv_key":
|
||||
this.SimRecvKey = (string)configuration_result;
|
||||
break;
|
||||
case "database_provider":
|
||||
this.DatabaseProvider = (string)configuration_result;
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,40 +1,40 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://www.openmetaverse.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSim Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
namespace OpenSim.Framework.Configuration.Interfaces
|
||||
{
|
||||
public interface IGenericConfig
|
||||
{
|
||||
void SetFileName(string fileName);
|
||||
void LoadData();
|
||||
void LoadDataFromString(string data);
|
||||
string GetAttribute(string attributeName);
|
||||
bool SetAttribute(string attributeName, string attributeValue);
|
||||
void Commit();
|
||||
void Close();
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Copyright (c) Contributors, http://www.openmetaverse.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSim Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
namespace OpenSim.Framework.Configuration.Interfaces
|
||||
{
|
||||
public interface IGenericConfig
|
||||
{
|
||||
void SetFileName(string fileName);
|
||||
void LoadData();
|
||||
void LoadDataFromString(string data);
|
||||
string GetAttribute(string attributeName);
|
||||
bool SetAttribute(string attributeName, string attributeValue);
|
||||
void Commit();
|
||||
void Close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,62 +1,62 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenSim.Framework.Configuration
|
||||
{
|
||||
/// <summary>
|
||||
/// UserConfig -- For User Server Configuration
|
||||
/// </summary>
|
||||
public class UserConfig
|
||||
{
|
||||
public string DefaultStartupMsg = "";
|
||||
public string GridServerURL = "";
|
||||
public string GridSendKey = "";
|
||||
public string GridRecvKey = "";
|
||||
|
||||
public string DatabaseProvider = "";
|
||||
|
||||
private ConfigurationMember configMember;
|
||||
|
||||
public UserConfig(string description, string filename)
|
||||
{
|
||||
configMember = new ConfigurationMember(filename, description, this.loadConfigurationOptions, this.handleIncomingConfiguration);
|
||||
configMember.performConfigurationRetrieve();
|
||||
}
|
||||
|
||||
public void loadConfigurationOptions()
|
||||
{
|
||||
configMember.addConfigurationOption("default_startup_message", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "Default Startup Message", "Welcome to OGS",false);
|
||||
|
||||
configMember.addConfigurationOption("default_grid_server", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "Default Grid Server URI", "http://127.0.0.1:8001/", false);
|
||||
configMember.addConfigurationOption("grid_send_key", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "Key to send to grid server", "null", false);
|
||||
configMember.addConfigurationOption("grid_recv_key", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "Key to expect from grid server", "null", false);
|
||||
configMember.addConfigurationOption("database_provider", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "DLL for database provider", "OpenSim.Framework.Data.MySQL.dll", false);
|
||||
|
||||
}
|
||||
|
||||
public bool handleIncomingConfiguration(string configuration_key, object configuration_result)
|
||||
{
|
||||
switch (configuration_key)
|
||||
{
|
||||
case "default_startup_message":
|
||||
this.DefaultStartupMsg = (string)configuration_result;
|
||||
break;
|
||||
case "default_grid_server":
|
||||
this.GridServerURL = (string)configuration_result;
|
||||
break;
|
||||
case "grid_send_key":
|
||||
this.GridSendKey = (string)configuration_result;
|
||||
break;
|
||||
case "grid_recv_key":
|
||||
this.GridRecvKey = (string)configuration_result;
|
||||
break;
|
||||
case "database_provider":
|
||||
this.DatabaseProvider = (string)configuration_result;
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenSim.Framework.Configuration
|
||||
{
|
||||
/// <summary>
|
||||
/// UserConfig -- For User Server Configuration
|
||||
/// </summary>
|
||||
public class UserConfig
|
||||
{
|
||||
public string DefaultStartupMsg = "";
|
||||
public string GridServerURL = "";
|
||||
public string GridSendKey = "";
|
||||
public string GridRecvKey = "";
|
||||
|
||||
public string DatabaseProvider = "";
|
||||
|
||||
private ConfigurationMember configMember;
|
||||
|
||||
public UserConfig(string description, string filename)
|
||||
{
|
||||
configMember = new ConfigurationMember(filename, description, this.loadConfigurationOptions, this.handleIncomingConfiguration);
|
||||
configMember.performConfigurationRetrieve();
|
||||
}
|
||||
|
||||
public void loadConfigurationOptions()
|
||||
{
|
||||
configMember.addConfigurationOption("default_startup_message", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "Default Startup Message", "Welcome to OGS",false);
|
||||
|
||||
configMember.addConfigurationOption("default_grid_server", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, "Default Grid Server URI", "http://127.0.0.1:8001/", false);
|
||||
configMember.addConfigurationOption("grid_send_key", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "Key to send to grid server", "null", false);
|
||||
configMember.addConfigurationOption("grid_recv_key", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "Key to expect from grid server", "null", false);
|
||||
configMember.addConfigurationOption("database_provider", ConfigurationOption.ConfigurationTypes.TYPE_STRING, "DLL for database provider", "OpenSim.Framework.Data.MySQL.dll", false);
|
||||
|
||||
}
|
||||
|
||||
public bool handleIncomingConfiguration(string configuration_key, object configuration_result)
|
||||
{
|
||||
switch (configuration_key)
|
||||
{
|
||||
case "default_startup_message":
|
||||
this.DefaultStartupMsg = (string)configuration_result;
|
||||
break;
|
||||
case "default_grid_server":
|
||||
this.GridServerURL = (string)configuration_result;
|
||||
break;
|
||||
case "grid_send_key":
|
||||
this.GridSendKey = (string)configuration_result;
|
||||
break;
|
||||
case "grid_recv_key":
|
||||
this.GridRecvKey = (string)configuration_result;
|
||||
break;
|
||||
case "database_provider":
|
||||
this.DatabaseProvider = (string)configuration_result;
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user