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


C# List.AddRange方法代码示例

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


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

示例1: GetShippingRatesSyncParallel

        public ShippingRate[] GetShippingRatesSyncParallel(decimal weight, string originZipCode, string destinationZipCode)
        {
            // create object that will store results
            List<ShippingRate> rates = new List<ShippingRate>();

            // launch asynchronous requests, which will complete in parallel
            WebRequest fedExRequest = CreateFedExRequest(weight, originZipCode, destinationZipCode);
            IAsyncResult fedExResult = fedExRequest.BeginGetResponse(null, null);

            WebRequest upsRequest = CreateUpsRequest(weight, originZipCode, destinationZipCode);
            IAsyncResult upsResult = upsRequest.BeginGetResponse(null, null);

            WebRequest uspsRequest = CreateUspsRequest(weight, originZipCode, destinationZipCode);
            IAsyncResult uspsResult = uspsRequest.BeginGetResponse(null, null);

            // wait for all requests; each EndGetResponse will block if the request hasn't completed

            using (WebResponse response = fedExRequest.EndGetResponse(fedExResult))
                rates.AddRange(GetFedExRates(response));

            using (WebResponse response = upsRequest.EndGetResponse(upsResult))
                rates.AddRange(GetUpsRates(response));

            using (WebResponse response = uspsRequest.EndGetResponse(uspsResult))
                rates.AddRange(GetUspsRates(response));

            return rates.ToArray();
        }
开发者ID:bgrainger,项目名称:AsyncIoDemo,代码行数:28,代码来源:ShippingRatesProvider.cs

示例2: GetShippingRatesSync

        public ShippingRate[] GetShippingRatesSync(decimal weight, string originZipCode, string destinationZipCode)
        {
            // create object that will store results
            List<ShippingRate> rates = new List<ShippingRate>();

            // launch requests serially, waiting for each one
            using (WebResponse response = CreateFedExRequest(weight, originZipCode, destinationZipCode).GetResponse())
                rates.AddRange(GetFedExRates(response));

            using (WebResponse response = CreateUpsRequest(weight, originZipCode, destinationZipCode).GetResponse())
                rates.AddRange(GetUpsRates(response));

            using (WebResponse response = CreateUspsRequest(weight, originZipCode, destinationZipCode).GetResponse())
                rates.AddRange(GetUspsRates(response));

            return rates.ToArray();
        }
开发者ID:bgrainger,项目名称:AsyncIoDemo,代码行数:17,代码来源:ShippingRatesProvider.cs

示例3: CreateGraph

        public void CreateGraph(int nodeCount, int edgeCount)
        {
            _f8.TabulaRasa ();
            var creationDate = DateHelper.ConvertDateTime (DateTime.Now);
            var vertexIDs = new List<Int32> ();
            var prng = new Random ();
            if (nodeCount < _numberOfToBeTestedVertices) {
                _numberOfToBeTestedVertices = nodeCount;
            }

            _toBeBenchenVertices = new List<VertexModel> (_numberOfToBeTestedVertices);

            for (var i = 0; i < nodeCount; i++) {
                vertexIDs.Add (_f8.CreateVertex (creationDate).Id);

            }

            if (edgeCount != 0) {
                foreach (var aVertexId in vertexIDs) {
                    var targetVertices = new HashSet<Int32> ();

                    do {
                        targetVertices.Add (vertexIDs [prng.Next (0, vertexIDs.Count)]);
                    } while (targetVertices.Count < edgeCount);

                    foreach (var aTargetVertex in targetVertices) {
                        _f8.CreateEdge (aVertexId, 0, aTargetVertex, creationDate);
                    }
                }

                _toBeBenchenVertices.AddRange (PickInterestingIDs (vertexIDs, prng)
                    .Select (aId => {
                    VertexModel v = null;

                    _f8.TryGetVertex (out v, aId);

                    return v;
                }));
            }
        }
开发者ID:politician,项目名称:fallen-8,代码行数:40,代码来源:BenchmarkProvider.cs

