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


C# IList.Concat方法代码示例

本文整理汇总了C#中IList.Concat方法的典型用法代码示例。如果您正苦于以下问题:C# IList.Concat方法的具体用法?C# IList.Concat怎么用?C# IList.Concat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IList的用法示例。


在下文中一共展示了IList.Concat方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Calculate

        public int Calculate(IList<int> numbers, decimal currentSum, int globalMax)
        {
            int result = 0;
            decimal max = numbers.Count == 0 ? 1 : numbers[numbers.Count - 1];

            for (decimal i = max + 1; i <= globalMax; i++)
            {
                decimal sum = currentSum + values[(int)i];
                if (sum > half)
                    break;
                if (Math.Abs(sum-half)< 0.000000001m)
                {
                    foreach (var number in numbers.Concat(new int[] {(int)i}))
                    {
                        Console.Write(number.ToString()+",");
                    }
                    Console.Write("    "    +sum.ToString());
                    Console.WriteLine();
                    result++;
                    break;
                }

                if (i<globalMax && sum + sumOfValues[(int)i+1]< half)
                    break;

                List<int> newNumbers = new List<int>(numbers);
                newNumbers.Add((int)i);

                result += Calculate(newNumbers, sum, globalMax);
            }
            return result;
        }
开发者ID:balazsmolnar,项目名称:Euler,代码行数:32,代码来源:Program.cs

示例2: Connection

        public Connection(IMessageBus newMessageBus,
                          IJsonSerializer jsonSerializer,
                          string baseSignal,
                          string connectionId,
                          IList<string> signals,
                          IList<string> groups,
                          ITraceManager traceManager,
                          IAckHandler ackHandler,
                          IPerformanceCounterManager performanceCounterManager,
                          IProtectedData protectedData)
        {
            if (traceManager == null)
            {
                throw new ArgumentNullException("traceManager");
            }

            _bus = newMessageBus;
            _serializer = jsonSerializer;
            _baseSignal = baseSignal;
            _connectionId = connectionId;
            _signals = new List<string>(signals.Concat(groups));
            _groups = new DiffSet<string>(groups);
            _traceSource = traceManager["SignalR.Connection"];
            _ackHandler = ackHandler;
            _counters = performanceCounterManager;
            _protectedData = protectedData;
        }
开发者ID:Djohnnie,项目名称:Sonarr,代码行数:27,代码来源:Connection.cs

示例3: Connection

        public Connection(IMessageBus newMessageBus,
                          JsonSerializer jsonSerializer,
                          string baseSignal,
                          string connectionId,
                          IList<string> signals,
                          IList<string> groups,
                          ILoggerFactory loggerFactory,
                          IAckHandler ackHandler,
                          IPerformanceCounterManager performanceCounterManager,
                          IProtectedData protectedData,
                          IMemoryPool pool)
        {
            if (loggerFactory == null)
            {
                throw new ArgumentNullException("loggerFactory");
            }

            _bus = newMessageBus;
            _serializer = jsonSerializer;
            _baseSignal = baseSignal;
            _connectionId = connectionId;
            _signals = new List<string>(signals.Concat(groups));
            _groups = new DiffSet<string>(groups);
            _logger = loggerFactory.CreateLogger<Connection>();
            _ackHandler = ackHandler;
            _counters = performanceCounterManager;
            _protectedData = protectedData;
            _excludeMessage = m => ExcludeMessage(m);
            _pool = pool;
        }
开发者ID:leloulight,项目名称:SignalR-Server,代码行数:30,代码来源:Connection.cs

示例4: ParseRelationOperation

 public ParseRelationOperation(IEnumerable<ParseObject> adds,
     IEnumerable<ParseObject> removes) {
   adds = adds ?? new ParseObject[0];
   removes = removes ?? new ParseObject[0];
   this.targetClassName = adds.Concat(removes).Select(o => o.ClassName).FirstOrDefault();
   this.adds = new ReadOnlyCollection<string>(IdsFromObjects(adds).ToList());
   this.removes = new ReadOnlyCollection<string>(IdsFromObjects(removes).ToList());
 }
开发者ID:mehul9595,项目名称:Parse-SDK-dotNET,代码行数:8,代码来源:ParseRelationOperation.cs

示例5: CheckDigits

		private static bool CheckDigits (IList <int> digits, Tuple <int, int> factorsPair)
		{
			var allDigits = digits
				.Concat (factorsPair.Item1.GetDigits ())
				.Concat (factorsPair.Item2.GetDigits ())
				.ToList ();
			
			if (allDigits.Count != 9)
				return false;
			
			return nineDigits.SequenceEqual (
				allDigits.OrderBy (d => d));
		}
开发者ID:juancri,项目名称:eulerproject,代码行数:13,代码来源:Problem32.cs

