• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# ICollection类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中ICollection的典型用法代码示例。如果您正苦于以下问题:C# ICollection类的具体用法?C# ICollection怎么用?C# ICollection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ICollection类属于命名空间,在下文中一共展示了ICollection类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: AddContracts

        public override void AddContracts(
            ICSharpContextActionDataProvider provider,
            Func<IExpression, IExpression> getContractExpression,
            out ICollection<ICSharpStatement> firstNonContractStatements)
        {
            var contractInvariantMethodDeclaration = classLikeDeclaration.EnsureContractInvariantMethod(provider.PsiModule);

            if (contractInvariantMethodDeclaration.Body != null)
            {
                var factory = CSharpElementFactory.GetInstance(provider.PsiModule);

                var expression = factory.CreateExpression("$0", declaration.DeclaredElement);

                ICSharpStatement firstNonContractStatement;

                AddContract(
                    ContractKind.Invariant,
                    contractInvariantMethodDeclaration.Body,
                    provider.PsiModule,
                    () => getContractExpression(expression),
                    out firstNonContractStatement);
                firstNonContractStatements = firstNonContractStatement != null ? new[] { firstNonContractStatement } : null;
            }
            else
            {
                firstNonContractStatements = null;
            }
        }
开发者ID:prodot,项目名称:ReCommended-Extension,代码行数:28,代码来源:FieldContractInfo.cs


示例2: ExcludeMultiples

 private static void ExcludeMultiples(ICollection<long> crossedOffList, long candidate, int max)
 {
     for (var i = candidate; i < max + 1; i += candidate)
     {
         crossedOffList.Add(i);
     }
 }
开发者ID:nemesek,项目名称:ProjectEuler,代码行数:7,代码来源:Problem10Tests.cs


