本文整理汇总了C#中ICollection.ElementAtOrDefault方法的典型用法代码示例。如果您正苦于以下问题:C# ICollection.ElementAtOrDefault方法的具体用法?C# ICollection.ElementAtOrDefault怎么用?C# ICollection.ElementAtOrDefault使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICollection
的用法示例。
在下文中一共展示了ICollection.ElementAtOrDefault方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RoundRobinOffer
protected void RoundRobinOffer(ICollection<OfferUtility> offers, TimeSpan remainingTime)
{
CompareOffer(OpponentOffer, false);
int roundPart = (int)(Domain.RoundLength.TotalSeconds / offers.Count);
int offerIndex =
Math.Min(
offers.Count - 1,
(Math.Max(0,(int)remainingTime.TotalSeconds-1) / roundPart) % offers.Count
);
NegotiationOffer offer = offers.ElementAtOrDefault(offerIndex).Offer;
SendOffer(offer, false);
}
示例2: ProcessUninstallBundles
private static void ProcessUninstallBundles(Primitives ip, ICollection<Bundle> Bundles)
{
// Uninstall only VS selected items
var pos = 0;
var selectedbundle = Bundles.ElementAtOrDefault(pos);
Logger.Log(String.Format(CultureInfo.InvariantCulture, "-Bundle uninstall started."), Logger.MessageLevel.Verbose, AppName);
var bundleexitcode = 0;
while ((selectedbundle != null) && (bundleexitcode == 0) && (pos <= (Bundles.Count() - 1)))
{
Logger.Log(String.Format(CultureInfo.InvariantCulture, "--Bundle uninstall [{0}]", selectedbundle.Name), Logger.MessageLevel.Verbose, AppName);
// Is the bundle installed
if (selectedbundle.Installed)
{
Console.WriteLine(String.Format(CultureInfo.InvariantCulture, "Initiating uninstall: {0}", selectedbundle.Name));
bundleexitcode = ip.Uninstall(selectedbundle);
}
pos++;
selectedbundle = Bundles.ElementAtOrDefault(pos);
}
Logger.Log(String.Format(CultureInfo.InvariantCulture, "Bundle uninstall completed"), Logger.MessageLevel.Verbose, AppName);
switch (bundleexitcode)
{
// Reboot error codes from bundle and then from MSU
case -2147205120:
case 3010:
Logger.Log(String.Format(CultureInfo.InvariantCulture, "Reboot exception has been hit from bundle: {0}", selectedbundle.Name), Logger.MessageLevel.Error, AppName);
throw new RebootRequiredException("A reboot is required to complete the uninstall process or an error can occur in the uninstall process.");
case 0:
ProcessUninstallMSIs(ip);
break;
default:
Logger.Log(String.Format(CultureInfo.InvariantCulture, "Bundle exited with non-zero exit code: {0}", bundleexitcode), Logger.MessageLevel.Error, AppName);
Console.WriteLine(String.Format(CultureInfo.InvariantCulture, "Bundle exited with non-zero exit code: {0}", bundleexitcode));
break;
}
}
示例3: FilterTexture
private void FilterTexture(
ICollection<Material> slotMaterials,
List<Texture2D> textures, Maid maid, EditTarget texEdit)
{
Material material = null;
Texture2D texture = null;
{
if ( slotMaterials != null ) {
material = slotMaterials.ElementAtOrDefault(texEdit.matNo);
if (material != null) {
texture = material.GetTexture(texEdit.propName) as Texture2D;
}
}
}
if (material == null || texture == null) return;
FilterParam filterParam = GetFilterParam(maid, texEdit.slotName, material, texEdit.propName);
if (!filterParam.Dirty.Value) return;
FilterTexture(texture, filterParam);
}