Member 12928891
// The main thing I can add to this is that a LINQ query is almost always faster than a loop such as a foreach, etc. Here are a couple of prime examples in optimized code form.
// Try to use queries rather than loops.
/// <summary> This one accepts the Collection of Dictionaries for
/// ViewAllAssociations(); Has it's own special Size & Location Settings.
/// It directly calls the Mother Method of them all below this one.
/// NOTE: "var x = ..." below does a ton of work,
/// & faster because instead of a loop it's a LINQ query!
///
/// <param name="listOfLists">
private static void DisplayResults
(IEnumerable<Dictionary<string, string>> listOfLists)
{
#region was
//var i = 0;
//var text = "";
//foreach (var dic in listOfLists)
//{
//// if (i == reportsListBox.Items.Count) break;
// text += GetDisplayString(dic, reportsListBox.Items[i++].ToString());
//}
#endregion was
var i = 0;
var
x = listOfLists.Aggregate("", (current, dic) => current +
GetDisplayString(dic, OPS.Default.reportsListBoxItems[i++]));
const string t = "";
var s = AUS.Default.OMA_D4_S;
var l = AUS.Default.OMA_D4_L;
DisplayResults(x, t, ref s, ref l);
AUS.Default.OMA_D4_S = s;
AUS.Default.OMA_D4_L = l;
AUS.Default.Save();
}
/// <summary> This overload is where all end up.
/// It allows for total flexibility of usages for all args.
/// While providing critical defaults to reduce duplicity.
/// if title is empty it defaults to:
/// "Folder Associations Information:"
///
/// <param name="x">
/// <param name="t">
/// <param name="s">
/// <param name="l">
private static void DisplayResults
(string x, string t, ref Size s, ref Point l)
{
if (string.IsNullOrEmpty(t)) t =
"Folder Associations Information:";
using (var f = new ShowMeForm(x, t))
{
f.Size = s;
f.Location = l;
f.ShowDialog();
l = f.Location;
s = f.Size;
}
}
/// <summary> This was split out so it can be used by both
/// the View2Associations and the ViewAllAssociations: v4.7.3.75
/// Added the string dir arg to the sig to interface it with both.
///
/// <param name="dic">
/// <param name="dir">
/// <returns>
private static string GetDisplayString
(Dictionary<string, string> dic, string dir)
{ // Sweet! Great integration.
#region Was
//foreach (var pair in list)
//{
// // Concatenate the text string and show it.
// text += "The Data Folder:\n" + pair.Key +
// "\n\nWhich is set to the Data file: \n" +
// pair.Value + "\n\n";
//}
#endregion Was
string
title = string.Format("\nResults for: {0}\n\n", dir),
text = title +
"The following currently use this Reports Folder:\n\n";
return
dic.Aggregate(text, (current, pair) => current +
("The Data Folder:\n" + pair.Key +
"\n\nWhich is set to the Data file: \n" +
pair.Value + "\n\n"));
}
// Whereever it says .Aggregate here are good examples and it can be many Types.
// Take the first one:
// var x = listOfLists.Aggregate blah blah...
// Think for a minute what that is doing, it's iterating through a Collection of Dictionary Collections and getting the appropriate string for each and very very rapidly and efficiently!
// Follow the code path through that down to this other one above and you will see what I mean. From the Collection of Dictionaries down to this does a LOT.
[no name]
Если вы собираетесь продолжать без необходимости воскрешать древние уже отвеченные "вопросы", несмотря на то, что вам сказали не делать этого, вы могли бы, по крайней мере, предоставить точную информацию.