示例4: CaptureModeration

        /// <summary>
        /// Captures all moderations.
        /// </summary>
        public void CaptureModeration()
        {
            lock (Container.lockModeratedClientList)
            {
                var entries = new List<LogEntry>();
                var lastModerated = DateTime.MinValue;
                lock (Repository.Container.lockDatabase)
                {
                    using (var command = new SQLiteCommand(this.Container.DatabaseConnection))
                    {
                        command.CommandText = "SELECT MAX(CreationDate) FROM Moderate";
                        var result = command.ExecuteScalar();
                        if (result is Int32 && (Int32)result > 0) lastModerated = ((Int32)result).ToDateTime();
                        if (result is Int64 && (Int64)result > 0) lastModerated = ((Int64)result).ToDateTime();
                    }
                }
                if (lastModerated == DateTime.MinValue) LogService.Debug("Start capturing previous Moderation data. This may take some time...");

                uint? index = null;
                ushort length = 10;
                try
                {
                    while (true)
                    {
                        var logEntriesResult = index.HasValue ? QueryRunner.GetLogEntries(length, false, index) : QueryRunner.GetLogEntries(length, false);
                        entries.AddRange(logEntriesResult.LogEntries.Where(m => m.LogLevel == LogLevel.Info && m.LogCategory == "VirtualServer" && m.TimeStamp > lastModerated));
                        index = logEntriesResult.LogPositionToContinueReading;

                        if (index == 0) break;
                        if (!logEntriesResult.LogEntries.Any() || logEntriesResult.LogEntries.Min(l => l.TimeStamp) < lastModerated) break;
                        if (entries.Count > 10000) break;
                        length = 100;
                    }
                }
                catch (ArgumentException) { }

                foreach (var logEntry in entries)
                {
                    var entity = ModeratedClientEntity.Parse(logEntry);
                    if (entity.HasValue)
                    {
                        lock (Repository.Container.lockDatabase)
                        {
                            using (var command = new SQLiteCommand(this.Container.DatabaseConnection))
                            {
                                command.CommandText = string.Format("INSERT INTO Moderate(ClientDatabaseId, ModeratorDatabaseId, ServerGroupId, Type, CreationDate) VALUES({0}, {1}, {2}, {3}, {4})", entity.Value.User, entity.Value.Moderator, entity.Value.ServerGroup, (int)entity.Value.Type, entity.Value.Moderated.ToTimeStamp());
                                command.ExecuteNonQuery();
                            }
                        }
                    }
                }

                if (lastModerated == DateTime.MinValue) LogService.Debug("Finished capturing Moderation data.");
            }
        }
开发者ID:Oslo-Lions-Elektroniske-Sportsklubb,项目名称:TS3-Bot,代码行数:58,代码来源:ClientData.cs

示例5: OnExecute

        public override void OnExecute()
        {
            base.OnExecute();

            DateTime now  = DateTime.Now;
            List<ONotification> notifications =
                TablesLogic.tNotification.LoadList(
                TablesLogic.tNotification.NextNotificationDateTime < now);

            foreach (ONotification notification in notifications)
            {
                try
                {
                    // Load up the object and test if the expected
                    // field is null. 
                    // 
                    OActivity activity = TablesLogic.tActivity.Load(notification.ActivityID);
                    ONotificationProcess notificationProcess = TablesLogic.tNotificationProcess.Load(notification.NotificationProcessID);
                    ONotificationMilestones milestones = notificationProcess.NotificationMilestones;

                    // 2010.06.30
                    // Kim Foong
                    // Checks if any of the objects are null, if so, we terminate the
                    // notification.
                    //
                    if (activity == null || notificationProcess == null || milestones == null)
                    {
                        using (Connection c = new Connection())
                        {
                            notification.NextNotificationDateTime = null;
                            notification.Save();
                            c.Commit();
                        }
                        continue;
                    }

                    Type type = typeof(TablesLogic).Assembly.GetType("LogicLayer." + activity.ObjectTypeName);
                    LogicLayerPersistentObject obj = PersistentObject.LoadObject(type, activity.AttachedObjectID.Value) as LogicLayerPersistentObject;
                    if (obj == null)
                    {
                        // 2010.06.30
                        // Kim Foong
                        // Terminate the notification.
                        //
                        using (Connection c = new Connection())
                        {
                            notification.NextNotificationDateTime = null;
                            notification.Save();
                            c.Commit();
                        }
                        continue;
                    }

                    int milestoneNumber = notification.NextNotificationMilestone.Value;
                    int notificationLevel = notification.NextNotificationLevel.Value;
                    string expectedField = (string)milestones.DataRow["ExpectedField" + milestoneNumber];

                    object value = DataFrameworkBinder.GetValue(obj, expectedField, false);
                    using (Connection c = new Connection())
                    {
                        if (value == null)
                        {
                            // Now since this value is null, we must send a notification.
                            //
                            // But we need to first find out the list of all the recipients 
                            // configured to receive the notification.
                            //
                            ONotificationHierarchyLevel notificationHierarchyLevel =
                                notificationProcess.NotificationHierarchy.FindNotificationHierarchyLevelByLevel(notificationLevel);

                            StringBuilder email = new StringBuilder();
                            StringBuilder cellphone = new StringBuilder();

                            // Assign users/roles to the task.
                            //
                            StringBuilder emails = new StringBuilder();
                            StringBuilder cellphones = new StringBuilder();
                            if (notificationHierarchyLevel != null)
                            {
                                List<OUser> notifyUsers = new List<OUser>();
                                List<OPosition> notifyPositions = new List<OPosition>();

                                // Here we assigned the users
                                //
                                foreach (OUser user in notificationHierarchyLevel.Users)
                                    notifyUsers.Add(user);

                                // Then we assign the positions.
                                //
                                foreach (OPosition position in notificationHierarchyLevel.Positions)
                                    notifyPositions.Add(position);

                                // Then we assign the positions through the roles.
                                //
                                List<string> roleCodes = new List<string>();
                                foreach (ORole role in notificationHierarchyLevel.Roles)
                                    roleCodes.Add(role.RoleCode);
                                List<OPosition> assignedPositions = OPosition.GetPositionsByRoleCodesAndObject(obj, roleCodes.ToArray());
                                notifyPositions.AddRange(assignedPositions);

//.........这里部分代码省略.........
开发者ID:vinhdoan,项目名称:Angroup.demo,代码行数:101,代码来源:NotificationService.cs


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