本文整理汇总了C#中System.Environment类的典型用法代码示例。如果您正苦于以下问题:C# Environment类的具体用法?C# Environment怎么用?C# Environment使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Environment类属于System命名空间,在下文中一共展示了Environment类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestAndConditionBlocked
public void TestAndConditionBlocked()
{
var env = new Environment();
env.Process(TestAndConditionBlockedProcess(env));
env.RunD(5);
Assert.AreEqual(5, env.NowD);
}
示例2: All_environment_variables_from_spec_are_available_as_typed_properties
public void All_environment_variables_from_spec_are_available_as_typed_properties()
{
var headers = new Dictionary<string, string>();
BodyDelegate body = (next, error, complete) => () => { };
var env = new Dictionary<string, object>
{
{"owin.RequestMethod", "GET"},
{"owin.RequestUri", "/foo"},
{"owin.RequestHeaders", headers},
{"owin.RequestBody", body},
{"owin.BaseUri", "/my-app"},
{"owin.ServerName", "localhost"},
{"owin.ServerPort", "8080"},
{"owin.UriScheme", "https"},
{"owin.RemoteEndPoint", new IPEndPoint(IPAddress.Parse("127.0.0.1") ?? IPAddress.None, 80)},
{"owin.Version", "1.0"},
};
var environment = new Environment(env);
Assert.That(environment.Method, Is.EqualTo("GET"));
Assert.That(environment.RequestUri, Is.EqualTo("/foo"));
Assert.That(environment.Headers, Is.SameAs(headers));
Assert.That(environment.Body, Is.SameAs(body));
Assert.That(environment.BaseUri, Is.EqualTo("/my-app"));
Assert.That(environment.ServerName, Is.EqualTo("localhost"));
Assert.That(environment.ServerPort, Is.EqualTo("8080"));
Assert.That(environment.UriScheme, Is.EqualTo("https"));
Assert.That(environment.RemoteEndPoint.ToString(), Is.EqualTo("127.0.0.1:80"));
Assert.That(environment.Version, Is.EqualTo("1.0"));
}
示例3: All_environment_variables_from_spec_are_available_as_typed_properties
public void All_environment_variables_from_spec_are_available_as_typed_properties()
{
var headers = new Dictionary<string, string[]>();
BodyDelegate body = (a, b, c) => { };
var env = new Dictionary<string, object>
{
{OwinConstants.RequestMethod, "GET"},
{OwinConstants.RequestPath, "/foo"},
{OwinConstants.RequestHeaders, headers},
{OwinConstants.RequestBody, body},
{OwinConstants.RequestPathBase, "/my-app"},
{OwinConstants.RequestQueryString, "hello=world"},
{OwinConstants.RequestScheme, "https"},
{OwinConstants.Version, "1.0"},
};
var environment = new Environment(env);
Assert.That(environment.Method, Is.EqualTo("GET"));
Assert.That(environment.Path, Is.EqualTo("/foo"));
Assert.That(environment.Headers, Is.SameAs(headers));
Assert.That(environment.BodyDelegate, Is.SameAs(body));
Assert.That(environment.PathBase, Is.EqualTo("/my-app"));
Assert.That(environment.QueryString, Is.EqualTo("hello=world"));
Assert.That(environment.Scheme, Is.EqualTo("https"));
Assert.That(environment.Version, Is.EqualTo("1.0"));
}
示例4: LISpMiner
/// <summary>
/// Creates instance of LISpMiner for existing location.
/// </summary>
/// <param name="lmpath">Path to LM folder.</param>
/// <param name="env">Environment settings.</param>
public LISpMiner(DirectoryInfo lmpath, Environment env)
{
if (!lmpath.Exists)
{
throw new Exception(String.Format("LISpMiner does not exist at location {0}", lmpath.FullName));
}
this.Environment = env;
this.Id = lmpath.Name.Substring("LISpMiner_".Length);
this.LMPrivatePath = lmpath.FullName;
this.SharedPool = !File.Exists(Path.Combine(this.LMPrivatePath, "LMTaskPooler.exe"));
string metabaseFile;
string devNull = string.Empty;
string metabaseDSNFile;
string databaseFile;
string databaseDSNFile;
this.GetDatabaseNames(string.Empty, out databaseFile, out databaseDSNFile);
if (File.Exists(databaseFile))
{
this.Database = new AccessConnection(databaseDSNFile, databaseFile, string.Empty);
}
else
{
this.Database = new MySQLConnection(databaseDSNFile);
}
this.GetMetabaseNames(out metabaseFile, ref devNull, out metabaseDSNFile);
this.Metabase = new AccessConnection(metabaseDSNFile, metabaseFile, string.Empty);
this.Created = lmpath.CreationTime;
}
示例5: EvalStep
public override bool EvalStep(out object answer, ref Control expression, ref Environment environment)
{
#if DEBUG
Warm ("PrimitiveIsCharEqA.EvalStep");
#endif
throw new NotImplementedException ();
}
示例6: Car
private IEnumerable<Event> Car(string name, Environment env, Resource gasStation, Container fuelPump)
{
/*
* A car arrives at the gas station for refueling.
*
* It requests one of the gas station's fuel pumps and tries to get the
* desired amount of gas from it. If the stations reservoir is
* depleted, the car has to wait for the tank truck to arrive.
*/
var fuelTankLevel = env.RandUniform(MinFuelTankLevel, MaxFuelTankLevel + 1);
env.Log("{0} arriving at gas station at {1}", name, env.Now);
using (var req = gasStation.Request()) {
var start = env.Now;
// Request one of the gas pumps
yield return req;
// Get the required amount of fuel
var litersRequired = FuelTankSize - fuelTankLevel;
yield return fuelPump.Get(litersRequired);
// The "actual" refueling process takes some time
yield return env.Timeout(TimeSpan.FromSeconds(litersRequired / RefuelingSpeed));
env.Log("{0} finished refueling in {1} seconds.", name, (env.Now - start).TotalSeconds);
}
}
示例7: Compose
/// <summary>Composes a path name of a special folder and a string component</summary>
public static string Compose(Environment.SpecialFolder special, params string[] components)
{
var args = new string[1 + components.Length];
args[0] = Environment.GetFolderPath(special);
Array.Copy(components, 0, args, 1, components.Length);
return Compose(args);
}
示例8: Invoke
public async Task<MiddlewareInvocationEnum> Invoke(Environment environment)
{
string[] setReplyHeader;
bool shouldSetReply = false;
if (environment.RequestHeaders.TryGetValue(SET_REPLY_HEADER_NAME, out setReplyHeader)
&& !string.IsNullOrWhiteSpace(setReplyHeader[0])
&& bool.TryParse(setReplyHeader[0], out shouldSetReply)
&& shouldSetReply)
{
Replies[environment.RequestPath] = await ReadAllBytes(environment.RequestBody);
return MiddlewareInvocationEnum.StopChain;
}
else
{
byte[] data;
if (Replies.TryGetValue(environment.RequestPath, out data))
{
await environment.ResponseBody.WriteAsync(data, 0, data.Length);
environment.ResponseHeaders.ContentLength = data.Length;
environment.ResponseHeaders.ContentType = "application/json";
return MiddlewareInvocationEnum.StopChain;
}
else
return MiddlewareInvocationEnum.ContinueToNext;
}
}
示例9: Customer
private IEnumerable<Event> Customer(Environment env, string name, Resource counter, TimeSpan meanTimeInBank)
{
var arrive = env.Now;
env.Log("{0} {1}: Here I am", arrive, name);
using (var req = counter.Request()) {
// Wait for the counter or abort at the end of our tether
var timeout = env.TimeoutUniform(MinPatience, MaxPatience);
yield return req | timeout;
var wait = env.Now - arrive;
if (req.IsProcessed) {
// We got the counter
env.Log("{0} {1}: waited {2}", env.Now, name, wait);
yield return env.TimeoutExponential(meanTimeInBank);
env.Log("{0} {1}: Finished", env.Now, name);
} else {
// We reneged
env.Log("{0} {1}: RENEGED after {2}", env.Now, name, wait);
}
}
}
示例10: All_environment_variables_from_spec_are_available_as_typed_properties
public void All_environment_variables_from_spec_are_available_as_typed_properties()
{
var headers = new Dictionary<string, string>();
var body = new BodyDelegate((next, error, complete) => () => { }).ToAction();
var env = new Dictionary<string, object>
{
{"owin.RequestMethod", "GET"},
{"owin.RequestPath", "/foo"},
{"owin.RequestHeaders", headers},
{"owin.RequestBody", body},
{"owin.RequestPathBase", "/my-app"},
{"owin.RequestQueryString", "hello=world"},
{"owin.RequestScheme", "https"},
{"owin.Version", "1.0"},
};
var environment = new Environment(env);
Assert.That(environment.Method, Is.EqualTo("GET"));
Assert.That(environment.Path, Is.EqualTo("/foo"));
Assert.That(environment.Headers, Is.SameAs(headers));
Assert.That(environment.Body, Is.SameAs(body));
Assert.That(environment.PathBase, Is.EqualTo("/my-app"));
Assert.That(environment.QueryString, Is.EqualTo("hello=world"));
Assert.That(environment.Scheme, Is.EqualTo("https"));
Assert.That(environment.Version, Is.EqualTo("1.0"));
}
示例11: Request
public Request(SHA sha, string shaInSignature, string pspID, int orderID, decimal price, Encoding encoding, Environment environment)
{
if (string.IsNullOrWhiteSpace(shaInSignature))
{
throw new ArgumentException("SHA-IN is required");
}
if (string.IsNullOrWhiteSpace(pspID))
{
throw new ArgumentException("PSPID is required");
}
if (orderID < 1)
{
throw new ArgumentException("Invalid Order ID");
}
if (price <= 0)
{
throw new ArgumentException("Invalid price");
}
this._sha = sha;
this._shaInSignature = shaInSignature;
this._pspID = pspID;
this._orderID = orderID;
this._price = price;
extrafields = new Dictionary<InFields, string>();
this.Encoding = encoding;
this.Environment = environment;
}
示例12: EvalStep
public override bool EvalStep(out object answer, ref Control expression, ref Environment environment)
{
#if DEBUG
Warm ("-");
NoteCalls (this.rand1);
rand1TypeHistogram.Note (this.rand1Type);
SCode.location = "PrimitiveIsCharEqQ";
#endif
// Eval argument1
object ev1;
Control unev = this.rand1;
Environment env = environment;
while (unev.EvalStep (out ev1, ref unev, ref env)) { };
if (ev1 == Interpreter.UnwindStack) {
throw new NotImplementedException ();
//((UnwinderState) env).AddFrame (new PrimitiveCombination2Frame0 (this, environment));
//answer = Interpreter.UnwindStack;
//environment = env;
//return false;
}
//bool x = (ev1 is char);
//bool y = (ev1 is Character);
//if (x != y) Debugger.Break ();
answer = ((ev1 is char) && (this.rand0Value == (char) ev1)) ? Constant.sharpT : Constant.sharpF;
return false;
}
示例13: Update
public override void Update(Environment environment, Camera cam, Mesh mesh)
{
base.Update(environment, cam, mesh);
if (currentMaterial != null)
{
Texture diffuseTex = currentMaterial.GetTexture(Material.TEXTURE_DIFFUSE);
if (diffuseTex != null)
{
Texture.ActiveTextureSlot(0);
diffuseTex.Use();
SetUniform("Material_DiffuseMap", 0);
SetUniform("Material_HasDiffuseMap", 1);
}
else
{
SetUniform("Material_HasDiffuseMap", 0);
}
Texture normalTex = currentMaterial.GetTexture(Material.TEXTURE_NORMAL);
if (normalTex != null)
{
Texture.ActiveTextureSlot(1);
normalTex.Use();
SetUniform("Material_NormalMap", 1);
SetUniform("Material_HasNormalMap", 1);
}
else
{
SetUniform("Material_HasNormalMap", 0);
}
}
}
示例14: EvalStep
public override bool EvalStep(out object answer, ref Control expression, ref Environment environment)
{
#if DEBUG
Warm ("-");
NoteCalls (this.rand0);
NoteCalls (this.rand1);
rand0TypeHistogram.Note (this.rand0Type);
rand1TypeHistogram.Note (this.rand1Type);
SCode.location = "PCondRecordRef";
#endif
Control unev = this.rand1;
Environment env = environment;
object ev1;
while (unev.EvalStep (out ev1, ref unev, ref env)) { };
#if DEBUG
SCode.location = "PCondRecordRef";
#endif
if (ev1 == Interpreter.UnwindStack) {
throw new NotImplementedException ();
}
unev = this.rand0;
env = environment;
object ev0;
while (unev.EvalStep (out ev0, ref unev, ref env)) { };
#if DEBUG
SCode.location = "PCondRecordRef";
#endif
if (ev0 == Interpreter.UnwindStack) {
throw new NotImplementedException ();
//((UnwinderState) env).AddFrame (new PrimitiveCombination1Frame0 (this, environment));
//answer = Interpreter.UnwindStack;
//environment = env;
//return false;
}
object result = ((Record) ev0).Ref ((int) ev1);
if (result is Boolean && (((bool) result) == false)) {
#if DEBUG
SCode.location = "-";
NoteCalls (this.alternative);
alternativeTypeHistogram.Note (this.alternativeType);
SCode.location = "PCondRecordRef";
#endif
expression = this.alternative;
answer = null;
return true;
} else {
#if DEBUG
SCode.location = "-";
NoteCalls (this.consequent);
consequentTypeHistogram.Note (this.consequentType);
SCode.location = "PCondRecordRef";
#endif
expression = this.consequent;
answer = null;
return true;
}
}
示例15: Main
public static void Main(string[] args)
{
// Change the console window
Terminal term = new Terminal();
term.Title = "Terminal Window Title";
term.DisplayMode = (int)ConsoleDisplayModeForSet.CONSOLE_FULLSCREEN_MODE;
//Console.WriteLine("Terminal Title: {0}", term.Title);
term.WriteLine("Terminal Window Title - has been set");
COORD fontSize = term.FontSize;
Console.WriteLine("Terminal Font Size: X = {0}, Y = {1}", fontSize.X, fontSize.Y);
Console.WriteLine("mouse buttons: {0}", term.MouseButtons);
// Instantiate a machine
Machine aMachine = new Machine();
// Print some properties
Console.WriteLine("Name: {0}", aMachine.ShortName);
Console.WriteLine("Domain: {0}", aMachine.DomainName);
Environment environ = new Environment();
Console.WriteLine("Command Line: {0}", environ.CommandLine);
// Get the name of the process image that this process is running
//Process aProc = new Process();
//PrintProcess(aProc);
//PrintAllProcesses();
PrintAllDrives();
//PrintVolumes();
Console.ReadLine();
}