示例6: ProcessWatchers

        public static IList<string> ProcessWatchers(this IBot bot, string repositoryName, IList<string> existingWatchers, IEnumerable<dynamic> watchers)
        {
            var currentWatchers = watchers.Select(c => c.login.ToString()).Cast<string>().ToList();
            var newWatchers = currentWatchers.Except(existingWatchers).ToList();
            foreach (var w in newWatchers)
            {
                bot.SayToAllRooms(string.Format("{0} is now watching {1}", w, repositoryName));
            }

            var noLongerWatching = existingWatchers.Except(currentWatchers).ToList();
            foreach (var w in noLongerWatching)
            {
                bot.SayToAllRooms(string.Format("{0} is no longer watching {1}", w, repositoryName));
            }

            return existingWatchers.Concat(newWatchers).Except(noLongerWatching).ToList();
        }
开发者ID:NickJosevski,项目名称:jibbr,代码行数:17,代码来源:BotWatcherExtensions.cs

示例7: GetPostsByInterests

        public IList<UserPostDto> GetPostsByInterests(IList<Interest> interests)
        {
            //get user interests
            //get sibling and parent interests
            var interestAndParentInterests = interests
                .Concat(interests.Select(x => x.ParentInterest))
                .Where(x => x != null)
                .Distinct()
                .ToList();

            var posts = _postRepository.GetPostsByInterestTypes(interestAndParentInterests).ToList();

            //get all media with any matching interests order by date desc limit by 100
            var recentPosts = posts.OrderByDescending(x => x.CreateDate).Take(200);

            /*
             * my thinking is take the last 100 because a user probably won't read past that..
             * if we only grab the first 10 then there is the problem that 11th might be extremely relevent
             * but shows up much later on cause it's
             * slightly older
             */

            return recentPosts.Select(
                post =>
                {
                    int rank = 0;

                    //we know the medium has a userInterest tied to it
                    if (interests.Contains(post.Interest))
                        rank = 10;
                    else if (post.Interest.ParentInterest != null && interestAndParentInterests.Contains(post.Interest.ParentInterest))
                        rank = 2;
                    else if (interestAndParentInterests.Contains(post.Interest))
                        rank = 1;

                    int daysSinceMediumCreated = (DateTime.UtcNow - post.CreateDate).Days;

                    rank -= daysSinceMediumCreated;

                    return new { Rank = rank, FeedItem = new UserPostDto(post) };
                }).OrderByDescending(x => x.Rank).Select(x => x.FeedItem).ToList();
        }
开发者ID:scottccoates,项目名称:CliqFlip,代码行数:42,代码来源:PostTasks.cs

示例8: GroupData

        private IList<DssExportHistory> GroupData(IList<LocationTransaction> locTrans, DssOutboundControl dssOutboundControl, DateTime effectiveDate)
        {
            #region 补充0成品工单
            var fgOrderDetIdList = locTrans
                 .Where(l => StringHelper.Eq(l.TransactionType, BusinessConstants.CODE_MASTER_LOCATION_TRANSACTION_TYPE_VALUE_RCT_WO))
                 .Select(l => l.OrderDetailId).Distinct().ToList();
            var rmOrderDetIdList = locTrans
                   .Where(l => StringHelper.Eq(l.TransactionType, BusinessConstants.CODE_MASTER_LOCATION_TRANSACTION_TYPE_VALUE_ISS_WO))
                   .Select(l => l.OrderDetailId).Distinct().ToList();

            var addList = rmOrderDetIdList.Except(fgOrderDetIdList).Distinct().ToList();

            #region 添加虚拟RCT-WO
            if (addList.Count > 0)
            {

                IList<LocationTransaction> virtualWOList = this.GetVirRctWo(addList);//GetVirtualRCTWO 修改为 GetVirRctWo
                if (virtualWOList.Count > 0)
                {
                    foreach (var virtualWO in virtualWOList)
                    {
                        virtualWO.TransactionType = BusinessConstants.CODE_MASTER_LOCATION_TRANSACTION_TYPE_VALUE_RCT_WO;
                        virtualWO.EffectiveDate = effectiveDate;
                        virtualWO.Qty = 0;
                    }
                    locTrans = locTrans.Concat(virtualWOList).ToList();
                }
            }
            #endregion
            #endregion

            #region Transformer
            var fgQuery = locTrans.Where(l => StringHelper.Eq(l.TransactionType, BusinessConstants.CODE_MASTER_LOCATION_TRANSACTION_TYPE_VALUE_RCT_WO)).ToList();
            var rmQuery = locTrans.Where(l => StringHelper.Eq(l.TransactionType, BusinessConstants.CODE_MASTER_LOCATION_TRANSACTION_TYPE_VALUE_ISS_WO)).ToList();

            log.Debug("Begin to group single data, count:" + fgQuery.Count);
            IList<DssExportHistory> dssExportHistoryList = this.GroupSingleDssExportHistory(fgQuery, rmQuery, dssOutboundControl, effectiveDate);
            #endregion

            return dssExportHistoryList;
        }
