本文整理汇总了C#中SortOption类的典型用法代码示例。如果您正苦于以下问题:C# SortOption类的具体用法?C# SortOption怎么用?C# SortOption使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SortOption类属于命名空间,在下文中一共展示了SortOption类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BindModel
/// <summary>
/// MVC Model Binder for automatically binding the request parameters for a PagedList sort to an instance of
/// SortOption
/// </summary>
/// <param name="controllerContext"></param>
/// <param name="bindingContext"></param>
/// <returns></returns>
/// <example>public ActionResult Index(int? page, [ModelBinder(typeof(PagedListBinder))] SortOption? sort)</example>
/// <see cref="SortOption"/>
public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
{
//Does the request contain the minimum parameters for sortng a PagedList?
if (!String.IsNullOrEmpty((string)controllerContext.HttpContext.Request.Params["Column"]))
{
//Yup -
SortOption sort = new SortOption();
sort.Column = controllerContext.HttpContext.Request.Params["Column"];
if (Enum.IsDefined(typeof(SortOrder), controllerContext.HttpContext.Request.Params["Direction"]))
{
Enum.TryParse<SortOrder>(controllerContext.HttpContext.Request.Params["Direction"], out sort.Direction);
}
else
{
sort.Direction = SortOrder.ascending;
}
return sort;
}
else
{
//Nothing to bind to
return null;
}
}
示例2: Files
public static IEnumerable<string> Files(string directory, string pattern = "*.*", SearchOption searchOption = SearchOption.TopDirectoryOnly, SortOption sortOption = SortOption.Ascending)
{
var q = zDirectory.EnumerateFiles(directory, pattern, searchOption);
if (sortOption == SortOption.Ascending)
return q;
else
return q.OrderByDescending(file => file);
}
示例3: ListAsDataTable
public System.Data.DataTable ListAsDataTable(int BranchID = 0, long ProductID = 0, long MatrixID =0, string BarCode = "", string ProductCode = "", Int64 ProductGroupID = 0, Int64 ProductSubGroupID = 0, Int64 SupplierID = 0, ProductListFilterType clsProductListFilterType = ProductListFilterType.ShowActiveAndInactive,
bool isQuantityGreaterThanZERO = false, Int32 Limit = 0, Int32 isSummary = 1, string ExpirationDate = Constants.C_DATE_MIN_VALUE_STRING, Int32 ForReorder = 0, Int32 OverStock = 0, string SortField = "", SortOption SortOrder = SortOption.Ascending, bool ShowOnlyWithInvalidUnitMatrix = false)
{
try
{
DateTime dteExpiration = Constants.C_DATE_MIN_VALUE;
DateTime.TryParse(ExpirationDate, out dteExpiration);
string SQL = "CALL procProductInventorySelect(@BranchID, @ProductID, @MatrixID, @BarCode, @ProductCode, @ProductGroupID, @ProductSubGroupID, @SupplierID, @ShowActiveAndInactive, @isQuantityGreaterThanZERO, @lngLimit, @isSummary, @dteExpiration, @ForReorder, @OverStock, @SortField, @SortOrder)";
// do an override if Only those with invalid unit matrix
if (ShowOnlyWithInvalidUnitMatrix)
SQL = "CALL procProductInventorySelectWithInvalidUnitMatrix(@BranchID, @ProductID, @MatrixID, @BarCode, @ProductCode, @ProductGroupID, @ProductSubGroupID, @SupplierID, @ShowActiveAndInactive, @isQuantityGreaterThanZERO, @lngLimit, @isSummary, @dteExpiration, @ForReorder, @OverStock, @SortField, @SortOrder)";
MySqlCommand cmd = new MySqlCommand();
cmd.CommandType = System.Data.CommandType.Text;
cmd.CommandText = SQL;
cmd.Parameters.AddWithValue("@BranchID", BranchID);
cmd.Parameters.AddWithValue("@ProductID", ProductID);
cmd.Parameters.AddWithValue("@MatrixID", MatrixID);
cmd.Parameters.AddWithValue("@BarCode", BarCode);
cmd.Parameters.AddWithValue("@ProductCode", ProductCode);
cmd.Parameters.AddWithValue("@ProductGroupID", ProductGroupID);
cmd.Parameters.AddWithValue("@ProductSubGroupID", ProductSubGroupID);
cmd.Parameters.AddWithValue("@SupplierID", SupplierID);
cmd.Parameters.AddWithValue("@ShowActiveAndInactive", clsProductListFilterType.ToString("d"));
cmd.Parameters.AddWithValue("@isQuantityGreaterThanZERO", isQuantityGreaterThanZERO);
cmd.Parameters.AddWithValue("@lngLimit", Limit);
cmd.Parameters.AddWithValue("@isSummary", isSummary);
cmd.Parameters.AddWithValue("@dteExpiration", dteExpiration.ToString("yyyy-MM-dd"));
cmd.Parameters.AddWithValue("@ForReorder", ForReorder);
cmd.Parameters.AddWithValue("@OverStock", OverStock);
cmd.Parameters.AddWithValue("@SortField", SortField);
switch (SortOrder)
{
case SortOption.Ascending:
cmd.Parameters.AddWithValue("@SortOrder", "ASC");
break;
case SortOption.Desscending:
cmd.Parameters.AddWithValue("@SortOrder", "DESC");
break;
}
string strDataTableName = "tbl" + this.GetType().FullName.Split(new Char[] { '.' })[this.GetType().FullName.Split(new Char[] { '.' }).Length - 1]; System.Data.DataTable dt = new System.Data.DataTable(strDataTableName);
base.MySqlDataAdapterFill(cmd, dt);
return dt;
}
catch (Exception)
{
throw;
}
}
示例4: Sort
protected override void Sort(Tab tab, SortOption options)
{
if (options["Default"])
{
sortJewls(tab, 11);
}
if (options["Dynamic"])
{
int numberOfColumns = (int)Math.Ceiling(tab.Items.Count() / 12f);
sortJewls(tab, numberOfColumns);
}
}
示例5: Build
private static object Build(SortOption sortOption)
{
if (!sortOption.IgnoreUnmapped)
return sortOption.Ascending
? (object)sortOption.Name
: new JObject(new JProperty(sortOption.Name, "desc"));
var properties = new List<JProperty> { new JProperty("ignore_unmapped", true) };
if (!sortOption.Ascending)
properties.Add(new JProperty("order", "desc"));
return new JObject(new JProperty(sortOption.Name, new JObject(properties)));
}
示例6: Sort
protected override void Sort(Tab tab, SortOption options)
{
int numberOfColumns = (int)Math.Ceiling(tab.Items.Count() / 12f);
if (options["Default"])
{
numberOfColumns = 11;
sortMaps(tab, numberOfColumns);
}
if (options["Full"])
{
numberOfColumns = 12;
sortMaps(tab, numberOfColumns);
}
if (options["1 Margin"])
{
if (numberOfColumns <= 11)
numberOfColumns = 11;
sortMaps(tab, numberOfColumns);
}
if (options["2 Margin"])
{
if (numberOfColumns <= 10)
numberOfColumns = 10;
sortMaps(tab, numberOfColumns);
}
if (options["3 Margin"])
{
if (numberOfColumns <= 9)
numberOfColumns = 9;
sortMaps(tab, numberOfColumns);
}
if (options["Dynamic"])
{
numberOfColumns = (int)Math.Ceiling(tab.Items.Count() / 12f);
sortMaps(tab, numberOfColumns);
}
if (options["Dynamic + 1"])
{
numberOfColumns = (int)Math.Ceiling(tab.Items.Count() / 12f) + 1;
numberOfColumns = Mathf.Clamp(numberOfColumns, 0, 11);
sortMaps(tab, numberOfColumns);
}
if (options["Dynamic + 2"])
{
numberOfColumns = (int)Math.Ceiling(tab.Items.Count() / 12f) + 2;
numberOfColumns = Mathf.Clamp(numberOfColumns, 0, 11);
sortMaps(tab, numberOfColumns);
}
}
示例7: Sort
protected override void Sort(Tab tab, SortOption options)
{
IEnumerable<Item> gems = tab.Items;
if (options["Sort by color then type"])
{
SortEm(
gems.Where(x => x.GemRequirement == GemRequirement.Str).OrderByDescending(x => x.GemType).ThenBy(x => x.FullItemName).ThenBy(x => x.Level),
gems.Where(x => x.GemRequirement == GemRequirement.Dex).OrderByDescending(x => x.GemType).ThenBy(x => x.FullItemName).ThenBy(x => x.Level),
gems.Where(x => x.GemRequirement == GemRequirement.Int).OrderByDescending(x => x.GemType).ThenBy(x => x.FullItemName).ThenBy(x => x.Level)
);
}
else if (options["Sort by type"])
{
SortEm(
gems.Where(x => x.GemType == GemType.Normal).OrderByDescending(x => x.FullItemName).ThenBy(x => x.LevelRequirement),
gems.Where(x => x.GemType == GemType.Support).OrderByDescending(x => x.FullItemName).ThenBy(x => x.LevelRequirement),
gems.Where(x => x.GemType == GemType.Aura).OrderByDescending(x => x.FullItemName).ThenBy(x => x.LevelRequirement)
);
}
else if (options["Sort by quality"])
{
SortEm(
gems.Where(x => x.GemRequirement == GemRequirement.Str).OrderByDescending(x => x.Quality).ThenBy(x => x.FullItemName),
gems.Where(x => x.GemRequirement == GemRequirement.Dex).OrderByDescending(x => x.Quality).ThenBy(x => x.FullItemName),
gems.Where(x => x.GemRequirement == GemRequirement.Int).OrderByDescending(x => x.Quality).ThenBy(x => x.FullItemName)
);
}
else if (options["Find quality gems"])
{
SortEm(
gems.Where(x => x.Quality == 0).OrderByDescending(x => x.GemRequirement).ThenBy(x => x.GemType).ThenBy(x => x.FullItemName),
gems.Where(x => x.LevelRequirement > 99999), // No middle
gems.Where(x => x.Quality > 0).OrderByDescending(x => x.Quality).ThenBy(x => x.FullItemName)
);
}
else if (options["Sort by color then level"])
{
SortEm(
gems.Where(x => x.GemRequirement == GemRequirement.Str).OrderByDescending(x => x.Level).ThenBy(x => x.Quality),
gems.Where(x => x.GemRequirement == GemRequirement.Dex).OrderByDescending(x => x.GemType).ThenBy(x => x.Quality),
gems.Where(x => x.GemRequirement == GemRequirement.Int).OrderByDescending(x => x.GemType).ThenBy(x => x.Quality)
);
}
else if (options["Sort by level"])
{
SortFromBottom(gems.OrderByDescending(x => x.LevelRequirement));
}
}
示例8: Sort
protected override void Sort(Tab tab, SortOption options)
{
int numberOfColumns = (int)Math.Ceiling(tab.Items.Count() / 12f);
int numberOfItems = tab.Items.Count();
if (options["Default"])
{
numberOfColumns = 12;
}
if (options["1 Margin"])
{
if (numberOfColumns <= 11)
numberOfColumns = 11;
}
if (options["2 Margin"])
{
if (numberOfColumns <= 10)
numberOfColumns = 10;
}
if (options["Dynamic"])
{
numberOfColumns = (int)Math.Ceiling(tab.Items.Count() / 12f);
}
int x = 11;
int y = 11;
int i = 0;
int lastLevel = 0;
bool maySkip = true;
foreach (var item in tab.Items.OrderByDescending(xx => xx.Level).ThenBy(xx => xx.Icon).ThenBy(xx => xx.Quality))
{
item.X = x;
item.Y = y;
i++;
x--;
bool canSkip = (lastLevel != item.Level && (numberOfItems - i) < numberOfColumns * y);
if (maySkip && lastLevel != item.Level && ((numberOfItems - i) < numberOfColumns * y) == false)
maySkip = false;
if (x == 11 - numberOfColumns || canSkip && maySkip)
{
x = 11;
y--;
}
lastLevel = item.Level;
}
}
示例9: GetTasks
public static IEnumerable<TaskModel> GetTasks(SortOption sortOption)
{
switch (sortOption)
{
case SortOption.Newest:
return DataLayer.TaskDatabase.GetItems<TaskModel>().OrderByDescending(t=>t.DateCreated);
case SortOption.Oldest:
return DataLayer.TaskDatabase.GetItems<TaskModel>().OrderBy(t => t.DateCreated);
case SortOption.TitleAscending:
return DataLayer.TaskDatabase.GetItems<TaskModel>().OrderBy(t => t.Task);
case SortOption.TitleDescending:
return DataLayer.TaskDatabase.GetItems<TaskModel>().OrderByDescending(t => t.Task);
}
return DataLayer.TaskDatabase.GetItems<TaskModel>().OrderBy(t => t.DateCreated);
}
示例10: GetCurrentState
public static StatData[] GetCurrentState(SortOption sortOption, int pageNumber, int pageSize)
{
var startPosition = pageSize*pageNumber;
switch (sortOption)
{
case SortOption.None:
return KeywordsDictionary.Skip(startPosition).Take(pageSize).Select(kvp => new StatData(kvp.Key, kvp.Value)).ToArray();
case SortOption.Keyword:
return KeywordsDictionary.OrderBy(pair => pair.Key).Skip(startPosition).Take(pageSize).Select(kvp => new StatData(kvp.Key, kvp.Value)).ToArray();
case SortOption.KeywordDecrease:
return KeywordsDictionary.OrderByDescending(pair => pair.Key).Skip(startPosition).Take(pageSize).Select(kvp => new StatData(kvp.Key, kvp.Value)).ToArray();
case SortOption.KeywordCount:
return KeywordsDictionary.OrderBy(pair => pair.Value).Skip(startPosition).Take(pageSize).Select(kvp => new StatData(kvp.Key, kvp.Value)).ToArray();
case SortOption.KeywordCountDecrease:
return KeywordsDictionary.OrderByDescending(pair => pair.Value).Skip(startPosition).Take(pageSize).Select(kvp => new StatData(kvp.Key, kvp.Value)).ToArray();
}
return new StatData[0];
}
示例11: List
public MySqlDataReader List(string SortField, SortOption SortOrder)
{
try
{
string SQL = SQLSelect() + "WHERE 1=1 ORDER BY " + SortField;
if (SortOrder == SortOption.Ascending)
SQL += " ASC";
else
SQL += " DESC";
MySqlCommand cmd = new MySqlCommand();
cmd.CommandType = System.Data.CommandType.Text;
cmd.CommandText = SQL;
return base.ExecuteReader(cmd);
}
catch (Exception ex)
{
{
}
throw base.ThrowException(ex);
}
}
示例12: ListAccessTypes
private MySqlDataReader ListAccessTypes(string SortField, SortOption SortOrder)
{
try
{
string SQL = "SELECT TypeID, TypeName, Remarks " +
"FROM sysAccessTypes " +
"ORDER BY " + SortField;
if (SortOrder == SortOption.Ascending)
SQL += " ASC";
else
SQL += " DESC";
MySqlCommand cmd = new MySqlCommand();
cmd.CommandType = System.Data.CommandType.Text;
cmd.CommandText = SQL;
return base.ExecuteReader(cmd);
}
catch (Exception ex)
{
throw base.ThrowException(ex);
}
}
示例13: ListAsDataTable
public System.Data.DataTable ListAsDataTable(Int64 MatrixID, string SortField, SortOption SortOrder)
{
try
{
string SQL = SQLSelect() + "WHERE 1=1 AND a.MatrixID = @MatrixID ORDER BY " + SortField;
if (SortOrder == SortOption.Ascending)
SQL += " ASC";
else
SQL += " DESC";
MySqlCommand cmd = new MySqlCommand();
cmd.Connection = GetConnection();
cmd.CommandType = System.Data.CommandType.Text;
cmd.CommandText = SQL;
cmd.Parameters.AddWithValue("@MatrixID", MatrixID);
string strDataTableName = "tbl" + this.GetType().FullName.Split(new Char[] { '.' })[this.GetType().FullName.Split(new Char[] { '.' }).Length - 1]; System.Data.DataTable dt = new System.Data.DataTable(strDataTableName);
base.MySqlDataAdapterFill(cmd, dt);
return dt;
}
catch (Exception ex)
{
{
}
throw base.ThrowException(ex);
}
}
示例14: ListAsDataTable
public System.Data.DataTable ListAsDataTable(SalesTransactionDetails clsSearchKey, bool WithTF = false, string SortField = "", SortOption SortOption = SortOption.Ascending, Int32 limit = 0)
{
try
{
return ListAsDataTable(clsSearchKey.BranchID, clsSearchKey.TerminalNo, clsSearchKey.TransactionID, clsSearchKey.TransactionNo, clsSearchKey.TransactionDateFrom, clsSearchKey.TransactionDateTo, clsSearchKey.TransactionStatus, clsSearchKey.PaymentType, clsSearchKey.isConsignment, false, clsSearchKey.CustomerName, clsSearchKey.CustomerGroupName, clsSearchKey.CashierID, clsSearchKey.CashierName, clsSearchKey.AgentName, WithTF, false, SortField, SortOption, limit); ;
}
catch (Exception ex)
{
throw base.ThrowException(ex);
}
}
示例15: ListClosedDataTable
public System.Data.DataTable ListClosedDataTable(Int32 BranchID, DateTime? TransactionDateFrom = null, DateTime? TransactionDateTo = null, string SortField = "TransactionDate", SortOption SortOrder = SortOption.Ascending, Int32 limit = 0)
{
try
{
return ListAsDataTable(BranchID, TransactionDateFrom: TransactionDateFrom, TransactionDateTo: TransactionDateTo, TransactionStatus: TransactionStatus.Closed, SortField: SortField, SortOption: SortOrder, limit: limit);
}
catch (Exception ex)
{
throw base.ThrowException(ex);
}
}