本文整理匯總了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();
}
示例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();
}
示例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;
}));
}
}
示例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.");
}
}
示例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);
//.........這裏部分代碼省略.........