开发者ID:Novthirteen,项目名称:yfkey-scms,代码行数:41,代码来源:RctwoOutboundMgr.cs

示例9: ParseParameters

        private static void ParseParameters(IList<IWhere> wheres)
        {
            var index = 1;
            var list = new List<string>();

            var innerparams = wheres
                .Where(w => w.Parameter.Type == ParameterType.Query)
                .SelectMany(w => ((IAdfQuery) w.Parameter.Value).Wheres);

            // NULL and NOT NULL are rendered different and dont use a parameter
            var allWheres = wheres.Concat(innerparams).Where(w => w.Operator != OperatorType.IsNull && w.Operator != OperatorType.IsNotNull);

            foreach (var where in allWheres)
            {
                if (where.Parameter.Name.IsNullOrEmpty())
                {
                    where.Parameter.Name = where.Column.ColumnName;
                }

                if (list.Contains(where.Parameter.Name))
                {
                    where.Parameter.Name += index++;
                }

                list.Add(where.Parameter.Name);

                ApplyLike(where);
            }
        }
开发者ID:erwinbovendeur,项目名称:ADF,代码行数:29,代码来源:SqlServerQueryParser.cs

示例10: GenerateParameterNames

        public static IList<ParameterName> GenerateParameterNames(
            this SemanticModel semanticModel,
            IEnumerable<ArgumentSyntax> arguments,
            IList<string> reservedNames = null)
        {
            reservedNames = reservedNames ?? SpecializedCollections.EmptyList<string>();

            // We can't change the names of named parameters.  Any other names we're flexible on.
            var isFixed = reservedNames.Select(s => true).Concat(
                arguments.Select(a => a.NameColon != null)).ToList();

            var parameterNames = reservedNames.Concat(
                arguments.Select(semanticModel.GenerateNameForArgument)).ToList();

            return GenerateNames(reservedNames, isFixed, parameterNames);
        }
开发者ID:otawfik-ms,项目名称:roslyn,代码行数:16,代码来源:SemanticModelExtensions.cs

示例11: GetNextLayer

        private IEnumerable<IList<Color>> GetNextLayer(IList<Color> list)
        {
            var colors = new List<Color>() {
                Color.NotSet,
                Color.Blue,
                Color.Black,
                Color.Red,
                Color.White,
                Color.Yellow
            };

            foreach (var color in colors) {
                yield return list.Concat(new List<Color>() { color }).ToList();
            }
        }
开发者ID:goosefraba19,项目名称:ktane-abe,代码行数:15,代码来源:WiresSolverTests.cs

示例12: SonAgentMethod

 private static IList<TAgents> SonAgentMethod(int id, APIDataDataContext db, IList<TAgents> agent)
 {
     var sonagents = (from c in db.TAgents where c.DirectAgentID == id select c).ToList();
     foreach (var item in sonagents)
     {
         agent = SonAgentMethod(item.ID, db, agent);
     }
     agent = agent.Concat(sonagents).ToList();
     return agent;
 }
开发者ID:BriseLee,项目名称:test,代码行数:10,代码来源:Converter.cs

