本文整理汇总了C#中Properties.getProperty方法的典型用法代码示例。如果您正苦于以下问题:C# Properties.getProperty方法的具体用法?C# Properties.getProperty怎么用?C# Properties.getProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Properties
的用法示例。
在下文中一共展示了Properties.getProperty方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
public static void Main(string[] args)
{
Properties pps = new Properties();
if ( System.IO.File.Exists(DEFAULT_FILE) )
LoadLeapPropertiesFile();
else
p = new ProfileImpl();
if (args.Length > 0)
{
pps = jade.Boot.parseCmdLineArgs(args);
if (pps != null)
{
java.util.Enumeration en = pps.keys();
while ( en.hasMoreElements() )
{
string key = (string) en.nextElement();
string prop = pps.getProperty(key);
p.setParameter(key, prop);
}//End WHILE block
}//End IF block
}//End IF block
/* VERSIONE 3.2 */
jade.wrapper.AgentContainer mc = null;
/* VERSIONE 3.1 */
//jade.wrapper.MainContainer mc = null;
try
{
if (p.getParameter("main", "true").Equals("false"))
mc = Runtime.instance().createAgentContainer(p);
else
mc = Runtime.instance().createMainContainer(p);
}
catch(Exception exc)
{
Console.WriteLine( "\n----------- INIZIO ECCEZIONE ------------------" );
Console.WriteLine( exc.Message );
Console.WriteLine( exc.InnerException );
Console.WriteLine( "\n----------- FINE ECCEZIONE ------------------" );
}
Console.ReadLine();
}
示例2: Start
// Use this for initialization
void Start()
{
props = new Properties(filename);
Camera.main.orthographicSize = System.Convert.ToSingle(props.getProperty("cameraSize"));
float offset = Camera.main.aspect * Camera.main.orthographicSize;
float cameraX = System.Convert.ToSingle(props.getProperty("cameraX"));
float cameraY = System.Convert.ToSingle(props.getProperty("cameraY"));
float cameraZ = System.Convert.ToSingle(props.getProperty("cameraZ"));
int cameraNumber = System.Convert.ToInt32(props.getProperty("cameraNumber"));
//Camera.main.transform.position = new Vector3(cameraX, cameraY, cameraZ);
if(cameraNumber == 0){ // server camera
Camera.main.transform.position = new Vector3(cameraX, cameraY, cameraZ);
} else if(cameraNumber == 1){ // #1 client camera
Camera.main.transform.position = new Vector3(0 - offset, cameraY, cameraZ);
} else if(cameraNumber == 2){ // #2 client camera
Camera.main.transform.position = new Vector3(offset, cameraY, cameraZ);
}
float cameraRoll = System.Convert.ToSingle(props.getProperty("cameraRoll"));
float cameraPitch = System.Convert.ToSingle(props.getProperty("cameraPitch"));
float cameraYaw = System.Convert.ToSingle(props.getProperty("cameraYaw"));
Camera.main.transform.Rotate(cameraPitch, cameraYaw, cameraRoll);
}
示例3: getControllers
/**
* Creates a vector of SampleController plugins.
*
* @param properties
* The properties with information about the samplers
* @return The Controllers value
*/
// TODO - does not appear to be called directly
public static Vector<Object> getControllers(Properties properties)
{
String name = "controller."; // $NON-NLS-1$
Vector<Object> v = new Vector<Object>();
Enumeration<?> names = properties.keys();
while (names.hasMoreElements()) {
String prop = (String) names.nextElement();
if (prop.startsWith(name)) {
Object o = instantiate(properties.getProperty(prop),
"org.apache.jmeter.control.SamplerController"); // $NON-NLS-1$
v.addElement(o);
}
}
return v;
}
示例4: GenericADODataModel
/**
* <p>Specifies all SQL queries in a {@link Properties} object. See the <code>*_KEY</code>
* constants in this class (e.g. {@link #GET_USER_SQL_KEY}) for a list of all keys which
* must map to a value in this object.</p>
*
* @param props {@link Properties} object containing values
* @if anything goes wrong during initialization
*/
public GenericADODataModel(Properties props)
: base(
props.getProperty(GET_USER_SQL_KEY),
props.getProperty(GET_NUM_USERS_SQL_KEY),
props.getProperty(GET_NUM_ITEMS_SQL_KEY),
props.getProperty(SET_PREFERENCE_SQL_KEY),
props.getProperty(REMOVE_PREFERENCE_SQL_KEY),
props.getProperty(GET_USERS_SQL_KEY),
props.getProperty(GET_ITEMS_SQL_KEY),
props.getProperty(GET_ITEM_SQL_KEY),
props.getProperty(GET_PREFS_FOR_ITEM_SQL_KEY),
props.getProperty(GET_USERS_PREFERRING_ITEM_SQL_KEY))
{
this.ConnectionString = props.getProperty(CONNECTION_STRING_KEY);
}
示例5: appendstrings
/**
* Loads the strings of the application from the given set of XML properties
* files.
*
* @param languageFiles
* List with the names of the file containing the text
*/
//public static void loadstrings(string[] languageFiles)
//{
// if (languageFiles != null && languageFiles.length > 0)
// {
// loadstrings(languageFiles[0]);
// for (int i = 1; i < languageFiles.length; i++)
// appendstrings(languageFiles[i]);
// }
// else {
// guistrings = new Properties();
// }
//}
/**
* Loads the strings of the application from the given set of XML properties
* files.
*
* @param languageFiles
* List with the names of the file containing the text
*/
//public static void loadstrings(InputStream[] languageFiles)
//{
// if (languageFiles != null && languageFiles.length > 0)
// {
// loadstrings(languageFiles[0]);
// for (int i = 1; i < languageFiles.length; i++)
// appendstrings(languageFiles[i]);
// }
// else {
// guistrings = new Properties();
// }
//}
/**
* Loads the strings of the application from the given XML properties file.
*
* @param languageFile
* Name of the file containing the text
*/
//public static void loadstrings(InputStream languageFile)
//{
// guistrings = new Properties();
// try
// {
// guistrings.loadFromXML(languageFile);
// }
// // If the file is bad formed
// catch (InvalidPropertiesFormatException e)
// {
// JOptionPane.showMessageDialog(null, "The language file is bad-formed, please try to use another language file.\nAlthough you may still be able to use the adventure editor, you might get occasional problems or get some unreadable texts.\nIf you get this error again, please try reinstalling the application.", "Error loading the language file", JOptionPane.ERROR_MESSAGE);
// }
// // If the file was not found
// catch (FileNotFoundException e)
// {
// JOptionPane.showMessageDialog(null, "The language file was not found, please verify that the language files are on the disk.\nAlthough you may still be able to use the adventure editor, you might get occasional problems or get some unreadable texts.\nIf you get this error again, please try reinstalling the application.", "Error loading the language file", JOptionPane.ERROR_MESSAGE);
// }
// // If there was a I/O exception
// catch (IOException e)
// {
// JOptionPane.showMessageDialog(null, "There has been an error loading the language file, please check for problem accessing the files.\nAlthough you may still be able to use the adventure editor, you might get occasional problems or get some unreadable texts.\nIf you get this error again, please try reinstalling the application.", "Error loading the language file", JOptionPane.ERROR_MESSAGE);
// }
//}
/**
* Loads the language file specified as argument but does not clear the
* properties structure, appending both contents. The results are equivalent
* to: properties = properties.append(propertiesFromNewFile)
*/
//public static void appendstrings(string languageFile)
//{
// try
// {
// appendstrings(languageFile);
// }
// catch (FileNotFoundException e)
// {
// Debug.Log(
// "One of the language file required was not found, please verify that the language files are on the disk.\nAlthough you may still be able to use the adventure editor, you might get occasional problems or get some unreadable texts.\nIf you get this error again, please try reinstalling the application.\n Error loading the language file");
// }
//}
/**
* Loads the language file specified as argument but does not clear the
* properties structure, appending both contents. The results are equivalent
* to: properties = properties.append(propertiesFromNewFile)
*/
public static void appendstrings(string languageFile)
{
try
{
Properties newstrings = new Properties(languageFile);
foreach (string key in newstrings.getKeyset())
{
if (guistrings.ContainsKey(key))
guistrings.Remove(key);
guistrings.Add(key, newstrings.getProperty(key));
}
//.........这里部分代码省略.........
示例6: Main
public static void Main(string[] args)
{
Properties arguments = new Properties();
string error = "";
bool ok = args.Length > 0;
if (ok)
{
arguments.setProperty("Trace", "Off");
arguments.setProperty("Rule", "xri");
for (int i = 0; i < args.Length; i++)
{
if (args[i].Equals("-trace"))
arguments.setProperty("Trace", "On");
else if (args[i].Equals("-visitor"))
arguments.setProperty("Visitor", args[++i]);
else if (args[i].Equals("-file"))
arguments.setProperty("File", args[++i]);
else if (args[i].Equals("-string"))
arguments.setProperty("String", args[++i]);
else if (args[i].Equals("-rule"))
arguments.setProperty("Rule", args[++i]);
else
{
error = "unknown argument: " + args[i];
ok = false;
}
}
}
if (arguments.getProperty("File") == null &&
arguments.getProperty("String") == null)
{
error = "insufficient arguments";
ok = false;
}
if (!ok)
{
Logger.Info("error: " + error);
Logger.Info("usage: Parser [-rule rulename] [-trace] <-file file | -string string> [-visitor visitor]");
}
else
{
try
{
Parser parser = new Parser();
Rule rule = null;
parser.traceOff();
if (arguments.getProperty("Trace").Equals("On"))
parser.traceOn();
if (arguments.getProperty("File") != null)
rule = parser.parse(arguments.getProperty("Rule"), File.OpenRead(arguments.getProperty("File")));
else if (arguments.getProperty("String") != null)
rule = parser.parse(arguments.getProperty("Rule"), arguments.getProperty("String"));
if (arguments.getProperty("Visitor") != null)
{
Visitor visitor =
(Visitor)Activator.CreateInstance(Type.GetType(arguments.getProperty("Visitor")));
visitor.visit(rule);
}
}
catch (ArgumentException e)
{
Logger.Info("argument error: " + e.Message);
}
catch (IOException e)
{
Logger.Info("io error: " + e.Message);
}
catch (ParserException e)
{
Logger.Info("parser error: " + e.Message);
}
catch (TypeLoadException e)
{
Logger.Info("visitor error: class not found - " + e.Message);
}
catch (MethodAccessException e)
{
Logger.Info("visitor error: illegal access - " + e.Message);
}
catch (TargetInvocationException e)
{
Logger.Info("visitor error: instantiation failure - " + e.Message);
}
}
}