本文整理汇总了C#中Options类的典型用法代码示例。如果您正苦于以下问题:C# Options类的具体用法?C# Options怎么用?C# Options使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Options类属于命名空间,在下文中一共展示了Options类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Execute
public void Execute(string[] args)
{
Options options = new Options(args);
int threadsCount = options.ThreadsCount > 0
? options.ThreadsCount
: Environment.ProcessorCount;
_loopsPerThread = options.MegaLoops * 1000000L;
if (threadsCount == 1)
{
Burn();
}
else
{
_loopsPerThread /= threadsCount;
_gateEvent = new ManualResetEvent(false);
Thread[] threads = new Thread[threadsCount];
for (int i = 0; i < threadsCount; i++)
{
var thread = new Thread(Burn);
thread.IsBackground = true;
thread.Start();
threads[i] = thread;
}
_gateEvent.Set();
foreach (var thread in threads)
thread.Join();
}
}
示例2: TestNoInternal
public void TestNoInternal()
{
PolicyTemplate template = new PolicyTemplate();
template.Load(policyFile);
Options options = new Options(pdfExternal);
SortedList<int, IAction> internalActions = template[TemplatePolicy.PdfPolicy, ChannelType.SMTP, Routing.Internal];
SortedList<int, IAction> externalActions = template[TemplatePolicy.PdfPolicy, ChannelType.SMTP, Routing.External];
Assert.AreEqual(1, internalActions.Count);
Assert.AreEqual(1, externalActions.Count);
PdfPolicy pdfPolicy = new PdfPolicy(template, options);
pdfPolicy.Apply();
string runtimePolicy = System.IO.Path.GetTempFileName();
string myPolicy = System.IO.Path.GetTempFileName();
template.Save(myPolicy, runtimePolicy);
PolicyTemplate modifedTemplate = new PolicyTemplate();
modifedTemplate.Load(myPolicy);
internalActions = modifedTemplate[TemplatePolicy.PdfPolicy, ChannelType.SMTP, Routing.Internal];
externalActions = modifedTemplate[TemplatePolicy.PdfPolicy, ChannelType.SMTP, Routing.External];
Assert.AreEqual(0, internalActions.Count);
Assert.AreEqual(1, externalActions.Count);
modifedTemplate.Close();
System.IO.File.Delete(runtimePolicy);
System.IO.File.Delete(myPolicy);
}
示例3: TestDayOfWeekModifierWithSundayStartOne
public void TestDayOfWeekModifierWithSundayStartOne()
{
Options options = new Options();
options.DayOfWeekStartIndexZero = false;
Assert.AreEqual("在 12:23 PM, 在 第二个星期日 每月", ExpressionDescriptor.GetDescription("23 12 * * 1#2", options));
}
示例4: WriteClasses
public void WriteClasses(List<string> classes, Options options)
{
WriteLine("[JsType(JsMode.Json)]");
Bracket((options.AccessInternal ? "internal" : "public") + " static class Classes");
if (options.MinimizeNames)
WriteLine("#if DEBUG");
foreach (string c in classes)
{
string cc = Name.ToCamelCase(c);
WriteLine("public const string " + cc + " = \"" + c + "\";");
}
if (options.MinimizeNames)
{
WriteLine("#else");
foreach (string c in classes)
{
string cc = Name.ToCamelCase(c);
string co = ob.ObfuscateClass(c);
WriteLine("public const string " + cc + " = \"" + co + "\";");
}
WriteLine("#endif");
}
EndBracket();
}
示例5: Builder
public Builder(Options options, AppLocations appLocations, IBuilderEvent builderEvent)
: base(options, appLocations)
{
Counters = new List<string>();
traceListener = new BuilderEventListener(this);
BuilderEvent = builderEvent;
}
示例6: JsGlobal
public JsGlobal(ExecutionVisitor visitor, Options options)
{
this.Options = options;
this.Visitor = visitor;
this["null"] = JsNull.Instance;
#region Global Classes
this["Object"] = ObjectClass = new JsObjectConstructor(this);
this["Function"] = FunctionClass = new JsFunctionConstructor(this);
this["Array"] = ArrayClass = new JsArrayConstructor(this);
this["Boolean"] = BooleanClass = new JsBooleanConstructor(this);
this["Date"] = DateClass = new JsDateConstructor(this);
this["Error"] = ErrorClass = new JsErrorConstructor(this, "Error");
this["EvalError"] = EvalErrorClass = new JsErrorConstructor(this, "EvalError");
this["RangeError"] = RangeErrorClass = new JsErrorConstructor(this, "RangeError");
this["ReferenceError"] = ReferenceErrorClass = new JsErrorConstructor(this, "ReferenceError");
this["SyntaxError"] = SyntaxErrorClass = new JsErrorConstructor(this, "SyntaxError");
this["TypeError"] = TypeErrorClass = new JsErrorConstructor(this, "TypeError");
this["URIError"] = URIErrorClass = new JsErrorConstructor(this, "URIError");
this["Number"] = NumberClass = new JsNumberConstructor(this);
this["RegExp"] = RegExpClass = new JsRegExpConstructor(this);
this["String"] = StringClass = new JsStringConstructor(this);
this["Math"] = MathClass = new JsMathConstructor(this);
this.Prototype = ObjectClass.Prototype;
#endregion
MathClass.Prototype = ObjectClass.Prototype;
foreach (JsInstance c in this.GetValues())
{
if (c is JsConstructor)
{
((JsConstructor)c).InitPrototype(this);
}
}
#region Global Properties
this["NaN"] = NumberClass["NaN"]; // 15.1.1.1
this["Infinity"] = NumberClass["POSITIVE_INFINITY"]; // // 15.1.1.2
this["undefined"] = JsUndefined.Instance; // 15.1.1.3
this[JsInstance.THIS] = this;
#endregion
#region Global Functions
this["eval"] = new JsFunctionWrapper(Eval); // 15.1.2.1
this["parseInt"] = new JsFunctionWrapper(ParseInt); // 15.1.2.2
this["parseFloat"] = new JsFunctionWrapper(ParseFloat); // 15.1.2.3
this["isNaN"] = new JsFunctionWrapper(IsNaN);
this["isFinite"] = new JsFunctionWrapper(isFinite);
this["decodeURI"] = new JsFunctionWrapper(DecodeURI);
this["encodeURI"] = new JsFunctionWrapper(EncodeURI);
this["decodeURIComponent"] = new JsFunctionWrapper(DecodeURIComponent);
this["encodeURIComponent"] = new JsFunctionWrapper(EncodeURIComponent);
#endregion
}
示例7: Main
static int Main( string[] args )
{
var options = new Options();
var parser = new CommandLine.Parser( with => with.HelpWriter = Console.Error );
if ( parser.ParseArgumentsStrict( args, options, () => Environment.Exit( -2 ) ) )
{
if ( string.IsNullOrEmpty( options.PathToRockWeb ) )
{
string removeString = "Dev Tools\\Applications";
string currentDirectory = System.Reflection.Assembly.GetExecutingAssembly().Location;
int index = currentDirectory.IndexOf( removeString );
string rockDirectory = ( index < 0 )
? currentDirectory
: currentDirectory.Substring( 0, index );
options.PathToRockWeb = Path.Combine( rockDirectory, "RockWeb" );
}
if ( !Directory.Exists( options.PathToRockWeb ) )
{
Console.WriteLine( "Error: unable to find directory: " + options.PathToRockWeb );
return -1;
}
Run( options );
}
return 0;
}
示例8: Main
static void Main(string[] args)
{
var options = new Options();
var parser = new CommandLineParser(new CommandLineParserSettings(Console.Error));
try
{
if (!parser.ParseArguments(args, options))
{
Console.Read();
Environment.Exit(0);
}
}
catch (Exception ex)
{
errorPrompt("When parsing command line arguments an exception occurred:\n{0}", ex.Message);
}
if (options.writeMode)
{
writeDataMatrix(options);
Console.Read();
Environment.Exit(0);
}
if (options.readMode)
{
readDataMatrix(options);
Console.Read();
Environment.Exit(0);
}
}
示例9: ParsingInfo
private ParsingInfo(Options options, char initiator, char terminator, Func<string, Quantifier, IElement> parseToken)
{
this.options = options;
this.initiator = initiator;
this.terminator = terminator;
this.parseToken = parseToken;
}
示例10: Script
/// <summary>
/// Инициализирует объект типа Script и преобрзует код сценария во внутреннее представление.
/// </summary>
/// <param name="code">Код скрипта на языке JavaScript.</param>
/// <param name="parentContext">Родительский контекст для контекста выполнения сценария.</param>
/// <param name="messageCallback">Делегат обратного вызова, используемый для вывода сообщений компилятора</param>
public Script(string code, Context parentContext, CompilerMessageCallback messageCallback, Options options)
{
if (code == null)
throw new ArgumentNullException();
Code = code;
int i = 0;
root = CodeBlock.Parse(new ParsingState(Tools.RemoveComments(code, 0), Code, messageCallback), ref i).Statement;
if (i < code.Length)
throw new System.ArgumentException("Invalid char");
CompilerMessageCallback icallback = messageCallback != null ? (level, cord, message) =>
{
messageCallback(level, CodeCoordinates.FromTextPosition(code, cord.Column, cord.Length), message);
} : null as CompilerMessageCallback;
var stat = new FunctionStatistics();
Parser.Build(ref root, 0, new System.Collections.Generic.Dictionary<string, VariableDescriptor>(), _BuildState.None, icallback, stat, options);
var body = root as CodeBlock;
Context = new Context(parentContext ?? NiL.JS.Core.Context.globalContext, true, pseudoCaller);
Context.thisBind = new GlobalObject(Context);
Context.variables = (root as CodeBlock).variables;
Context.strict = (root as CodeBlock).strict;
for (i = body.localVariables.Length; i-- > 0; )
{
var f = Context.DefineVariable(body.localVariables[i].name);
body.localVariables[i].cacheRes = f;
body.localVariables[i].cacheContext = Context;
if (body.localVariables[i].Inititalizator != null)
f.Assign(body.localVariables[i].Inititalizator.Evaluate(Context));
if (body.localVariables[i].isReadOnly)
body.localVariables[i].cacheRes.attributes |= JSObjectAttributesInternal.ReadOnly;
body.localVariables[i].captured |= stat.ContainsEval;
}
var bd = body as CodeNode;
body.Optimize(ref bd, null, icallback, options, stat);
}
示例11: Save
/// <summary>
/// Save user settings for grammar and spelling checking.
/// </summary>
/// <param name="addin">A reference to the <code>XWikiAddin</code>.</param>
public static void Save(ref XWord2003AddIn addin)
{
wordOptions = addin.Application.Options;
checkGrammarAsYouType = wordOptions.CheckGrammarAsYouType;
checkGrammarWithSpelling = wordOptions.CheckGrammarWithSpelling;
checkSpellingAsYouType = wordOptions.CheckSpellingAsYouType;
}
示例12: Main
static int Main(string[] args)
{
_options = new Options();
CommandLineParser parser = new CommandLineParser(_options);
parser.Parse();
if (_options.Help)
{
Console.WriteLine(parser.UsageInfo.ToString(78, false));
return 0;
}
if (parser.HasErrors)
{
Console.WriteLine(parser.UsageInfo.ToString(78, true));
return -1;
}
if(_options.Test)
Test();
if (_options.TestString != null)
TestString();
else
RunDec0de();
return 0;
}
示例13: Main
static void Main(string[] args)
{
var options = new Options();
if (Parser.Default.ParseArguments(args, options))
{
if (!options.ConsoleIn && options.InputFile == null
|| !options.ConsoleOut && options.OutputFile == null)
{
Console.WriteLine(options.GetUsage());
return;
}
// consume Options instance properties
var inReader = options.ConsoleIn
? Console.In
: new StreamReader(options.InputFile);
using (var outWriter = options.ConsoleIn
? Console.Out
: new StreamWriter(options.OutputFile)
)
{
var xml = inReader.ReadToEnd();
var doc = XDocument.Parse(xml);
var md = doc.Root.ToMarkDown();
outWriter.Write(md);
outWriter.Close();
}
}
else
{
// Display the default usage information
Console.WriteLine(options.GetUsage());
}
}
示例14: Process
private int Process(CommandType command)
{
var options = new Options { DatabaseUrl = DatabaseUrl.Text, BaseDirectory = BaseDirectory.Text, Command = command };
var directoryPath = !string.IsNullOrWhiteSpace(options.BaseDirectory) ? options.BaseDirectory : Environment.CurrentDirectory;
var baseDirectory = new DirectoryInfo(directoryPath);
if (!baseDirectory.Exists)
{
MessageBox.Show(@"Provided directory {0} does not exist.", options.BaseDirectory);
return IncorrectOptionsReturnCode;
}
var password = Environment.GetEnvironmentVariable(PasswordEnvVar);
var url = new Lazy<Uri>(() => ParseDatabaseUrl(options));
try
{
ExecuteCommand(options.Command, baseDirectory, url, password);
}
catch (Exception e)
{
MessageBox.Show(e.ToString());
return UnknownErrorReturnCode;
}
return OkReturnCode;
}
示例15: PoResourceReader
public PoResourceReader(Stream stream, Options aOptions)
{
data = new Dictionary<string, PoItem>();
s = stream;
options = aOptions;
Load();
}