示例13: InlineIR

		private static BasicBlock InlineIR(this CALLInstruction call,
			IList<BasicBlockInstruction> preamble,
			BasicBlock backend,
			Dictionary<Subprogram, Dictionary<VirtualRegister, VirtualRegister>> inlineRegMaps)
		{
			Dictionary<VirtualRegister, VirtualRegister> inlineRegMap;
			if (!inlineRegMaps.TryGetValue(call.Target, out inlineRegMap))
			{
				inlineRegMap = call.Target.LocalVariables.Select(lv => 
					new KeyValuePair<VirtualRegister, VirtualRegister>(lv, new VirtualRegister(lv.UnderlyingType, lv.StateSpace))).
					ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
				inlineRegMaps.Add(call.Target, inlineRegMap);
			}
			inlineRegMap = inlineRegMap.Concat(call.Target.FormalParameters.Zip(call.Arguments,
				(formal, actual) => new KeyValuePair<VirtualRegister, VirtualRegister>(formal,
				(actual is VirtualRegister) ? (actual as VirtualRegister) : 
				(formal.StateSpace != StateSpaces.REG) ? new VirtualRegister(formal.UnderlyingType, formal.StateSpace) :
				new VirtualRegister(formal.DataType)))).
				ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
			
			Dictionary<BasicBlock, BasicBlock> cfgmap = call.Target.GetBasicBlocks().Select(bb => 
			{
				VirtualRegister flag = (bb.Trailer is JumpIfInstruction) ?
					(bb.Trailer as JumpIfInstruction).Flag.MapOperand(inlineRegMap) : null;
				
				ControlFlowInstruction trailer;
				
				switch (bb.Trailer.OpCode)
				{
				case IROpCodes.RET:
					trailer = new JMPInstruction() { Target = backend };
					break;
				case IROpCodes.JMP:
					trailer = new JMPInstruction();
					break;
				case IROpCodes.JT:
					trailer = new JTInstruction(flag);
					break;
				case IROpCodes.JF:
					trailer = new JFInstruction(flag);
					break;
				default:
					throw new NotSupportedException();
				}
				
				return new KeyValuePair<BasicBlock, BasicBlock>(bb,
					new BasicBlock(bb.Code.Select(bbi => bbi.MapInstruction(inlineRegMap)).ToList(), trailer));
				
			}).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
			
			foreach (KeyValuePair<BasicBlock, BasicBlock> bbmap in cfgmap)
			{
				if (bbmap.Key.Successor != null)
					bbmap.Value.Successor = cfgmap[bbmap.Key.Successor];
				if (bbmap.Key.Target != null)
					bbmap.Value.Target = cfgmap[bbmap.Key.Target];
			}
			
			BasicBlock root = cfgmap[call.Target.CFGRoot];
			return new BasicBlock(preamble.Concat(root.Code).ToList(), root.Trailer);
		}
开发者ID:cephdon,项目名称:gpudotnet,代码行数:61,代码来源:Inline.cs

示例14: ScreenRecordForm

        public ScreenRecordForm( IPluginHost pluginHost )
            : base(pluginHost)
        {
            this.StickyWindow = new DroidExplorer.UI.StickyWindow ( this );
            CommonResolutions = GetCommonResolutions ( );
            InitializeComponent ( );

            var defaultFile = "screenrecord_{0}_{1}.mp4".With ( this.PluginHost.Device, DateTime.Now.ToString ( "yyyy-MM-dd-hh" ) );
            this.location.Text = "/sdcard/{0}".With ( defaultFile );

            var resolution = new VideoSize ( PluginHost.CommandRunner.GetScreenResolution ( ) );
            var sizes = CommonResolutions.Concat ( new List<VideoSize> { resolution } ).OrderBy ( x => x.Size.Width ).Select ( x => x ).ToList ( );
            resolutionList.DataSource = sizes;
            resolutionList.DisplayMember = "Display";
            resolutionList.ValueMember = "Size";
            resolutionList.SelectedItem = resolution;

            rotateList.DataSource = GetRotateArgumentsList ( );
            rotateList.DisplayMember = "Display";
            rotateList.ValueMember = "Arguments";

            var bitrates = new List<BitRate> ( );

            for ( int i = 1; i < 25; i++ ) {
                bitrates.Add ( new BitRate ( i ) );
            }

            bitrateList.DataSource = bitrates;
            bitrateList.DisplayMember = "Display";
            bitrateList.ValueMember = "Value";
            bitrateList.SelectedItem = bitrates.Single ( x => x.Mbps == 4 );
            var ts = new TimeSpan ( 0, 0, 0, timeLimit.Value, 0 );
            displayTime.Text = ts.ToString ( );
        }
开发者ID:camalot,项目名称:droidexplorer,代码行数:34,代码来源:ScreenRecordForm.cs

示例15: Merge2ListRecurseImple

        private static IList<int> Merge2ListRecurseImple(IList<int> thisList, IList<int> thatList,
                                                          int thisCounter, int thatCounter,
                                                          int thisLength, int thatLength,
                                                          IList<int> result) 
        {
            Contract.Requires(thisList != null && thatList != null);
            //Base Case
            //Do nothing when reaches end of lists
            if (thisCounter == thisLength
                && thatCounter == thatLength)
                return result;

            if (thisCounter < thisLength && thatCounter < thatLength)
            {
                if (thisList[thisCounter] > thatList[thatCounter])
                {
                    result.Add(thatList[thatCounter]);
                    ++thatCounter;
                }
                else
                {
                    result.Add(thisList[thisCounter]);
                    ++thisCounter;
                }
            }

            if (thisCounter == thisLength)
            {
                result = result.Concat(thatList).ToList();
                return result;
            }
            if (thatCounter == thatLength)
            {
                result = result.Concat(thisList).ToList();
                return result;
            }
            Contract.Ensures(result != null);
            return Merge2ListRecurseImple(thisList, thatList, thisCounter, thatCounter, thisLength, thatLength, result);
        }
开发者ID:edwardt,项目名称:KeyConcepts,代码行数:39,代码来源:MergeList.cs


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