本文整理汇总了C#中Library.List.AddRange方法的典型用法代码示例。如果您正苦于以下问题:C# List.AddRange方法的具体用法?C# List.AddRange怎么用?C# List.AddRange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Library.List
的用法示例。
在下文中一共展示了List.AddRange方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Install
public override void Install(IDictionary stateSaver)
{
base.Install(stateSaver);
var installdir = GetParameter("targetdir");
string msg = "";
foreach (var k in Context.Parameters.Keys)
msg += (k + "\n");
msg += "VALUES:\n";
foreach (var v in Context.Parameters.Values)
msg += (v + "\n");
//MessageBox.Show(msg);
List<string> writeableDirs = new List<string>();
string configDir = Path.Combine(Path.Combine(installdir, "Myro"), "config");
string storeDir = Path.Combine(Path.Combine(installdir, "Myro"), "store");
writeableDirs.Add(configDir);
writeableDirs.Add(storeDir);
writeableDirs.AddRange(Directory.GetDirectories(configDir, "*", SearchOption.AllDirectories));
writeableDirs.AddRange(Directory.GetDirectories(storeDir, "*", SearchOption.AllDirectories));
string dirs = "";
foreach (var d in writeableDirs)
{
dirs += (d + "\n");
if (GrantModifyAccessToFolder("Everyone", d) != true)
throw new Exception("Couldn't make " + d + " writeable");
}
//MessageBox.Show("Made writeable:\n" + dirs);
}
示例2: DownloadAllVideos
public void DownloadAllVideos(PDownload pDownload)
{
Broadcasts broadcasts = GetBroadcasts(pDownload.User);
broadcasts.broadcasts = broadcasts.broadcasts.Where(b => b.available_for_replay || b.state == "RUNNING").ToList();
if (pDownload.IsReverseOrder) broadcasts.broadcasts.Reverse();
#region Selected Videos
List<int> selectedVideos = pDownload.SelectedVideos;
if (selectedVideos.Any())
{
List<Broadcast> selectedBroadcasts = new List<Broadcast>();
selectedBroadcasts.AddRange(selectedVideos.Select(selectedVideo => broadcasts.broadcasts[selectedVideo]));
broadcasts.broadcasts = selectedBroadcasts.ToList();
}
#endregion
#region Selected Broadcasts
List<string> selectedBroadcastsText = pDownload.SelectedBroadcasts;
if (selectedBroadcastsText.Any())
{
broadcasts.broadcasts =
selectedBroadcastsText.Select(
selectedBroadcast => broadcasts.broadcasts.First(b => b.id == selectedBroadcast)).ToList();
}
#endregion
Console.WriteLine(broadcasts.broadcasts.Count + " broadcasts found.");
foreach (var broadcast in broadcasts.broadcasts)
{
DownloadVideos(broadcast, pDownload.DownloadLiveStream);
}
}
示例3: GetData
public byte[] GetData()
{
List<byte> result = new List<byte>();
byte[] byteLabel = Encoding.ASCII.GetBytes(Label);
Writer.AddBytes(result, byteLabel);
foreach (Frame frame in Frames)
{
result.AddRange(frame.GetData());
}
return result.ToArray();
}
示例4: GetFiles
private static List<FileItem> GetFiles(DirectoryInfo directory)
{
List<FileItem> files = new List<FileItem>();
foreach (FileInfo file in directory.GetFiles())
{
files.Add(new FileItem(file));
}
foreach (DirectoryInfo dir in directory.GetDirectories())
{
files.AddRange(GetFiles(dir));
}
return files;
}
示例5: GenerateReport
private List<string> GenerateReport()
{
if (!Files.Any()) return null;
var fileHelper = new FileHelper();
var days = Files.Select(fileHelper.GetEntries).ToList();
var lines = new List<string>();
var runningTotal = new TimeSpan(0, 0, 0, 0);
foreach (var d in days)
{
lines.AddRange(d.Select(entry => entry.ToString()));
var hours = d.Sum(te => te.Hours);
var minutes = d.Sum(te => te.Minutes);
var seconds = d.Sum(te => te.Seconds);
var ts = new TimeSpan(0, hours, minutes, seconds);
runningTotal = runningTotal.Add(ts);
lines.Add(string.Format("---- Total Time For Day ---- {0}:{1:D2}:{2:D2} ---------------", ts.Hours, ts.Minutes,
ts.Seconds));
}
lines.Add(string.Format("---- Total Time For All Days Selected ---- {0}:{1:D2}:{2:D2} ---------------",
(runningTotal.Days * 24 + runningTotal.Hours), runningTotal.Minutes,
runningTotal.Seconds));
return lines;
}
示例6: GetData
public List<byte> GetData()
{
List<byte> result = new List<byte>();
byte[] byteLabel = Encoding.ASCII.GetBytes(Label);
Writer.AddBytes(result, byteLabel);
//write the size of the rest at the end
Writer.AddBytes(result, BitPlane.Width);
Writer.AddBytes(result, Height);
Writer.AddBytes(result, Origin.X);
Writer.AddBytes(result, Origin.Y);
result.Add((byte)Direction);
//now write the bitmask
result.AddRange(BitPlane.GetData());
//write the indexes to the palette
//first the size since it will usually be less than the bitplane bit count
Writer.AddBytes(result, BitPlane.GetPixelCount() - 1);
//then the actual indexes
result.AddRange(GetDataList());
//int size = result.Count - 2;
//now insert the size
Writer.WriteSizeShort(result);
return result;
}
示例7: ArrayList
private void _路线属性_VisibilityChange(bool isvisible)
{
ListBoxEx innerControl = this._路线属性.InnerControl as ListBoxEx;
if (!isvisible)
{
string str = "";
new List<string>();
ListBox.SelectedObjectCollection selectedItems = innerControl.SelectedItems;
int count = innerControl.Items.Count;
ArrayList list = new ArrayList(count);
int val = 0;
for (int i = 0; i < count; i++)
{
if (selectedItems.Contains(innerControl.Items[i]))
{
ListBoxItem item = innerControl.Items[i] as ListBoxItem;
val |= Convert.ToInt32(item.Tag.ToString());
str = str + item.Name.ToString() + ",";
}
}
this.setTimeSpeedReadOnly(this.dgvSubSpeedParam.CurrentRow, val);
list.Add(Convert.ToString(val, 2).PadLeft(6, '0').ToCharArray());
if (this.dgvSubSpeedParam.CurrentCell != null)
{
try
{
this.dgvSubSpeedParam.CurrentCell.Value = str.Trim(",".ToCharArray());
this.dgvSubSpeedParam.CurrentCell.Tag = list;
}
catch (Exception)
{
}
}
}
else
{
innerControl.ClearSelected();
if (this.dgvSubSpeedParam.CurrentCell.Tag == null)
{
List<string> list2 = new List<string>();
list2.AddRange(this.dgvSubSpeedParam.CurrentCell.Value.ToString().Split(",".ToCharArray()));
int num4 = innerControl.Items.Count;
for (int j = 0; j < num4; j++)
{
ListBoxItem item2 = innerControl.Items[j] as ListBoxItem;
if (list2.Contains(item2.Name))
{
innerControl.SetSelected(j, true);
}
}
}
else if (this.dgvSubSpeedParam.CurrentCell.Tag != null)
{
ArrayList tag = this.dgvSubSpeedParam.CurrentCell.Tag as ArrayList;
if ((tag[0] as char[])[0].ToString().Equals("1"))
{
innerControl.SetSelected(4, true);
}
else
{
innerControl.SetSelected(4, false);
}
if ((tag[0] as char[])[1].ToString().Equals("1"))
{
innerControl.SetSelected(3, true);
}
else
{
innerControl.SetSelected(3, false);
}
if ((tag[0] as char[])[2].ToString().Equals("1"))
{
innerControl.SetSelected(2, true);
}
else
{
innerControl.SetSelected(2, false);
}
if ((tag[0] as char[])[3].ToString().Equals("1"))
{
innerControl.SetSelected(1, true);
}
else
{
innerControl.SetSelected(1, false);
}
if ((tag[0] as char[])[5].ToString().Equals("1"))
{
innerControl.SetSelected(0, true);
}
else
{
innerControl.SetSelected(0, false);
}
}
}
}
示例8: GetData
public List<byte> GetData()
{
List<byte> result = new List<byte>();
byte[] byteLabel = Encoding.ASCII.GetBytes(Label);
Writer.AddBytes(result, byteLabel);
//write the size of the rest at the end
Writer.AddBytes(result, Width);
Writer.AddBytes(result, Height);
Writer.AddBytes(result, Origin.X);
Writer.AddBytes(result, Origin.Y);
result.Add((byte)Direction);
//then the actual indexes
result.AddRange(GetDataList());
//now insert the size
Writer.WriteSizeShort(result);
return result;
}
示例9: ArrayList
private void _区域属性_VisibilityChange(bool isvisible)
{
ListBoxEx innerControl = this._区域属性.InnerControl as ListBoxEx;
if (!isvisible)
{
string str = "";
new List<string>();
ListBox.SelectedObjectCollection selectedItems = innerControl.SelectedItems;
int count = innerControl.Items.Count;
ArrayList val = new ArrayList(count);
for (int i = 0; i < count; i++)
{
string str2 = "";
if (selectedItems.Contains(innerControl.Items[i]))
{
str2 = "1";
ListBoxItem item = innerControl.Items[i] as ListBoxItem;
str = str + item.Name.ToString() + ",";
}
else
{
str2 = "0";
}
val.Add(str2);
}
this.setTimeSpeedReadOnly(this.dgvArea.CurrentRow, val);
if (this.dgvArea.CurrentCell != null)
{
this.dgvArea.CurrentCell.Value = str.Trim(",".ToCharArray());
this.dgvArea.CurrentCell.Tag = val;
}
}
else
{
innerControl.ClearSelected();
if (this.dgvArea.CurrentCell.Tag == null)
{
List<string> list2 = new List<string>();
list2.AddRange(this.dgvArea.CurrentCell.Value.ToString().Split(",".ToCharArray()));
int num3 = innerControl.Items.Count;
for (int j = 0; j < num3; j++)
{
ListBoxItem item2 = innerControl.Items[j] as ListBoxItem;
if (list2.Contains(item2.Name))
{
innerControl.SetSelected(j, true);
}
}
}
else if (this.dgvArea.CurrentCell.Tag != null)
{
ArrayList tag = this.dgvArea.CurrentCell.Tag as ArrayList;
for (int k = 0; k < innerControl.Items.Count; k++)
{
innerControl.SetSelected(k, tag[k].ToString().Equals("1"));
}
}
}
}
示例10: GetData
public byte[] GetData()
{
List<byte> result = new List<byte>();
byte[] byteLabel = Encoding.ASCII.GetBytes(Label);
Writer.AddBytes(result, byteLabel);
foreach (Chunk chunk in Chunks)
{
result.AddRange(chunk.GetData());
}
//don't forget the size
Writer.WriteSizeInt(result);
return result.ToArray();
}
示例11: UpdateChunklist
private void UpdateChunklist(Broadcast broadcast, string baseUrl, ref List<string> playlist, ref bool liveStream)
{
List<string> currentChunks;
try
{
currentChunks = GetPlaylistUrls(baseUrl + "chunklist.m3u8");
}
catch (Exception)
{
liveStream = false;
return;
}
playlist.AddRange(currentChunks.Except(playlist));
playlist = playlist.Except(_localFileActions.GetValidFiles(broadcast.username, broadcast.id)).ToList();
}
示例12: GetData
public List<byte> GetData()
{
List<byte> result = new List<byte>();
byte[] byteLabel = Encoding.ASCII.GetBytes(Label);
Writer.AddBytes(result, byteLabel);
//write the size of the rest at the end
Writer.AddBytes(result, BitPlane.Width);
Writer.AddBytes(result, Height);
Writer.AddBytes(result, Origin.X);
Writer.AddBytes(result, Origin.Y);
//now write the bitmask
result.AddRange(BitPlane.GetData());
//now insert the size
Writer.WriteSizeShort(result);
return result;
}
示例13: RenderPicture
private void RenderPicture(Graphics g)
{
var angleOffset = -Math.PI / 2;
var anglePerStudent = Math.PI * 2 / _students.Count;
var center = new Point(_width / 2, _height / 2);
var maxRadius = Math.Min(center.X, center.Y) * _ratio / 100.0f;
Func<int, float, float, Point> getPoint = (id, delta, lRadius) =>
{
var radius = maxRadius * lRadius / 100.0f;
var angle = angleOffset + anglePerStudent * (id + delta / 100.0f);
return center + new Size((int)(radius * Math.Cos(angle)), (int)(radius * Math.Sin(angle)));
};
Func<float, Rectangle> getRectangle = lRadius =>
{
var delta = maxRadius*lRadius/100.0f;
return new Rectangle((int)(center.X - delta), (int)(center.Y - delta), (int) (2*delta), (int) (2*delta));
};
Func<double, float> toDeg = rad => (float) (rad / Math.PI * 180);
// Пороговые линии
for (var j = 0; j < _grades.Count; ++j)
{
g.DrawPie(new Pen(Color.Black, j == (_grades.Count - 1) ? 4 : 2) {DashPattern = new[] {3.0f, 5.0f}},
getRectangle(_grades[j]), 0.0f, 360.0f);
}
// Основные и дополнительные зависимости
for (var i = 0; i < _students.Count; ++i)
{
var grades = _students[i].Grades;
var mainGrades = (_mode == Mode.Pie || _mode == Mode.Pie)
? new[]{0.0f}.Concat(grades[0]).ToList()
: Enumerable.Range(0, grades[0].Length + 1).Select(a => a * 100.0f / grades[0].Length).ToList();
// Основная зависимость
for (var j = mainGrades.Count - 1; j >= 1; --j)
{
if (Math.Abs(mainGrades[j]) > Parameters.Tolerance)
{
var brush = GetBrush(j, grades);
g.FillPie(brush, getRectangle(mainGrades[j]),
toDeg(angleOffset + anglePerStudent * i), toDeg(anglePerStudent));
g.DrawPie(new Pen(Color.Black, 2), getRectangle(mainGrades[j]),
toDeg(angleOffset + anglePerStudent * i), toDeg(anglePerStudent));
}
}
// Дополнительные зависимости
for (var k = 1; k < grades.Length; ++k)
{
var addGrades = new List<float> {0.0f};
addGrades.AddRange(grades[k]);
if (addGrades.All(a => a < Parameters.Tolerance))
continue;
for (var j = 0; j < addGrades.Count - 1; ++j)
g.DrawLine(_additionalData[(k - 1) % _additionalData.Count],
getPoint(i, addGrades[j], mainGrades[j]),
getPoint(i, addGrades[j + 1], mainGrades[j + 1]));
}
}
// Разделительные линии между секторами
for (var i = 0; i < _students.Count; ++i)
{
g.DrawLine(new Pen(Color.Black, 2), center, getPoint(i, 0, 110));
}
// Разделители между секторами
for (var j = 0; j < _part.Count; ++j)
{
g.DrawLine(new Pen(Color.Black, 6), center, getPoint(_part[j], 0, 110));
}
var half = (int)Math.Ceiling(_students.Count / 2.0);
// Имена студентов
for (var i = 0; i < _students.Count; ++i)
{
var posRight = i < half;
var point = getPoint(i, 50, 0.6f * maxRadius);
var message = string.Format("{0} ({1})", _students[i].Name, _students[i].Info);
g.DrawString(message, _font, Brushes.Black, point, posRight ? _rightFormat : _leftFormat);
}
var lOffset = new Point(470, 30);
var lOffset2 = center + new Size(lOffset.X, lOffset.Y);
const int lSize = 30;
if (_mode == Mode.BlackRound || _mode == Mode.ColorRound)
{
lOffset = new Point(530, 30);
lOffset2 = center + new Size(lOffset.X, lOffset.Y);
//.........这里部分代码省略.........
示例14: ConnectionsManagerThread
//.........这里部分代码省略.........
{
_settings.DiffusionBlocksRequest.Remove(key);
}
}
}
}
// 存在しないブロックのKeyをRemoveする。
lock (this.ThisLock)
{
lock (_settings.DiffusionBlocksRequest.ThisLock)
{
foreach (var key in _cacheManager.ExceptFrom(_settings.DiffusionBlocksRequest.ToArray()).ToArray())
{
_settings.DiffusionBlocksRequest.Remove(key);
}
}
lock (_settings.UploadBlocksRequest.ThisLock)
{
foreach (var key in _cacheManager.ExceptFrom(_settings.UploadBlocksRequest.ToArray()).ToArray())
{
_settings.UploadBlocksRequest.Remove(key);
}
}
}
var baseNode = this.BaseNode;
var otherNodes = new List<Node>();
lock (this.ThisLock)
{
otherNodes.AddRange(_connectionManagers.Select(n => n.Node));
}
var messageManagers = new Dictionary<Node, MessageManager>();
foreach (var node in otherNodes)
{
messageManagers[node] = _messagesManager[node];
}
var diffusionBlocksList = new List<Key>();
{
{
var array = _settings.UploadBlocksRequest.ToArray();
_random.Shuffle(array);
int count = 256;
for (int i = 0; i < count && i < array.Length; i++)
{
diffusionBlocksList.Add(array[i]);
}
}
{
var array = _settings.DiffusionBlocksRequest.ToArray();
_random.Shuffle(array);
int count = 256;
for (int i = 0; i < count && i < array.Length; i++)
{
示例15: UpdateFiles
public void UpdateFiles()
{
List<FileItem> files = new List<FileItem>();
List<FileItem> filesDownload = new List<FileItem>();
FileInfo fileinfo = new FileInfo(_updatePath);
foreach (FileCollection col in _downloadcollections)
{
files.AddRange(col.Files);
}
AddToLog(files.Count + " files marked for check.");
_progressVerify.Maximum = files.Count;
_progressVerify.Value = 0;
_progressTotalDownload.Value = 0;
_progressFileDownload.Value = 0;
if (Library.SystemSettings.isDebuggingEnabled)
{
this.AddToLog("Starting file check", false);
}
foreach (FileItem f in files)
{
//build the stringname
string FullPath = fileinfo.DirectoryName + f.Directory + f.Filename;
if (File.Exists(FullPath))
{
//initiate a CRC object
CRC32 crc = new CRC32();
//check debug settings
if (Library.SystemSettings.isDebuggingEnabled)
{
this.AddToLog(" File: " + FullPath);
}
else
{
this.AddToLog(f.Directory + f.Filename);
}
//the file crc
string fileCRC = "";
//open a link to the file
using (Stream reader = new FileStream(FullPath, FileMode.Open, FileAccess.Read))
{
//go though each byte
foreach (byte b in crc.ComputeHash(reader))
{
//build the crc string
fileCRC += b.ToString("x2").ToLower();
}
}
//check debug settings
if (Library.SystemSettings.isDebuggingEnabled)
{
this.AddToLog("System CRC: " + fileCRC);
this.AddToLog(" XML CRC: " + f.FileCRC);
}
//check if they are matching
if (fileCRC != f.FileCRC)
{
filesDownload.Add(f);
if (Library.SystemSettings.isDebuggingEnabled)
{
this.AddToLog(" Status: Marked for download");
this.AddToLog("", false);
}
}
else
{
if (Library.SystemSettings.isDebuggingEnabled)
{
this.AddToLog(" Status: No action required");
this.AddToLog("", false);
}
}
}
else
{
filesDownload.Add(f);
if (Library.SystemSettings.isDebuggingEnabled)
{
this.AddToLog(" File: " + FullPath);
this.AddToLog(" Status: Marked for download");
this.AddToLog("", false);
}
else
{
this.AddToLog(f.Directory + f.Filename);
//.........这里部分代码省略.........