本文整理汇总了C#中List.Merge方法的典型用法代码示例。如果您正苦于以下问题:C# List.Merge方法的具体用法?C# List.Merge怎么用?C# List.Merge使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类List
的用法示例。
在下文中一共展示了List.Merge方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteToFile
public override IEnumerable<string> WriteToFile(string outputFile, List<FeatureItemGroup> features, List<string> samples, string removeNamePrefix)
{
var result = base.WriteToFile(outputFile, features, samples, removeNamePrefix).ToList();
var ntaFile = Path.ChangeExtension(outputFile, ".NTA.count");
var isomiRFile = Path.ChangeExtension(outputFile, ".isomiR.count");
var isomiRntaFile = Path.ChangeExtension(outputFile, ".isomiR_NTA.count");
using (StreamWriter swNTA = new StreamWriter(ntaFile))
using (StreamWriter swIso = new StreamWriter(isomiRFile))
using (StreamWriter swIsoNTA = new StreamWriter(isomiRntaFile))
{
swNTA.WriteLine("Feature\tLocation\tSequence\t{0}", samples.Merge("\t"));
swIso.WriteLine("Feature\tLocation\tSequence\t{0}", samples.Merge("\t"));
swIsoNTA.WriteLine("Feature\tLocation\tSequence\t{0}", samples.Merge("\t"));
foreach (var feature in features)
{
OutputCount(swNTA, feature, samples, MirnaConsts.NO_OFFSET, true, "", removeNamePrefix);
OutputCount(swIso, feature, samples, 0, false, "_+_0", removeNamePrefix);
OutputCount(swIso, feature, samples, 1, false, "_+_1", removeNamePrefix);
OutputCount(swIso, feature, samples, 2, false, "_+_2", removeNamePrefix);
OutputCount(swIsoNTA, feature, samples, 0, true, "_+_0", removeNamePrefix);
OutputCount(swIsoNTA, feature, samples, 1, true, "_+_1", removeNamePrefix);
OutputCount(swIsoNTA, feature, samples, 2, true, "_+_2", removeNamePrefix);
}
}
result.Add(ntaFile);
result.Add(isomiRFile);
result.Add(isomiRntaFile);
return result;
}
示例2: Draw
public async Task Draw(IUserMessage msg, int num = 1)
{
var channel = (ITextChannel)msg.Channel;
var cards = AllDecks.GetOrAdd(channel.Guild, (s) => new Cards());
var images = new List<Image>();
var cardObjects = new List<Cards.Card>();
if (num > 5) num = 5;
for (var i = 0; i < num; i++)
{
if (cards.CardPool.Count == 0 && i != 0)
{
try { await channel.SendMessageAsync("No more cards in a deck.").ConfigureAwait(false); } catch (Exception ex) { _log.Warn(ex); }
break;
}
var currentCard = cards.DrawACard();
cardObjects.Add(currentCard);
using (var stream = File.OpenRead(Path.Combine(cardsPath, currentCard.ToString().ToLowerInvariant()+ ".jpg").Replace(' ','_')))
images.Add(new Image(stream));
}
MemoryStream bitmapStream = new MemoryStream();
images.Merge().SaveAsPng(bitmapStream);
bitmapStream.Position = 0;
//todo CARD NAMES?
var toSend = $"{msg.Author.Mention}";
if (cardObjects.Count == 5)
toSend += $" drew `{Cards.GetHandValue(cardObjects)}`";
await channel.SendFileAsync(bitmapStream, images.Count + " cards.jpg", toSend).ConfigureAwait(false);
}
示例3: DoFunc
public override Func<CommandEventArgs, Task> DoFunc() {
Random r = new Random();
return async e => {
if (e.Args[0] == "") {
int num1 = r.Next(0, 10);
int num2 = r.Next(0, 10);
Image[] images;
if (num1 == 0 && num2 == 0 && r.Next(0, 2) == 1) {
images = new Image[3] { GetDice(1), GetDice(0), GetDice(0) };
} else {
images = new Image[2] { GetDice(num1), GetDice(num2) };
}
Bitmap bitmap = images.Merge();
await e.Channel.SendFile("dice.png", bitmap.ToStream(ImageFormat.Png));
return;
} else {
try {
int num = int.Parse(e.Args[0]);
if (num < 1) num = 1;
if (num > 30) {
await e.Send("You can roll up to 30 dies at a time.");
num = 30;
}
List<Image> dices = new List<Image>(num);
List<int> values = new List<int>(num);
for (int i = 0; i < num; i++) {
int randomNumber = r.Next(1, 7);
int toInsert = dices.Count;
if (randomNumber == 6 || dices.Count == 0)
toInsert = 0;
else if (randomNumber != 1)
for (int j = 0; j < dices.Count; j++) {
if (values[j] < randomNumber) {
toInsert = j;
break;
}
}
dices.Insert(toInsert, GetDice(randomNumber));
values.Insert(toInsert, randomNumber);
}
Bitmap bitmap = dices.Merge();
await e.Send(values.Count + " Dies rolled. Total: **" + values.Sum() + "** Average: **" + (values.Sum() / (1.0f * values.Count)).ToString("N2") + "**");
await e.Channel.SendFile("dices.png", bitmap.ToStream(ImageFormat.Png));
} catch {
await e.Send("Please enter a number of dices to roll.");
return;
}
}
};
}
示例4: Add
public void Add(string message, List<KeyValuePair<string, string>> options)
{
defaults.Add(new KeyValuePair<string, string>("apikey", this.ProwlConfig.ApiKey));
List<KeyValuePair<string, string>> data = new List<KeyValuePair<string, string>>();
data.AddRange(options);
data = data.Merge(defaults);
data.Add(new KeyValuePair<string, string>("event", message));
this._api("add", data);
}
示例5: GetCategory
public static IList<Cms_Category> GetCategory(IList<Cms_Category> list)
{
IList<Cms_Category> result = new List<Cms_Category>();
var a = from p in list where string.IsNullOrEmpty(p.Pguid) select p;
IList<Cms_Category> rootlist = a.ToList<Cms_Category>();
foreach (var item in rootlist)
{
result.Add(item);
result = result.Merge(GetRecursionCateory(item.Fguid, list));
}
result.OrderBy(d => d.Categoryid);
return result;
}
示例6: GetModule
public static IList<Base_Module> GetModule(IList<Base_Module> list)
{
IList<Base_Module> result = new List<Base_Module>();
var a = from p in list where string.IsNullOrEmpty(p.Pguid) select p;
IList<Base_Module> rootlist = a.ToList<Base_Module>();
foreach (var item in rootlist)
{
result.Add(item);
result = result.Merge(GetRecursionModule(item.Fguid, list));
}
result.OrderBy(d => d.Moduleno);
return result;
}
示例7: GetKeywordSql
private string GetKeywordSql()
{
if (Keywords.Length == 0)
{
return string.Empty;
}
var sqls = new List<string>();
sqls.Add(GetSql("gse.title", this.Keywords));
sqls.Add(GetSql("gse.summary", this.Keywords));
sqls.Add(GetSql("gse.type", this.Keywords));
sqls.Add(GetSql("gse.overall_design", this.Keywords));
return sqls.Merge(" or ");
}
示例8: WriteToFile
public virtual IEnumerable<string> WriteToFile(string outputFile, List<FeatureItemGroup> features, List<string> samples, string removeNamePrefix)
{
using (StreamWriter sw = new StreamWriter(outputFile))
{
//sw.NewLine = Environment.NewLine;
sw.WriteLine("Feature\tLocation\tSequence\t{0}", samples.Merge("\t"));
foreach (var feature in features)
{
OutputCount(sw, feature, samples, MirnaConsts.NO_OFFSET, false, "", removeNamePrefix);
}
}
string readFile = WriteReadCountTable(outputFile, features, samples);
return new[] { outputFile, readFile };
}
示例9: DoFunc
public override Func<CommandEventArgs, Task> DoFunc() => async (e) =>
{
if (cards == null)
{
await e.Send("Shuffling cards...");
cards = new Cards();
}
try
{
int num = 1;
var isParsed = int.TryParse(e.GetArg("count"), out num);
if (!isParsed || num < 2)
{
var c = cards.DrawACard();
await e.Channel.SendFile(c.Name +".jpg",(Properties.Resources.ResourceManager.GetObject(c.Name) as Image).ToStream());
return;
}
if (num > 5)
num = 5;
List<Image> images = new List<Image>();
List<Cards.Card> cardObjects = new List<Cards.Card>();
for (int i = 0; i < num; i++)
{
if (cards.CardPool.Count == 0 && i != 0)
{
await e.Send("No more cards in a deck.");
break;
}
var currentCard = cards.DrawACard();
cardObjects.Add(currentCard);
images.Add(Properties.Resources.ResourceManager.GetObject(currentCard.Name) as Image);
}
Bitmap bitmap = images.Merge();
await e.Channel.SendFile(images.Count + " cards.jpg", bitmap.ToStream());
if (cardObjects.Count == 5)
{
await e.Send(Cards.GetHandValue(cardObjects));
}
}
catch (Exception ex)
{
Console.WriteLine("Error drawing (a) card(s) " + ex.ToString());
}
};
示例10: GetRecursionModule
private static IList<Base_Module> GetRecursionModule(string fguid, IList<Base_Module> list)
{
IList<Base_Module> result = new List<Base_Module>();
var a = from p in list where p.Pguid == fguid select p;
IList<Base_Module> sublist = a.ToList<Base_Module>();
char nbsp = (char)0xA0;
foreach (var item in sublist)
{
int nodenolen = item.Moduleno.Length;
string text = "∟" + item.Title.Trim();
int len = nodenolen * 2 + text.Length-5;
item.Title = text.PadLeft(len, nbsp);
result.Add(item);
result = result.Merge(GetRecursionModule(item.Fguid, list));
}
return result;
}
示例11: GetRecursionCateory
private static IList<Cms_Category> GetRecursionCateory(string fguid, IList<Cms_Category> list)
{
IList<Cms_Category> result = new List<Cms_Category>();
var a = from p in list where p.Pguid == fguid select p;
IList<Cms_Category> sublist = a.ToList<Cms_Category>();
char nbsp = (char)0xA0;
foreach (var item in sublist)
{
int nodenolen = item.Categoryid.Length;
string text = "∟" + item.Title.Trim();
int len = nodenolen + text.Length;
item.Title = text.PadLeft(len, nbsp);
result.Add(item);
result = result.Merge(GetRecursionCateory(item.Fguid, list));
}
return result;
}
示例12: DrawCardFunc
private Func<CommandEventArgs, Task> DrawCardFunc() => async (e) =>
{
var cards = AllDecks.GetOrAdd(e.Server, (s) => new Cards());
try
{
var num = 1;
var isParsed = int.TryParse(e.GetArg("count"), out num);
if (!isParsed || num < 2)
{
var c = cards.DrawACard();
await e.Channel.SendFile(c.Name + ".jpg", (Properties.Resources.ResourceManager.GetObject(c.Name) as Image).ToStream()).ConfigureAwait(false);
return;
}
if (num > 5)
num = 5;
var images = new List<Image>();
var cardObjects = new List<Cards.Card>();
for (var i = 0; i < num; i++)
{
if (cards.CardPool.Count == 0 && i != 0)
{
await e.Channel.SendMessage("No more cards in a deck.").ConfigureAwait(false);
break;
}
var currentCard = cards.DrawACard();
cardObjects.Add(currentCard);
images.Add(Properties.Resources.ResourceManager.GetObject(currentCard.Name) as Image);
}
var bitmap = images.Merge();
await e.Channel.SendFile(images.Count + " cards.jpg", bitmap.ToStream()).ConfigureAwait(false);
if (cardObjects.Count == 5)
{
await e.Channel.SendMessage($"{e.User.Mention} `{Cards.GetHandValue(cardObjects)}`").ConfigureAwait(false);
}
}
catch (Exception ex)
{
Console.WriteLine("Error drawing (a) card(s) " + ex.ToString());
}
};
示例13: TestMerge
public void TestMerge()
{
Document doc = Application.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
Editor ed = doc.Editor;
var selRes = ed.Select("Выбери полилинии для объединения");
if (selRes.Count==0) return;
using (var t = db.TransactionManager.StartTransaction())
{
var pls = new List<Polyline>();
foreach (var item in selRes)
{
if (!item.IsValidEx()) continue;
var pl = item.GetObject(OpenMode.ForRead) as Polyline;
if (pl != null)
{
pls.Add(pl);
}
}
try
{
var plMerged = pls.Merge();
var cs = db.CurrentSpaceId.GetObject(OpenMode.ForWrite) as BlockTableRecord;
cs.AppendEntity(plMerged);
t.AddNewlyCreatedDBObject(plMerged, true);
plMerged.ColorIndex = 5;
}
catch(System.Exception ex)
{
Application.ShowAlertDialog(ex.ToString());
}
t.Commit();
}
}
示例14: WriteToFile
private static void WriteToFile(string fileName, List<RockhopperTranscriptResult> data, List<string> genes, Func<RockhopperTranscript, bool> significantFilter)
{
using (var sw = new StreamWriter(fileName))
{
sw.Write("Gene,Product");
foreach (var d in data)
{
sw.Write(",{0}_RPKM_{1},{0}_RPKM_{2},{0}_log2({1}/{2}),{0}_qValue", d.ComparisonName, d.Group1, d.Group2);
}
sw.WriteLine(",Significant");
foreach (var gene in genes)
{
sw.Write(gene);
var synonym = gene.StringBefore(",");
List<string> significant = new List<string>();
foreach (var d in data)
{
if (d.UnpredictedMap.ContainsKey(synonym))
{
var entry = d.UnpredictedMap[synonym];
sw.Write(",{0},{1},{2:0.00},{3}", entry.RPKM1, entry.RPKM2, entry.FoldChange, entry.Qvalue);
if (significantFilter(entry))
{
significant.Add(d.ComparisonName);
}
}
else
{
sw.Write(",0,0,0,1");
}
}
sw.WriteLine(",{0}", significant.Merge(";"));
}
}
}
示例15: GenerateWatchers
private IObservable<EventPattern<FileSystemEventArgs>> GenerateWatchers()
{
var observables = new List<IObservable<EventPattern<FileSystemEventArgs>>>();
foreach (Directory directory in _configuration.Watch)
{
if (!System.IO.Directory.Exists(directory.Path)) continue;
var watcher = new FileSystemWatcher(directory.Path)
{
IncludeSubdirectories = directory.IncludeSubDirs,
EnableRaisingEvents = false
};
_watchers.Add(watcher);
foreach (var listenerType in directory.GetListenerTypes())
{
IObservable<EventPattern<FileSystemEventArgs>> observable;
switch (listenerType)
{
case ListenerType.Created:
observable =
Observable.FromEventPattern<FileSystemEventHandler, FileSystemEventArgs>(
ev => watcher.Created += ev, ev => watcher.Created -= ev);
observables.Add(observable);
break;
case ListenerType.Changed:
observable = Observable.FromEventPattern<FileSystemEventHandler, FileSystemEventArgs>(
ev => watcher.Changed += ev, ev => watcher.Changed -= ev);
observables.Add(observable);
break;
case ListenerType.Deleted:
observable = Observable.FromEventPattern<FileSystemEventHandler, FileSystemEventArgs>(
ev => watcher.Deleted += ev, ev => watcher.Deleted -= ev);
observables.Add(observable);
break;
case ListenerType.Renamed:
var renamedObservable = Observable.FromEventPattern<RenamedEventHandler, RenamedEventArgs>(
ev => watcher.Renamed += ev, ev => watcher.Renamed -= ev);
observables.Add(
renamedObservable.Select(
evpat => new EventPattern<FileSystemEventArgs>(evpat.Sender, evpat.EventArgs)));
break;
}
}
}
var mergedObservables = observables.Merge();
return mergedObservables;
}