本文整理汇总了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();
}
示例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;
//.........这里部分代码省略.........