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


C# ICollection.ElementAtOrDefault方法代码示例

本文整理汇总了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);
 }
开发者ID:edenerez,项目名称:Negotiation,代码行数:12,代码来源:BasicDona.cs

示例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;
            }
        }
开发者ID:BlackMizi,项目名称:VisualStudioUninstaller,代码行数:37,代码来源:Program.cs

示例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);
        }
开发者ID:trzr,项目名称:CM3D2.AlwaysColorChangeEx.Plugin,代码行数:21,代码来源:TextureModifier.cs


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