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


C# Collection.Reverse方法代码示例

本文整理汇总了C#中Collection.Reverse方法的典型用法代码示例。如果您正苦于以下问题:C# Collection.Reverse方法的具体用法?C# Collection.Reverse怎么用?C# Collection.Reverse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Collection的用法示例。


在下文中一共展示了Collection.Reverse方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SevenSegmentDisplay

        /// <summary>
        /// Construct a SevenSegment display from a list of LEDs.
        /// </summary>
        /// <param name="Leds">The list of LEDs to use</param>
        /// <param name="rightToLeftDigits">Whether the digits are right-to-left digits</param>
        public SevenSegmentDisplay(IList<Led> Leds, bool rightToLeftDigits = false) : base(Leds.Count/8, 1)
        {
            if (Leds.Count % 8 != 0)
                throw new ArgumentException("Leds should contain a multiple of 8 segments when using this constructor", "leds");

            int numDigits = Leds.Count / 8;

            digits = new Collection<SevenSegmentDigit>();

            for(int i=0;i<numDigits;i++)
            {
                var leds = Leds.Skip(i * 8).Take(8).ToList();
                var digit = new SevenSegmentDigit(leds);
                digits.Add(digit);
            }

            if (rightToLeftDigits)
                digits = digits.Reverse().ToList();

            setupDigits();
        }
开发者ID:treehopper-electronics,项目名称:treehopper-sdk,代码行数:26,代码来源:SevenSegmentDisplay.cs

示例2: Admin

        public Admin()
            : base("/admin")
        {
            CWSProtocol.Client c = new CWSProtocol.Client("AdminModule");
            IReadOnlyList<string> requiredClaims = new List<string> { Helper.Users.Authentication.ADMINISTRATOR };

            this.RequiresAuthentication();
            this.RequiresClaims(requiredClaims);

            Get["/"] = parameters =>
            {
                var message = Session.FirstOrDefault(o => o.Key == "toggleMessage");

                if (message.Key != null)
                {
                    Context.ViewBag["toggleMessage"] = message.Value;
                    Session.Delete("toggleMessage");
                }

                message = Session.FirstOrDefault(o => o.Key == "requiresDelay");
                Models.Admin.ControlPanel m = new Models.Admin.ControlPanel(null, false, true, 0, false, false, false);

                if (message.Key != null)
                {
                    Context.ViewBag["requiresDelay"] = true;
                    Session.Delete("requiresDelay");
                }
                else
                {
                    Collection<string> logEntries = new Collection<string>(c.GetLogMessages());
                    logEntries.Reverse();

                    Dictionary<string, object> watcherSettings = c.GetWatcherStatus();

                    if (watcherSettings != null)
                        m = new Models.Admin.ControlPanel(logEntries,
                            watcherSettings.ContainsKey("ENABLED") ? Boolean.Parse(watcherSettings["ENABLED"].ToString()) : false,
                            watcherSettings.ContainsKey("BLOCKED") ? Boolean.Parse(watcherSettings["BLOCKED"].ToString()) : false,
                            watcherSettings.ContainsKey("TIMEOUT") ? UInt32.Parse(watcherSettings["TIMEOUT"].ToString()) : 0,
                            watcherSettings.ContainsKey("CHECKINTERNET") ? Boolean.Parse(watcherSettings["CHECKINTERNET"].ToString()) : false,
                            watcherSettings.ContainsKey("CHECKLAN") ? Boolean.Parse(watcherSettings["CHECKLAN"].ToString()) : false,
                            watcherSettings.ContainsKey("CHECKLOOPBACK") ? Boolean.Parse(watcherSettings["CHECKLOOPBACK"].ToString()) : false);
                }

                return View["index.cshtml", m];
            };

            Get["/toggle/{action}"] = parameters =>
            {
                string action = parameters["action"].ToString();

                switch (action.ToLower())
                {
                    case "start":
                        c.SendStart();
                        Session["toggleMessage"] = "The server will now be started. Please refresh the page in a few seconds.";
                        Session["requiresDelay"] = true;
                        break;
                    case "stop":
                        c.SendStop();
                        Session["toggleMessage"] = "The server will now be stopped. Please refresh the page in a few seconds.";
                        Session["requiresDelay"] = true;
                        break;
                    case "restart":
                        c.SendRestart();
                        Session["toggleMessage"] = "The server will now be restarted. Please refresh the page in a few seconds.";
                        Session["requiresDelay"] = true;
                        break;
                    case "kill":
                        c.SendKill();
                        Session["toggleMessage"] = "The server will now be killed. Please refresh the page in a few seconds.";
                        Session["requiresDelay"] = true;
                        break;
                }
                Helper.CachedVariables.UpdateCachedVariables();
                return Response.AsRedirect("/admin");
            };

            Get["/statistics"] = parameters =>
            {
                return View["statistics.cshtml"];
            };

            Get["/log/clear"] = parameters =>
            {
                c.ClearLogMessage();
                return Response.AsRedirect("/admin");
            };

            Get["/watcher/{action}"] = parameters =>
            {
                string action = parameters["action"].ToString();
                switch (action.ToLower())
                {
                    case "start":
                        c.StartWatcher();
                        break;
                    case "stop":
                        c.StopWatcher();
                        break;
//.........这里部分代码省略.........
开发者ID:ChrisK91,项目名称:CWSRestart,代码行数:101,代码来源:Admin.cs


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