当前位置: 首页>>代码示例>>C#>>正文


C# System.Environment类代码示例

本文整理汇总了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);
 }
开发者ID:hsz-develop,项目名称:abeham--SimSharp,代码行数:7,代码来源:ConditionTest.cs

示例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"));
        }
开发者ID:loudej,项目名称:gato,代码行数:31,代码来源:EnvironmentTests.cs

示例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"));
        }
开发者ID:ArloL,项目名称:gate,代码行数:27,代码来源:EnvironmentTests.cs

示例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;
        }
开发者ID:KIZI,项目名称:sewebar-cms,代码行数:40,代码来源:LISpMiner.cs

示例5: EvalStep

 public override bool EvalStep(out object answer, ref Control expression, ref Environment environment)
 {
     #if DEBUG
     Warm ("PrimitiveIsCharEqA.EvalStep");
     #endif
     throw new NotImplementedException ();
 }
开发者ID:NotJRM,项目名称:jrm-code-project,代码行数:7,代码来源:PrimitiveIsCharEq.cs

示例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);
              }
        }
开发者ID:hsz-develop,项目名称:abeham--SimSharp,代码行数:26,代码来源:GasStationRefueling.cs

示例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);
 }
开发者ID:mikey179,项目名称:reference,代码行数:8,代码来源:Paths.cs

示例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;
            }
        }
开发者ID:skleanthous,项目名称:SuperSimple.MiniWebServer,代码行数:31,代码来源:DynamicControllerMiddleware.cs

示例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);
            }
              }
        }
开发者ID:hsz-develop,项目名称:abeham--SimSharp,代码行数:25,代码来源:BankRenege.cs

示例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"));
        }
开发者ID:bvanderveen,项目名称:gate,代码行数:27,代码来源:EnvironmentTests.cs

示例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;
        }
开发者ID:Impuls-Communicatie,项目名称:Ogone.NET,代码行数:32,代码来源:Request.cs

示例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;
        }
开发者ID:NotJRM,项目名称:jrm-code-project,代码行数:27,代码来源:PrimitiveIsEq.cs

示例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);
                }
            }
        }
开发者ID:ajmd17,项目名称:apexengine-sharp,代码行数:32,代码来源:NormalsShader.cs

示例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;
            }
        }
开发者ID:NotJRM,项目名称:jrm-code-project,代码行数:60,代码来源:PCondRecordRef.cs

示例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();
        }
开发者ID:Wiladams,项目名称:NewTOAPIA,代码行数:33,代码来源:Program.cs


注:本文中的System.Environment类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。