本文整理汇总了C#中Common.List.AddRange方法的典型用法代码示例。如果您正苦于以下问题:C# List.AddRange方法的具体用法?C# List.AddRange怎么用?C# List.AddRange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Common.List
的用法示例。
在下文中一共展示了List.AddRange方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Build
public void Build(Solution solution, bool onlyResources, bool checkTabularSectionKey = false, bool filtersOnly = false)
{
String configurationFile = System.IO.Path.Combine(solution.SolutionFolder, @"configuration\configuration.xml");
Factory factory = new Factory();
Dictionary<String, Parameter> globalParameters = factory.GetGlobalParameters(configurationFile);
List<Entity> entities = new List<Entity>();
entities.AddRange(factory.GetEntities(configurationFile, checkTabularSectionKey));
entities.AddRange(factory.GetResources(solution.DeviceResourceFolder));
entities.AddRange(factory.GetAdmin());
Dictionary<String, List<Constant>> constants = factory.GetConstants(configurationFile);
ConfigVersion configVersion = factory.GetVersion(configurationFile);
Config config = new Config(configVersion, solution.DatabaseName, entities, globalParameters, constants);
if (onlyResources)
BuildResources(config, solution);
else
{
if (filtersOnly)
BuildFilters(config, solution);
else
{
BuildAll(config, solution);
InsertConstants(solution);
}
}
}
示例2: WriteFileToGK
public void WriteFileToGK(XDevice gkDevice)
{
var bytesList = new List<byte>();
var gkFileInfo = new GKFileInfo();
gkFileInfo.Initialize(XManager.DeviceConfiguration, gkDevice);
bytesList.AddRange(gkFileInfo.InfoBlock);
var sendResult = SendManager.Send(gkDevice, 0, 21, 0);
if (sendResult.HasError)
{ Error = "Невозможно начать процедуру записи "; return; }
bytesList.AddRange(gkFileInfo.FileBytes);
var progressCallback = GKProcessorManager.StartProgress("Запись файла в " + gkDevice.PresentationName, null, bytesList.Count / 256, true, GKProgressClientType.Administrator);
for (var i = 0; i < bytesList.Count; i += 256)
{
if (progressCallback.IsCanceled)
{ Error = "Операция отменена"; return; }
GKProcessorManager.DoProgress("Запись блока данных " + i + 1, progressCallback);
var bytesBlock = BitConverter.GetBytes((uint)(i / 256 + 1)).ToList();
bytesBlock.AddRange(bytesList.GetRange(i, Math.Min(256, bytesList.Count - i)));
sendResult = SendManager.Send(gkDevice, (ushort)bytesBlock.Count(), 22, 0, bytesBlock);
if (sendResult.HasError)
{
Error = "Невозможно записать блок данных " + i;
break;
}
}
var endBlock = BitConverter.GetBytes((uint) (bytesList.Count()/256 + 1)).ToList();
sendResult = SendManager.Send(gkDevice, 0, 22, 0, endBlock);
if (sendResult.HasError)
{ Error = "Невозможно завершить запись файла "; }
}
示例3: GetParts
private static string[] GetParts(CacheKey[] namespaceCacheKeys, string[] keyParts)
{
List<string> returnList = new List<string>();
string[] versionKeys = namespaceCacheKeys.ConvertAll(key => key.ToString());
Getter<string>[] getters = new Getter<string>[namespaceCacheKeys.Length];
getters.Length.Times(i => getters[i] = () => Guid.NewGuid().ToString());
string[] versionValues = Caching.Instances.Main.MultiGet<string>(versionKeys, getters, DateTime.MaxValue);
returnList.AddRange(versionValues);
returnList.AddRange(keyParts);
return returnList.ToArray();
}
示例4: Receive
private void Receive(Socket sourceSocket)
{
try {
List<byte> bufferComplete = new List<byte>();
// TODO: Make configurable
byte[] bufferReceive = new byte[1024];
int bytesRead = sourceSocket.Receive(bufferReceive);
while (bytesRead > 0) {
bufferComplete.AddRange(bufferReceive.Take(bytesRead));
// TODO: Make configurable
for (int i = 0; i < 10; i++) {
Console.WriteLine("Is more data available: " + sourceSocket.Available);
if (sourceSocket.Available > 0) {
break;
}
// TODO: Make configurable
Thread.Sleep(100);
}
if (sourceSocket.Available == 0) {
break;
}
bytesRead = sourceSocket.Receive(bufferReceive);
}
Guid guid = WriteRequestToFile(bufferComplete.ToArray());
byte[] response = WaitForResponse(guid);
if (response != null) {
sourceSocket.Send(response);
Console.WriteLine("Returned data to client: " + response.Length);
}
} catch (Exception e) {
Console.WriteLine("Error: " + e);
} finally {
sourceSocket.Close();
}
}
示例5: CreateDeviceDependentResources
protected override void CreateDeviceDependentResources()
{
base.CreateDeviceDependentResources();
RemoveAndDispose(ref vertexBuffer);
// Retrieve our SharpDX.Direct3D11.Device1 instance
var device = this.DeviceManager.Direct3DDevice;
List<Vertex> vertices = new List<Vertex>();
vertices.AddRange(new[] {
new Vertex(0, 0, -4, Vector3.UnitY, Color.Blue),
new Vertex(0, 0, 4,Vector3.UnitY, Color.Blue),
new Vertex(-4, 0, 0, Vector3.UnitY, Color.Red),
new Vertex(4, 0, 0,Vector3.UnitY, Color.Red),
});
for (var i = -4f; i < -0.09f; i += 0.2f)
{
vertices.Add(new Vertex(i, 0, -4, Color.Gray));
vertices.Add(new Vertex(i, 0, 4, Color.Gray));
vertices.Add(new Vertex(-i, 0, -4, Color.Gray));
vertices.Add(new Vertex(-i, 0, 4, Color.Gray));
vertices.Add(new Vertex(-4, 0, i, Color.Gray));
vertices.Add(new Vertex(4, 0, i, Color.Gray));
vertices.Add(new Vertex(-4, 0, -i, Color.Gray));
vertices.Add(new Vertex(4, 0, -i, Color.Gray));
}
vertexCount = vertices.Count;
vertexBuffer = ToDispose(Buffer.Create(device, BindFlags.VertexBuffer, vertices.ToArray()));
}
示例6: MergeItems
private List<CalendarItem> MergeItems(List<CalendarItem> newItems, List<CalendarItem> fromRepo)
{
var result = new List<CalendarItem>();
var newModels = newItems.Except(fromRepo, new CalendarItemEqualityComparer()).ToList();
var updatet = fromRepo.Except(newModels,new CalendarItemEqualityComparer()).ToList();
updatet.ForEach(x =>
{
var model = newItems.FirstOrDefault(y => y.Id == x.Id);
if (model != null)
{
model.SyncStatus.CalenadCalendarItemStatus = IsModified(model, x)
? CalendarItemStatus.Updated
: CalendarItemStatus.Unmodified;
result.Add(model);
}
});
var deleted = fromRepo.Where(x => x.Start.Date >= DateTime.Now.Date).Except(newItems).Except(updatet);
newModels.ForEach(x => x.SyncStatus.CalenadCalendarItemStatus = CalendarItemStatus.New);
deleted.ForEach(x =>
{
x.SyncStatus.CalenadCalendarItemStatus = CalendarItemStatus.Deleted;
result.Add(x);
});
result.AddRange(newModels);
return result.OrderBy(x => x.Start).ToList();
}
示例7: Initialize
public static void Initialize(HttpConfiguration config)
{
var builder = new ContainerBuilder();
//some base interface register
//like dbcontext IRespository
IList<Assembly> assemblies = new List<Assembly>()
{
Assembly.Load("BaseService"),
Assembly.Load("SystematicWebApi")
};
var types = new List<Type>();
foreach (var item in assemblies)
{
types.AddRange(item.DefinedTypes.Where(o => typeof(IDependenceRegister).IsAssignableFrom(o)));
}
var registers = types.Select(type =>
type.Assembly.CreateInstance(type.FullName) as IDependenceRegister).ToList();
registers = registers.OrderBy(o => o.Order()).ToList();
foreach (var register in registers)
{
register.Register(builder);
}
var assembly = Assembly.GetCallingAssembly();
builder.RegisterApiControllers(assembly);
var container = builder.Build();
config.DependencyResolver = new AutofacWebApiDependencyResolver(container);
//DependencyResolver.SetResolver(new AutofacWebApiDependencyResolver(container));
}
示例8: GetCareerAbility
public static List<Ability_Info> GetCareerAbility(byte CareerLine, byte Level)
{
List<Ability_Info> Abilities = new List<Ability_Info>();
if (_CareerAbility.ContainsKey(CareerLine))
Abilities.AddRange(_CareerAbility[CareerLine].FindAll(info => info.Level <= Level));
return Abilities;
}
示例9: Run
public IEnumerable<string> Run()
{
List<string> errorMessages = new List<string>();
Database.SetInitializer(new DropCreateDatabaseAlways<FamilyMembersWithAttributes>());
var context = new FamilyMembersWithAttributes();
var chris = new Dad()
{
FirstName = "Chris this is a really long name........",
Address = new Address()
};
try
{
context.Dads.Add(chris);
errorMessages.AddRange(ValidationHelper.ExtractValidationMessages(context));
context.SaveChanges();
}
catch(DbEntityValidationException ex)
{
errorMessages.Add("Exception thrown when trying to save dad " + ex.ToString());
}
return errorMessages;
}
示例10: InitializeCameras
private void InitializeCameras()
{
LayoutPartCameraViews = new List<LayoutPartCameraView>();
var controls = new List<LayoutPartCameraView>();
GetLogicalChildCollection(_1X7GridView, controls);
LayoutPartCameraViews.AddRange(controls);
GetLogicalChildCollection(_2X2GridView, controls);
LayoutPartCameraViews.AddRange(controls);
GetLogicalChildCollection(_3X3GridView, controls);
LayoutPartCameraViews.AddRange(controls);
GetLogicalChildCollection(_4X4GridView, controls);
LayoutPartCameraViews.AddRange(controls);
GetLogicalChildCollection(_6X6GridView, controls);
LayoutPartCameraViews.AddRange(controls);
InitializeUIElement();
}
示例11: ReceiveAndCheckAsync
private static async Task ReceiveAndCheckAsync(UdpClient client, string expectedMessage)
{
var incomingBytes = new List<byte>();
var connectionReset=false;
try
{
do
{
var udpReceiveResult = await client.ReceiveAsync();
incomingBytes.AddRange(udpReceiveResult.Buffer);
} while (TcpMessenger.IsReadingShouldContinue(incomingBytes));
}
catch (SocketException ex)
{
if (ex.SocketErrorCode == SocketError.ConnectionReset)
{
connectionReset = true;
}
}
var actual = Encoding.UTF8.GetString(incomingBytes.ToArray());
if (connectionReset)
{
TcpMessenger.ErrorConnectionReset(actual);
}
else if (actual != expectedMessage)
{
TcpMessenger.ErrorWrongMessage(actual);
}
}
示例12: Index
public ActionResult Index(Guid? customerId, string keywords, bool? finish, int pageIndex = 1, int pageSize = 10)
{
var model = _iProjectInfoService.GetAll(a => a.Public);
if (customerId.HasValue)
model = model.Where(a => a.CustomerId == customerId);
if (!string.IsNullOrEmpty(keywords))
{
model =
model.Where(
a =>
a.ProjectName.Contains(keywords) || a.ProjectObjective.Contains(keywords) ||
a.Tag.Contains(keywords) || a.ProjectUsers.Any(b => b.SysUser.UserName == keywords));
}
if (finish.HasValue)
{
model = model.Where(a => a.Finish == finish);
}
//子项目
var subModel = model.Where(a => a.LastProjectInfoId != null);
//主项目
var mainModel = model.Where(a => a.LastProjectInfoId == null).ToPagedList(pageIndex, pageSize);
var mainList = new List<ProjectInfo>() { };
foreach (var item in mainModel)
{
mainList.Add(item);
mainList.AddRange((subModel as IQueryable<ProjectInfo>).Where(a => a.LastProjectInfoId == item.Id));
}
var result = mainList.Select(
a => new
{
a.Id,
a.UserId,
Leader = a.ProjectUsers != null ? a.ProjectUsers.Where(b => b.Leader).Select(b => b.SysUser.DisplayName) : null,
ProjectInfoState = a.ProjectInfoState != null ? a.ProjectInfoState.ProjectInfoStateName : null,
Follow = a.Public && (a.ProjectUsers!=null ? a.ProjectUsers.Any(b => b.SysUserId == _iUserInfo.UserId && b.Follow): false),
a.LastProjectInfoId,
a.Raty,
a.Public,
PlanCount = a.Plans.Count(p => !p.Deleted),
TaskCount = a.ProjectTasks.Count(t => !t.Deleted),
ReplyCount = a.ProjectInfoReplys.Count(r => !r.Deleted),
MemberCount = a.ProjectUsers != null ? a.ProjectUsers.Count(b => !b.Follow) : 0,
a.CustomerId,
a.Tag,
a.StarTime,
a.EndTime,
a.Finish,
a.ProjectName,
a.ProjectObjective,
a.CreatedDate
});
return Content(JsonConvert.SerializeObject(result), "text/json");
}
示例13: Start
public void Start()
{
while (true) {
// Wait for incoming request
string request = WaitForRequest();
// Send data to server
TcpClient client = new TcpClient(ApplicationConfiguration.HostDestinationUrl, ApplicationConfiguration.HostDestinationPort);
NetworkStream stream = client.GetStream();
byte[] bytesToSend = Constants.ENCODING_DEFAULT.GetBytes(request);
stream.Write(bytesToSend, 0, bytesToSend.Length);
// Receive data from server
// TODO: Make configurable
byte[] bufferReceive = new byte[8192];
List<byte> bufferComplete = new List<byte>();
int bytesRead = stream.Read(bufferReceive, 0, bufferReceive.Length);
while (bytesRead > 0) {
bufferComplete.AddRange(bufferReceive.Take(bytesRead));
// TODO: Make configurable
for (int i = 0; i < 10; i++) {
Console.WriteLine("Is more data available: " + stream.DataAvailable);
if (stream.DataAvailable) {
break;
}
// TODO: Make configurable
Thread.Sleep(100);
}
if (!stream.DataAvailable) {
break;
}
bytesRead = stream.Read(bufferReceive, 0, bufferReceive.Length);
}
client.Close();
WriteResponseToFile(bufferComplete.ToArray());
}
}
示例14: GetAllChildren
public static List<Device> GetAllChildren(Device device, bool isWithSelf = true)
{
var result = new List<Device>();
if (isWithSelf)
result.Add(device);
result.AddRange(device.Children.SelectMany(x => GetAllChildren(x)));
return result;
}
示例15: Send
public void Send(Socket socket, List<byte[]> sendBufferList)
{
List<byte> sendBuffer = new List<byte>();
for (int i = 0; i < sendBufferList.Count; i++)
{
sendBuffer.AddRange(sendBufferList[0]);
}
socket.Send(sendBuffer.ToArray());
}