示例3: AreComponentsRemovable

 internal static bool AreComponentsRemovable(ICollection components)
 {
     if (components == null)
     {
         throw new ArgumentNullException("components");
     }
     foreach (object obj2 in components)
     {
         Activity activity = obj2 as Activity;
         ConnectorHitTestInfo info = obj2 as ConnectorHitTestInfo;
         if ((activity == null) && (info == null))
         {
             return false;
         }
         if (activity != null)
         {
             ActivityDesigner designer = ActivityDesigner.GetDesigner(activity);
             if ((designer != null) && designer.IsLocked)
             {
                 return false;
             }
         }
         if ((info != null) && !(info.AssociatedDesigner is FreeformActivityDesigner))
         {
             return false;
         }
     }
     return true;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:29,代码来源:DesignerHelpers.cs


示例4: In

 /// <summary>
 /// Where a field value is one in a set.
 /// </summary>
 public static iCondition In(this iCondition pCon, string pFieldName, ICollection<string> pValues)
 {
     IEnumerable<string> strings = from str in pValues select string.Format("'{0}'", str);
     return pValues.Count == 0
         ? pCon
         : Expression(pCon, pFieldName, string.Format("IN ({0})", string.Join(",", strings)));
 }
开发者ID:thinkingmedia,项目名称:gems,代码行数:10,代码来源:ConditionWhere.cs


示例5: GetCardWithSuitThatEnemyDoesNotHave

        public Card GetCardWithSuitThatEnemyDoesNotHave(bool enemyHasATrumpCard, CardSuit trumpSuit, ICollection<Card> playerCards)
        {
            if (!enemyHasATrumpCard)
            {
                // In case the enemy does not have any trump cards and Stalker has a trump, he should throw a trump.
                var myTrumpCards = playerCards.Where(c => c.Suit == trumpSuit).ToList();
                if (myTrumpCards.Count() > 0)
                {
                    return myTrumpCards.OrderBy(c => c.GetValue()).LastOrDefault();
                }
            }

            var orderedCards = playerCards.OrderBy(c => c.GetValue());
            foreach (var card in orderedCards)
            {
                if (this.cardHolder.EnemyCards.All(c => c.Suit != card.Suit))
                {
                    if (enemyHasATrumpCard)
                    {
                        return playerCards.Where(c => c.Suit == card.Suit).OrderBy(c => c.GetValue()).FirstOrDefault();
                    }

                    return playerCards.Where(c => c.Suit == card.Suit).OrderByDescending(c => c.GetValue()).FirstOrDefault();
                }
            }

            return null;
        }
开发者ID:M-Yankov,项目名称:S.T.A.L.K.E.R,代码行数:28,代码来源:StalkerHelper.cs


示例6: Execute

        /// <summary>
        /// Executes the specified pipeline.
        /// </summary>
        /// <param name="pipelineName">The name.</param>
        /// <param name="pipeline">The pipeline.</param>
        /// <param name="translateRows">Translate the rows into another representation</param>
        public void Execute(string pipelineName,
                            ICollection<IOperation> pipeline,
                            Func<IEnumerable<Row>, IEnumerable<Row>> translateRows)
        {
            try
            {
                IEnumerable<Row> enumerablePipeline = PipelineToEnumerable(pipeline, new List<Row>(), translateRows);
                try
                {
                    raiseNotifyExecutionStarting();
                    DateTime start = DateTime.Now;
                    ExecutePipeline(enumerablePipeline);
                    raiseNotifyExecutionCompleting();
                    Trace("Completed process {0} in {1}", pipelineName, DateTime.Now - start);
                }
                catch (Exception e)
                {
                    string errorMessage = string.Format("Failed to execute pipeline {0}", pipelineName);
                    Error(e, errorMessage);
                }
            }
            catch (Exception e)
            {
                Error(e, "Failed to create pipeline {0}", pipelineName);                
            }

            DisposeAllOperations(pipeline);
        }
开发者ID:f4i2u1,项目名称:rhino-etl,代码行数:34,代码来源:AbstractPipelineExecuter.cs


示例7: CheckDataIfStartMenuIsExpectedToNotExist

        private static CheckResult CheckDataIfStartMenuIsExpectedToNotExist(ICollection<FileChange> fileChanges, ICollection<Registryhange> registryChanges,
            FileChange fileChange, StartMenuData startMenuData, Registryhange registryChange)
        {
            if (fileChange == null)
            {
               return CheckResult.Succeeded(startMenuData);
            }

            if (fileChange.Type != FileChangeType.Delete)
            {
                fileChanges.Remove(fileChange);
                if (registryChange != null)
                {
                    registryChanges.Remove(registryChange);
                }
                return CheckResult.Failure("Found menu item:'" + startMenuData.Name + "' when is was not expected");
            }

            // When uninstalling this key get changed
            const string startPageKey = @"HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\StartPage";
            var uninstallStartMenuKey =
                registryChanges.FirstOrDefault(x => string.Equals(x.Key, startPageKey, StringComparison.InvariantCultureIgnoreCase) &&
                                                    x.ValueName == "FavoritesRemovedChanges" &&
                                                    x.Type == RegistryChangeType.SetValue);

            if (uninstallStartMenuKey == null)
            {
                fileChanges.Remove(fileChange);
                return CheckResult.Failure("");
            }

            registryChanges.Remove(uninstallStartMenuKey);
            fileChanges.Remove(fileChange);
            return CheckResult.Succeeded(startMenuData);
        }
开发者ID:pwibeck,项目名称:InstallerVerificationFramework,代码行数:35,代码来源:StartMenuCheck.cs


示例8: getSteering

    public Vector3 getSteering(Rigidbody2D target, ICollection<Rigidbody2D> obstacles, out Vector3 bestHidingSpot)
    {
        //Find the closest hiding spot
        float distToClostest = Mathf.Infinity;
        bestHidingSpot = Vector3.zero;

        foreach(Rigidbody2D r in obstacles)
        {
            Vector3 hidingSpot = getHidingPosition(r, target);

            float dist = Vector3.Distance(hidingSpot, transform.position);

            if(dist < distToClostest)
            {
                distToClostest = dist;
                bestHidingSpot = hidingSpot;
            }
        }

        //If no hiding spot is found then just evade the enemy
        if(distToClostest == Mathf.Infinity)
        {
            return evade.getSteering(target);
        }

        //Debug.DrawLine(transform.position, bestHidingSpot);

        return steeringBasics.arrive(bestHidingSpot);
    }
开发者ID:ecaraway,项目名称:Global-Game-Jam-2016,代码行数:29,代码来源:Hide.cs


示例9: GoToEvent

 /// <summary>
 /// Creates a new GoToEvent using the given locations.
 /// </summary>
 /// <param name="locations">List of MarkerID's</param>
 public GoToEvent(ICollection<Point> locations)
 {
     if (locations == null)
         this.locations = new List<Point>();
     else
         this.locations = new List<Point>(locations);
 }
开发者ID:boschbc,项目名称:NaoRobot,代码行数:11,代码来源:GoToEvent.cs


示例10: DoCheck

        public override CheckResult DoCheck(BaseTestData data, ICollection<FileChange> fileChanges, ICollection<Registryhange> registryChanges)
        {
            if (!VerifyIfCorrectTestData(data))
            {
                return CheckResult.NotCheckDone();
            }

            var startMenuData = data as StartMenuData;
            var path = startMenuData.AllUsers ? GetAllUsersMenuFolder() : Environment.GetFolderPath(Environment.SpecialFolder.StartMenu);

            // To get the program folder
            var dirInfo = new DirectoryInfo(path);
            path = Path.Combine(path, dirInfo.GetDirectories()[0].Name);
            path = Path.Combine(path, startMenuData.Name + ".lnk");

            // Find registry GlobalAssocChangedCounter key that is updated when creating a startmenu
            var globalAssocChangedCounterKey = @"HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\explorer";
            if (Environment.Is64BitOperatingSystem)
            {
                globalAssocChangedCounterKey = @"HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\explorer";
            }
            var registryChange = registryChanges.FirstOrDefault(x => string.Equals(x.Key, globalAssocChangedCounterKey, StringComparison.InvariantCultureIgnoreCase) &&
                                                                   x.ValueName == "GlobalAssocChangedCounter" &&
                                                                   x.Type == RegistryChangeType.SetValue);

            var fileChange = fileChanges.FirstOrDefault(x => x.Path == path);

            return startMenuData.Exist ? CheckDataIfStartMenuIsExpectedToExist(fileChanges, registryChanges, fileChange, startMenuData, registryChange) :
                                         CheckDataIfStartMenuIsExpectedToNotExist(fileChanges, registryChanges, fileChange, startMenuData, registryChange);
        }
开发者ID:pwibeck,项目名称:InstallerVerificationFramework,代码行数:30,代码来源:StartMenuCheck.cs


示例11: AddProperty

 private static void AddProperty(ICollection<SearchResult> results, string field, string searchTerm)
 {
     if (field.ToLowerInvariant().Contains(searchTerm.ToLowerInvariant().Trim()))
     {
         results.Add(new SearchResult { id = field, name = field });
     }
 }
开发者ID:biganth,项目名称:Curt,代码行数:7,代码来源:ProfileServiceController.cs


示例12: Init

        /// <summary>
        /// Initializes the loggly logger
        /// </summary>
        /// <param name="session">Current encompass session, used to load the config file</param>
        /// <param name="config">Config file to load.  Will re-initialize when this is used.</param>
        /// <param name="tags">Collection of loggly tags.  If null, we will load the Loggly.Tags element from the config.</param>
        public static void Init(Session session, IEncompassConfig config, ICollection<string> tags = null)
        {
            config.Init(session);
            if (tags != null)
            {
                foreach (string tag in tags)
                {
                    AddTag(tag);
                }
            }
            
           foreach (var tag in config.GetValue(LOGGLY_TAGS, string.Empty).Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
            { 
                    AddTag(tag);
            }

            string configLogglyUrl = config.GetValue(LOGGLY_URL);

            if (configLogglyUrl != null)
            {
                SetPostUrl(configLogglyUrl);
            }
            bool allEnabled = config.GetValue(LOGGLY_ALL, false);
            bool errorEnabled = config.GetValue(LOGGLY_ERROR, false);
            bool warnEnabled = config.GetValue(LOGGLY_WARN, false);
            bool infoEnabled = config.GetValue(LOGGLY_INFO, false);
            bool debugEnabled = config.GetValue(LOGGLY_DEBUG, false);
            bool fatalEnabled = config.GetValue(LOGGLY_FATAL, false);

            Instance.ErrorEnabled = allEnabled || errorEnabled;
            Instance.WarnEnabled = allEnabled || warnEnabled;
            Instance.InfoEnabled = allEnabled || infoEnabled;
            Instance.DebugEnabled = allEnabled || debugEnabled;
            Instance.FatalEnabled = allEnabled || fatalEnabled;
        }
开发者ID:Guaranteed-Rate,项目名称:GuaranteedRate.Sextant,代码行数:41,代码来源:Loggly.cs


示例13: TryGetSubscribers

        public bool TryGetSubscribers(ICollection<Type> contracts, out ICollection<Address> subscribers)
        {
            Mandate.ParameterNotNull(contracts, "contracts");

            locker.EnterReadLock();

            var allSubscriptions = new List<Address>();
            subscribers = allSubscriptions;

            try
            {
                foreach (var subscriptions in contracts.Select(GetSubscribers))
                {
                    if (subscriptions == null)
                        continue;

                    allSubscriptions.AddRange(subscriptions);
                }

                return allSubscriptions.Any();
            }
            finally
            {
                locker.ExitReadLock();
            }
        }
开发者ID:AdrianFreemantle,项目名称:Hermes,代码行数:26,代码来源:SubscriptionCache.cs


示例14: DotExpression

 public DotExpression(IExpression expression, string name, ICollection<IExpression> arguments)
 {
     this.expression = expression;
     this.name = name;
     this.arguments = arguments;
     this.type = AsType(this.expression);
 }
开发者ID:ajlopez,项目名称:AjScript,代码行数:7,代码来源:DotExpression.cs


示例15: ConfigSettingMetadata

 public ConfigSettingMetadata(string location, string text, string sort, string className,
     string helpText, ICollection<string> listenTo) : base(location, text, sort)
 {
   _className = className;
   _helpText = helpText;
   _listenTo = listenTo;
 }
开发者ID:davinx,项目名称:MediaPortal-2,代码行数:7,代码来源:ConfigSettingMetadata.cs


示例16: AttributeRoutingEngine

        public AttributeRoutingEngine(ICollection assemblies)
        {
			List<IEntryControllerBinding> controllers = new List<IEntryControllerBinding>();
			System.Diagnostics.Debug.WriteLine("Init Routing Engine");

			foreach (Assembly a in assemblies)
			{
				System.Diagnostics.Debug.WriteLine(a.FullName);
				Type[] types;
				try
				{
					types = a.GetTypes();
				}
				catch
				{
					continue;
				}
				foreach (Type t in types)
				{
					if (t.GetCustomAttributes(typeof(IEntryControllerBinding), false).Length > 0)
					{
						IControllerBinding[] bindings = GetControllerBindings(t);
						if (bindings != null)
							foreach (IControllerBinding b in bindings)
							{
								IEntryControllerBinding eb = b as IEntryControllerBinding;
								if (eb != null) controllers.Add(eb);
							}
					}
				}
			}
			_controllers = controllers.ToArray();
		}
开发者ID:sebmarkbage,项目名称:calyptus.mvc,代码行数:33,代码来源:AttributeRoutingEngine.cs


示例17: MembershipEvent

 public MembershipEvent(ICluster cluster, IMember member, int eventType, ICollection<IMember> members)
     : base(cluster)
 {
     this.member = member;
     this.eventType = eventType;
     this.members = members;
 }
开发者ID:hasancelik,项目名称:hazelcast-csharp-client,代码行数:7,代码来源:MembershipEvent.cs


示例18: CreateActionPlanCommand

 public CreateActionPlanCommand(ICollection<Objective> objective, CoachingProcess coachingProcess, string Description = null)
 {
     this.CoachingProcess = new HashSet<CoachingProcess>();
     this.CoachingProcess.Add(coachingProcess);
     this.Objective = objective;
     this.Description = Description;
 }
开发者ID:luancarloswd,项目名称:CoachingPlan,代码行数:7,代码来源:CreateActionPlanCommand.cs


示例19: ArgumentHasLength

 /// <summary>
 /// 
 /// </summary>
 /// <param name="argumentName"></param>
 /// <param name="col"></param>
 public static void ArgumentHasLength(ICollection col, string argumentName)
 {
     if (col == null || col.Count <= 0)
     {
         throw new ArgumentException("参数不能空", argumentName);
     }
 }
开发者ID:deboe2015,项目名称:Ctrip.SOA,代码行数:12,代码来源:Guard.cs


示例20: EncodeIds

        private string EncodeIds(ICollection<int> ids)
        {
            if (ids == null || !ids.Any()) return string.Empty;

            // Using {1},{2} format so it can be filtered with delimiters.
            return "{" + string.Join("},{", ids.ToArray()) + "}";
        }
开发者ID:SmartFire,项目名称:Lombiq-Fields,代码行数:7,代码来源:MediaLibraryUploadField.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ICollectionPersister类代码示例发布时间:2022-05-24
下一篇:
C# ICohort类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap