本文整理汇总了C#中SortableCollection.Add方法的典型用法代码示例。如果您正苦于以下问题:C# SortableCollection.Add方法的具体用法?C# SortableCollection.Add怎么用?C# SortableCollection.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SortableCollection
的用法示例。
在下文中一共展示了SortableCollection.Add方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
private static void Main()
{
ISortableCollection<Item> sortableCollection = new SortableCollection<Item>();
//new[]
//{
// new Item(12),
// new Item(34),
// new Item(12),
// new Item(3.5),
// new Item(4.7),
// new Item(0.67)
//});
//sortableCollection.AddRange(new[]
//{
// new Item(45),
// new Item(5.6),
// new Item(12.5),
// new Item(1.2),
// new Item(340),
// new Item(155),
// new Item(30.5),
// new Item(4.76),
// new Item(0.174)
//});
Random random = new Random();
Enumerable.Range(0, 1000).ToList().ForEach(e => sortableCollection.Add(new Item(random.Next(e) * random.NextDouble())));
ISortableCollection<Item> collection1 = sortableCollection.Clone();
ISortableCollection<Item> collection2 = sortableCollection.Clone();
ISortableCollection<Item> collection3 = sortableCollection.Clone();
collection1.Remove(collection1[0]);
collection2.RemoveAt(collection2.Count - 1);
SortAlgorithm<Item> selectionSort = new SelectionSort<Item>();
SortAlgorithm<Item> shakeSort = new ShakeSort<Item>();
SortAlgorithm<Item> heapSort = new HeapSort<Item>();
selectionSort.Sort(collection1);
shakeSort.Sort(collection2);
heapSort.Sort(collection3);
Console.WriteLine(selectionSort);
Console.WriteLine(shakeSort);
Console.WriteLine(heapSort);
Console.ReadKey();
}
示例2: LoadLists
private void LoadLists()
{
List<FraudRule> rules = repository.FindForStore(MTApp.CurrentStore.Id);
SortableCollection<FraudRule> emailRules = new SortableCollection<FraudRule>();
SortableCollection<FraudRule> domainRules = new SortableCollection<FraudRule>();
SortableCollection<FraudRule> ipRules = new SortableCollection<FraudRule>();
SortableCollection<FraudRule> PHrules = new SortableCollection<FraudRule>();
SortableCollection<FraudRule> CCrules = new SortableCollection<FraudRule>();
for (int i = 0; i <= rules.Count - 1; i++)
{
switch (rules[i].RuleType)
{
case FraudRuleType.DomainName:
domainRules.Add(rules[i]);
break;
case FraudRuleType.EmailAddress:
emailRules.Add(rules[i]);
break;
case FraudRuleType.IPAddress:
ipRules.Add(rules[i]);
break;
case FraudRuleType.PhoneNumber:
PHrules.Add(rules[i]);
break;
case FraudRuleType.CreditCardNumber:
CCrules.Add(rules[i]);
break;
}
}
emailRules.Sort("RuleValue");
domainRules.Sort("RuleValue");
ipRules.Sort("RuleValue");
PHrules.Sort("RuleValue");
CCrules.Sort("RuleValue");
this.lstEmail.DataSource = emailRules;
this.lstEmail.DataTextField = "RuleValue";
this.lstEmail.DataValueField = "Bvin";
this.lstEmail.DataBind();
this.lstDomain.DataTextField = "RuleValue";
this.lstDomain.DataValueField = "Bvin";
this.lstDomain.DataSource = domainRules;
this.lstDomain.DataBind();
this.lstIP.DataTextField = "RuleValue";
this.lstIP.DataValueField = "Bvin";
this.lstIP.DataSource = ipRules;
this.lstIP.DataBind();
this.lstPhoneNumber.DataTextField = "RuleValue";
this.lstPhoneNumber.DataValueField = "Bvin";
this.lstPhoneNumber.DataSource = PHrules;
this.lstPhoneNumber.DataBind();
this.lstCreditCard.DataTextField = "RuleValue";
this.lstCreditCard.DataValueField = "Bvin";
this.lstCreditCard.DataSource = CCrules;
this.lstCreditCard.DataBind();
this.EmailField.Text = "";
this.DomainField.Text = "";
this.IPField.Text = "";
this.PhoneNumberField.Text = "";
this.CreditCardField.Text = "";
}
示例3: LoadShippingMethods
private void LoadShippingMethods(Order o)
{
SortableCollection<ShippingRateDisplay> Rates = new SortableCollection<ShippingRateDisplay>();
if (o.HasShippingItems == false)
{
ShippingRateDisplay r = new ShippingRateDisplay();
r.DisplayName = SiteTerms.GetTerm(SiteTermIds.NoShippingRequired);
r.ProviderId = "";
r.ProviderServiceCode = "";
r.Rate = 0;
r.ShippingMethodId = "NOSHIPPING";
Rates.Add(r);
}
else
{
// Shipping Methods
Rates = MTApp.OrderServices.FindAvailableShippingRates(o, MTApp.CurrentStore);
if ((Rates.Count < 1))
{
ShippingRateDisplay result = new ShippingRateDisplay();
result.DisplayName = "Shipping can not be calculated at this time. We will contact you after receiving your order with the exact shipping charges.";
result.ShippingMethodId = "TOBEDETERMINED";
result.Rate = 0;
Rates.Add(result);
}
}
this.litShippingMethods.Text = MerchantTribe.Commerce.Utilities.HtmlRendering.ShippingRatesToRadioButtons(Rates, 300, o.ShippingMethodUniqueKey);
}