本文整理汇总了C#中System.Collections.Specialized.ListDictionary.Contains方法的典型用法代码示例。如果您正苦于以下问题:C# ListDictionary.Contains方法的具体用法?C# ListDictionary.Contains怎么用?C# ListDictionary.Contains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.Specialized.ListDictionary
的用法示例。
在下文中一共展示了ListDictionary.Contains方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BasicTests
private void BasicTests (ListDictionary ld)
{
Assert.AreEqual (0, ld.Count, "Count");
Assert.IsFalse (ld.IsFixedSize, "IsFixedSize");
Assert.IsFalse (ld.IsReadOnly, "IsReadOnly");
Assert.IsFalse (ld.IsSynchronized, "IsSynchronized");
Assert.AreEqual (0, ld.Keys.Count, "Keys");
Assert.AreEqual (0, ld.Values.Count, "Values");
Assert.IsNotNull (ld.SyncRoot, "SyncRoot");
Assert.IsNotNull (ld.GetEnumerator (), "GetEnumerator");
Assert.IsNotNull ((ld as IEnumerable).GetEnumerator (), "IEnumerable.GetEnumerator");
ld.Add ("a", "1");
Assert.AreEqual (1, ld.Count, "Count-1");
Assert.IsTrue (ld.Contains ("a"), "Contains(a)");
Assert.IsFalse (ld.Contains ("1"), "Contains(1)");
ld.Add ("b", null);
Assert.AreEqual (2, ld.Count, "Count-2");
Assert.IsNull (ld["b"], "this[b]");
DictionaryEntry[] entries = new DictionaryEntry[2];
ld.CopyTo (entries, 0);
ld["b"] = "2";
Assert.AreEqual ("2", ld["b"], "this[b]2");
ld.Remove ("b");
Assert.AreEqual (1, ld.Count, "Count-3");
ld.Clear ();
Assert.AreEqual (0, ld.Count, "Count-4");
}
示例2: AreNamesUnique
/// <summary>
/// Returns true if all items in <paramref name="names0"/> and <paramref name="names1"/> are
/// unique strings. Case sensitivity consideration depends on <paramref name="ignoreCase"/>.
/// </summary>
/// <param name="names0">An array of strings.</param>
/// <param name="names1">An array of strings.</param>
/// <param name="ignoreCase">If true then case is not considered when comparing strings.</param>
/// <returns>bool</returns>
public static bool AreNamesUnique(string[] names0, string[] names1, bool ignoreCase)
{
bool result = true;
if (names0 == null && names1 == null)
return result;
ListDictionary dic = new ListDictionary(StringComparer.Create(new CultureInfo("en"), ignoreCase));
for (int i = 0; i < names0.Length; i++)
{
if (dic.Contains(names0[i]))
{
result = false;
break;
}
dic.Add(names0[i], null);
}
for (int i = 0; i < names1.Length; i++)
{
if (dic.Contains(names1[i]))
{
result = false;
break;
}
dic.Add(names1[i], null);
}
if (dic.Count == 0)
result = false; // when both arrays are empty
return result;
}
示例3: BuildDriveList
public void BuildDriveList()
{
base.Items.Clear();
ShellAPI.SHFILEINFO shInfo = new ShellAPI.SHFILEINFO();
ShellAPI.SHGFI dwAttribs =
ShellAPI.SHGFI.SHGFI_ICON |
ShellAPI.SHGFI.SHGFI_SMALLICON |
ShellAPI.SHGFI.SHGFI_SYSICONINDEX |
ShellAPI.SHGFI.SHGFI_DISPLAYNAME;
ListDictionary _iconDict = new ListDictionary();
foreach( string drive in System.IO.Directory.GetLogicalDrives() )
{
IntPtr m_pHandle = ShellAPI.SHGetFileInfo(drive, ShellAPI.FILE_ATTRIBUTE_NORMAL, ref shInfo, (uint)System.Runtime.InteropServices.Marshal.SizeOf(shInfo), dwAttribs);
if( m_pHandle.Equals(IntPtr.Zero)==false )
{
int idxIcon = 0;
if( _iconDict.Contains(shInfo.iIcon)==false )
{
base.ImageList.Images.Add( System.Drawing.Icon.FromHandle(shInfo.hIcon).Clone() as System.Drawing.Icon );
User32API.DestroyIcon(shInfo.hIcon);
_iconDict.Add( shInfo.iIcon, _iconDict.Count );
idxIcon = _iconDict.Count-1;
}
else
idxIcon = Convert.ToInt32( _iconDict[shInfo.iIcon] );
ImageComboItem item = new ImageComboItem(shInfo.szDisplayName, idxIcon, false);
item.ItemValue = drive;
base.Items.Add( item );
}
}
if( base.Items.Count!=0 )
base.SelectedIndex = 0;
}
示例4: LoadSolution
//.........这里部分代码省略.........
monitor.ReportWarning (GettextCatalog.GetString (
"{0}({1}): Unsupported or unrecognized project : '{2}'.",
fileName, sec.Start + 1, projectPath));
continue;
}
MSBuildProjectHandler handler = (MSBuildProjectHandler) item.ItemHandler;
List<string> projLines = lines.GetRange (sec.Start + 1, sec.Count - 2);
DataItem it = GetSolutionItemData (projLines);
handler.SlnProjectContent = projLines.ToArray ();
handler.ReadSlnData (it);
} catch (Exception e) {
if (e is UnknownSolutionItemTypeException) {
var name = ((UnknownSolutionItemTypeException)e).TypeName;
LoggingService.LogWarning (!string.IsNullOrEmpty (name)?
string.Format ("Could not load project '{0}' with unknown item type '{1}'", projectPath, name)
: string.Format ("Could not load project '{0}' with unknown item type", projectPath));
monitor.ReportWarning (!string.IsNullOrEmpty (name)?
GettextCatalog.GetString ("Could not load project '{0}' with unknown item type '{1}'", projectPath, name)
: GettextCatalog.GetString ("Could not load project '{0}' with unknown item type", projectPath));
} else {
LoggingService.LogError (string.Format ("Error while trying to load the project {0}", projectPath), e);
monitor.ReportWarning (GettextCatalog.GetString (
"Error while trying to load the project '{0}': {1}", projectPath, e.Message));
}
var uitem = new UnknownSolutionItem () {
FileName = projectPath,
LoadError = e.Message,
};
var h = new MSBuildHandler (projTypeGuid, projectGuid) {
Item = uitem,
};
uitem.SetItemHandler (h);
item = uitem;
}
if (!items.ContainsKey (projectGuid)) {
items.Add (projectGuid, item);
sortedList.Add (item);
data.ItemsByGuid [projectGuid] = item;
} else {
monitor.ReportError (GettextCatalog.GetString ("Invalid solution file. There are two projects with the same GUID. The project {0} will be ignored.", projectPath), null);
}
}
monitor.EndTask ();
if (globals != null && globals.Contains ("NestedProjects")) {
LoadNestedProjects (globals ["NestedProjects"] as Section, lines, items, monitor);
globals.Remove ("NestedProjects");
}
//Add top level folders and projects to the main folder
foreach (SolutionItem ce in sortedList) {
if (ce.ParentFolder == null)
folder.Items.Add (ce);
}
//FIXME: This can be just SolutionConfiguration also!
if (globals != null) {
if (globals.Contains ("SolutionConfigurationPlatforms")) {
LoadSolutionConfigurations (globals ["SolutionConfigurationPlatforms"] as Section, lines,
sol, monitor);
globals.Remove ("SolutionConfigurationPlatforms");
}
if (globals.Contains ("ProjectConfigurationPlatforms")) {
LoadProjectConfigurationMappings (globals ["ProjectConfigurationPlatforms"] as Section, lines,
sol, monitor);
globals.Remove ("ProjectConfigurationPlatforms");
}
if (globals.Contains ("MonoDevelopProperties")) {
LoadMonoDevelopProperties (globals ["MonoDevelopProperties"] as Section, lines, sol, monitor);
globals.Remove ("MonoDevelopProperties");
}
ArrayList toRemove = new ArrayList ();
foreach (DictionaryEntry e in globals) {
string name = (string) e.Key;
if (name.StartsWith ("MonoDevelopProperties.")) {
int i = name.IndexOf ('.');
LoadMonoDevelopConfigurationProperties (name.Substring (i+1), (Section)e.Value, lines, sol, monitor);
toRemove.Add (e.Key);
}
}
foreach (object key in toRemove)
globals.Remove (key);
}
//Save the global sections that we dont use
List<string> globalLines = new List<string> ();
foreach (Section sec in globals.Values)
globalLines.InsertRange (globalLines.Count, lines.GetRange (sec.Start, sec.Count));
data.GlobalExtra = globalLines;
monitor.EndTask ();
return folder;
}
示例5: doMedian
public string doMedian(DataSet ds)
{
if (ds.Tables[0].Rows.Count == 0)
return null;
DataTable dtRec = new DataTable();
ListDictionary Diets = new ListDictionary();
dtRec = ds.Tables[0];
int k = 0;
for (int j = 0; j < dtRec.Rows.Count; j++)
{
if (!Diets.Contains(dtRec.Rows[j]["C"].ToString()))
{
Diets.Add(dtRec.Rows[j]["C"].ToString(), k);
k++;
}
}
List<double>[] dDataAll = new List<double>[Diets.Count];
List<double>[] dDataFemale = new List<double>[Diets.Count];
List<double>[] dDataMale = new List<double>[Diets.Count];
foreach (DictionaryEntry de in Diets)
{
dDataAll[Convert.ToInt32(de.Value.ToString())] = new List<double>();
dDataMale[Convert.ToInt32(de.Value.ToString())] = new List<double>();
dDataFemale[Convert.ToInt32(de.Value.ToString())] = new List<double>();
}
for (int i = 0; i < dtRec.Rows.Count; i++)
{
if (string.IsNullOrEmpty(dtRec.Rows[i]["WEIGHT"].ToString()))
continue;
foreach (DictionaryEntry entry in Diets)
{
if (entry.Key.ToString().Equals(dtRec.Rows[i]["C"].ToString()))
{
dDataAll[Convert.ToInt32(entry.Value.ToString())].Add(Convert.ToDouble(dtRec.Rows[i]["WEIGHT"].ToString()));
if (dtRec.Rows[i]["SEX"].ToString().Equals("M"))
dDataMale[Convert.ToInt32(entry.Value.ToString())].Add(Convert.ToDouble(dtRec.Rows[i]["WEIGHT"].ToString()));
else
dDataFemale[Convert.ToInt32(entry.Value.ToString())].Add(Convert.ToDouble(dtRec.Rows[i]["WEIGHT"].ToString()));
break;
}
}
}
int meanLoop = 0;
foreach (DictionaryEntry de in Diets)
{
engine.SetSymbol("ALL", engine.CreateNumericVector(dDataAll[meanLoop].ToArray()));
var testResult = engine.Evaluate("median(ALL)").AsNumeric();
sReturn += de.Key.ToString() + " All = " + testResult[0].ToString() + "\n";
engine.SetSymbol("MALE", engine.CreateNumericVector(dDataMale[meanLoop].ToArray()));
testResult = engine.Evaluate("median(MALE)").AsNumeric();
sReturn += de.Key.ToString() + " Male = " + testResult[0].ToString() + "\n";
engine.SetSymbol("FEMALE", engine.CreateNumericVector(dDataFemale[meanLoop].ToArray()));
testResult = engine.Evaluate("median(FEMALE)").AsNumeric();
sReturn += de.Key.ToString() + " Female = " + testResult[0].ToString() + "\n\n";
meanLoop++;
}
return sReturn;
}
示例6: LoadSolution
//.........这里部分代码省略.........
LoggingService.LogError (string.Format ("Error while trying to load the project {0}", projectPath), e);
monitor.ReportWarning (GettextCatalog.GetString (
"Error while trying to load the project '{0}': {1}", projectPath, e.Message));
}
SolutionEntityItem uitem;
if (loadAsProject) {
uitem = new UnknownProject () {
FileName = projectPath,
LoadError = e.Message,
};
} else {
uitem = new UnknownSolutionItem () {
FileName = projectPath,
LoadError = e.Message,
};
}
var h = new MSBuildHandler (projTypeGuid, projectGuid) {
Item = uitem,
};
uitem.SetItemHandler (h);
item = uitem;
}
MSBuildHandler handler = (MSBuildHandler) item.ItemHandler;
projLines = lines.GetRange (sec.Start + 1, sec.Count - 2);
DataItem it = GetSolutionItemData (projLines);
handler.UnresolvedProjectDependencies = ReadSolutionItemDependencies (projLines);
handler.SlnProjectContent = projLines.ToArray ();
handler.ReadSlnData (it);
if (!items.ContainsKey (projectGuid)) {
items.Add (projectGuid, item);
sortedList.Add (item);
data.ItemsByGuid [projectGuid] = item;
} else {
monitor.ReportError (GettextCatalog.GetString ("Invalid solution file. There are two projects with the same GUID. The project {0} will be ignored.", projectPath), null);
}
}
monitor.EndTask ();
if (globals != null && globals.Contains ("NestedProjects")) {
LoadNestedProjects (globals ["NestedProjects"] as Section, lines, items, monitor);
globals.Remove ("NestedProjects");
}
// Resolve project dependencies
foreach (var it in items.Values.OfType<SolutionEntityItem> ()) {
MSBuildHandler handler = (MSBuildHandler) it.ItemHandler;
if (handler.UnresolvedProjectDependencies != null) {
foreach (var id in handler.UnresolvedProjectDependencies.ToArray ()) {
SolutionItem dep;
if (items.TryGetValue (id, out dep) && dep is SolutionEntityItem) {
handler.UnresolvedProjectDependencies.Remove (id);
it.ItemDependencies.Add ((SolutionEntityItem)dep);
}
}
if (handler.UnresolvedProjectDependencies.Count == 0)
handler.UnresolvedProjectDependencies = null;
}
}
//Add top level folders and projects to the main folder
foreach (SolutionItem ce in sortedList) {
示例7: Test01
public void Test01()
{
IntlStrings intl;
ListDictionary ld;
Object itm;
// simple string values
string[] values =
{
"",
" ",
"a",
"aA",
"text",
" SPaces",
"1",
"$%^#",
"2222222222222222222222222",
System.DateTime.Today.ToString(),
Int32.MaxValue.ToString()
};
// keys for simple string values
string[] keys =
{
"zero",
"oNe",
" ",
"",
"aa",
"1",
System.DateTime.Today.ToString(),
"$%^#",
Int32.MaxValue.ToString(),
" spaces",
"2222222222222222222222222"
};
int cnt = 0; // Count
// initialize IntStrings
intl = new IntlStrings();
// [] ListDictionary is constructed as expected
//-----------------------------------------------------------------
ld = new ListDictionary();
// [] on empty dictionary
//
cnt = ld.Count;
Assert.Throws<ArgumentNullException>(() => { itm = ld[null]; });
cnt = ld.Count;
itm = ld["some_string"];
if (itm != null)
{
Assert.False(true, string.Format("Error, returned non=null"));
}
cnt = ld.Count;
itm = ld[new Hashtable()];
if (itm != null)
{
Assert.False(true, string.Format("Error, returned non-null"));
}
// [] get Item() on dictionary filled with simple strings
//
cnt = ld.Count;
int len = values.Length;
for (int i = 0; i < len; i++)
{
ld.Add(keys[i], values[i]);
}
if (ld.Count != len)
{
Assert.False(true, string.Format("Error, count is {0} instead of {1}", ld.Count, values.Length));
}
//
for (int i = 0; i < len; i++)
{
if (!ld.Contains(keys[i]))
{
Assert.False(true, string.Format("Error, doesn't contain key", i));
}
if (String.Compare(ld[keys[i]].ToString(), values[i]) != 0)
{
Assert.False(true, string.Format("Error, returned wrong value", i));
}
}
//
// Intl strings
// [] get Item() on dictionary filled with Intl strings
//
//.........这里部分代码省略.........
示例8: RenderActiveScriptBlocks
private void RenderActiveScriptBlocks(List<UpdatePanel> updatePanels,
HtmlTextWriter writer,
string token,
List<RegisteredScript> scriptRegistrations) {
List<RegisteredScript> entriesToRender = new List<RegisteredScript>();
// no comparer needed because it will contain ScriptKeys which implement Equals
ListDictionary uniqueEntries = new ListDictionary();
// For each entry registered in the page, check and see which ones
// came from controls within UpdatePanels that are going to be updated.
Control lastControl = null;
foreach (RegisteredScript entry in scriptRegistrations) {
Control child = entry.Control;
bool isActive = ((lastControl != null) && (child == lastControl)) ||
IsControlRegistrationActive(updatePanels, child, true);
if (isActive) {
lastControl = child;
ScriptKey scriptKey = new ScriptKey(entry.Type, entry.Key);
if (!uniqueEntries.Contains(scriptKey)) {
entriesToRender.Add(entry);
uniqueEntries.Add(scriptKey, entry);
}
}
}
foreach (RegisteredScript activeRegistration in entriesToRender) {
if (String.IsNullOrEmpty(activeRegistration.Url)) {
if (activeRegistration.AddScriptTags) {
PageRequestManager.EncodeString(writer,
token,
"ScriptContentNoTags",
activeRegistration.Script);
}
else {
WriteScriptWithTags(writer, token, activeRegistration);
}
}
else {
PageRequestManager.EncodeString(writer,
token,
"ScriptPath",
activeRegistration.Url);
}
string fallbackScriptPath;
if (_fallbackScripts != null && _fallbackScripts.TryGetValue(new ScriptKey(activeRegistration.Type, activeRegistration.Key), out fallbackScriptPath)) {
// Only encode the fallback path and not the expression. On the client, we would use the success flag on load / readystatechanged to
// determine if the script was successfully fetched.
PageRequestManager.EncodeString(writer,
"fallbackScript",
fallbackScriptPath,
content: null);
}
}
}
示例9: MakeUnique
/// <summary>
/// Returns an array of strings where all entries are unique. If a duplicate string is found,
/// then it is modified using the <see cref="NamingHelper.Reformat()"/> method.
/// </summary>
/// <param name="names">An array of strings.</param>
/// <returns>An array of strings of equal length as the input array</returns>
public static string[] MakeUnique(string[] names)
{
string[] results = new string[names.Length];
int ctr;
ListDictionary dic = new ListDictionary();
for (int i = 0; i < names.Length; i++)
{
results[i] = string.Copy(names[i]);
ctr = 1; // ctr is 1 based, as the 0th item is already in the array
while (dic.Contains(results[i]))
results[i] = Reformat(names[i], ctr++);
dic.Add(results[i], null);
}
return results;
}
示例10: doTTest
private void doTTest()
{
REngine engine = REngine.GetInstance();
daoChart _daoChart = new daoChart();
DataSet dsRec = new DataSet();
DataTable dtRec = new DataTable();
ListDictionary Diets = new ListDictionary();
dsRec = _daoChart.getRData(1);
dtRec = dsRec.Tables[0];
int k = 0;
for (int j = 0; j < dtRec.Rows.Count; j++)
{
if (!Diets.Contains(dtRec.Rows[j]["C"].ToString()))
{
Diets.Add(dtRec.Rows[j]["C"].ToString(), k);
k++;
}
}
List<double>[] dData = new List<double>[Diets.Count];
foreach (DictionaryEntry de in Diets)
{
dData[Convert.ToInt32(de.Value.ToString())] = new List<double>();
}
for (int i = 0; i < dtRec.Rows.Count; i++)
{
if (string.IsNullOrEmpty(dtRec.Rows[i]["WEIGHT"].ToString()))
continue;
foreach (DictionaryEntry entry in Diets)
{
if (entry.Key.ToString().Equals(dtRec.Rows[i]["C"].ToString()))
{
dData[Convert.ToInt32(entry.Value.ToString())].Add(Convert.ToDouble(dtRec.Rows[i]["WEIGHT"].ToString()));
break;
}
}
}
foreach (DictionaryEntry deVector in Diets)
{
NumericVector Vgroup1 = engine.CreateNumericVector(dData[Convert.ToInt32(deVector.Value)].ToArray());
engine.SetSymbol(deVector.Key.ToString(), Vgroup1);
foreach (DictionaryEntry compareVector in Diets)
{
NumericVector Vgroup2 = engine.CreateNumericVector(dData[Convert.ToInt32(compareVector.Value)].ToArray());
if (!deVector.Key.ToString().Equals(compareVector.Key.ToString()))
{
engine.SetSymbol(compareVector.Key.ToString(), Vgroup2);
GenericVector testResult1 = engine.Evaluate("t.test(" + deVector.Key.ToString() + "," +
compareVector.Key.ToString() + ")").AsList();
double p1 = testResult1["p.value"].AsNumeric().First();
tbREngine.Text += deVector.Key.ToString() + "\\" + compareVector.Key.ToString();
tbREngine.Text += "\nP1-value = {0:0.000}" + p1 + "\n\n";
//engine.ClearGlobalEnvironment();
}
}
}
}
示例11: doQuantile
private void doQuantile()
{
REngine engine = REngine.GetInstance();
daoChart _daoChart = new daoChart();
DataSet dsRec = new DataSet();
DataTable dtRec = new DataTable();
ListDictionary Diets = new ListDictionary();
dsRec = _daoChart.getRData(1);
dtRec = dsRec.Tables[0];
int k = 0;
for (int j = 0; j < dtRec.Rows.Count; j++)
{
if (!Diets.Contains(dtRec.Rows[j]["C"].ToString()))
{
Diets.Add(dtRec.Rows[j]["C"].ToString(), k);
k++;
}
}
List<double>[] dDataAll = new List<double>[Diets.Count];
List<double>[] dDataFemale = new List<double>[Diets.Count];
List<double>[] dDataMale = new List<double>[Diets.Count];
foreach (DictionaryEntry de in Diets)
{
dDataAll[Convert.ToInt32(de.Value.ToString())] = new List<double>();
dDataMale[Convert.ToInt32(de.Value.ToString())] = new List<double>();
dDataFemale[Convert.ToInt32(de.Value.ToString())] = new List<double>();
}
for (int i = 0; i < dtRec.Rows.Count; i++)
{
if (string.IsNullOrEmpty(dtRec.Rows[i]["WEIGHT"].ToString()))
continue;
foreach (DictionaryEntry entry in Diets)
{
if (entry.Key.ToString().Equals(dtRec.Rows[i]["C"].ToString()))
{
dDataAll[Convert.ToInt32(entry.Value.ToString())].Add(Convert.ToDouble(dtRec.Rows[i]["WEIGHT"].ToString()));
if (dtRec.Rows[i]["SEX"].ToString().Equals("M"))
dDataMale[Convert.ToInt32(entry.Value.ToString())].Add(Convert.ToDouble(dtRec.Rows[i]["WEIGHT"].ToString()));
else
dDataFemale[Convert.ToInt32(entry.Value.ToString())].Add(Convert.ToDouble(dtRec.Rows[i]["WEIGHT"].ToString()));
break;
}
}
}
int meanLoop = 0;
foreach (DictionaryEntry de in Diets)
{
engine.SetSymbol("ALL", engine.CreateNumericVector(dDataAll[meanLoop].ToArray()));
var testResult = engine.Evaluate("quantile(ALL)").AsNumeric();
tbREngine.Text += de.Key.ToString() + " All \n";
for (int qloop = 0; qloop < 4; qloop++ )
tbREngine.Text += testResult[qloop].ToString() + "\n";
tbREngine.Text += "\n";
engine.SetSymbol("MALE", engine.CreateNumericVector(dDataMale[meanLoop].ToArray()));
testResult = engine.Evaluate("quantile(MALE)").AsNumeric();
tbREngine.Text += de.Key.ToString() + " Male \n";
for (int qloop = 0; qloop < 4; qloop++)
tbREngine.Text += testResult[qloop].ToString() + "\n";
tbREngine.Text += "\n";
engine.SetSymbol("FEMALE", engine.CreateNumericVector(dDataFemale[meanLoop].ToArray()));
testResult = engine.Evaluate("boxplot(FEMALE, vertical=true)").AsNumeric();
tbREngine.Text += de.Key.ToString() + " Female \n";
for (int qloop = 0; qloop < 4; qloop++)
tbREngine.Text += testResult[qloop].ToString() + "\n";
tbREngine.Text += "\n";
meanLoop++;
}
}
示例12: doAnova
private void doAnova()
{
REngine engine = REngine.GetInstance();
daoChart _daoChart = new daoChart();
DataSet dsRec = new DataSet();
DataTable dtRec = new DataTable();
ListDictionary Diets = new ListDictionary();
List<double> dMeasure = new List<double>();
List<string> sDiet = new List<string>();
dsRec = _daoChart.getRData(1);
dtRec = dsRec.Tables[0];
int k = 0;
for (int j = 0; j < dtRec.Rows.Count; j++)
{
if (!Diets.Contains(dtRec.Rows[j]["C"].ToString()))
{
Diets.Add(dtRec.Rows[j]["C"].ToString(), k);
sDiet.Add(dtRec.Rows[j]["C"].ToString());
k++;
}
}
List<double>[] dDataAll = new List<double>[Diets.Count];
List<double>[] dDataFemale = new List<double>[Diets.Count];
List<double>[] dDataMale = new List<double>[Diets.Count];
foreach (DictionaryEntry de in Diets)
{
dDataAll[Convert.ToInt32(de.Value.ToString())] = new List<double>();
dDataMale[Convert.ToInt32(de.Value.ToString())] = new List<double>();
dDataFemale[Convert.ToInt32(de.Value.ToString())] = new List<double>();
}
for (int i = 0; i < dtRec.Rows.Count; i++)
{
if (string.IsNullOrEmpty(dtRec.Rows[i]["WEIGHT"].ToString()))
continue;
foreach (DictionaryEntry entry in Diets)
{
if (entry.Key.ToString().Equals(dtRec.Rows[i]["C"].ToString()))
{
dDataAll[Convert.ToInt32(entry.Value.ToString())].Add(Convert.ToDouble(dtRec.Rows[i]["WEIGHT"].ToString()));
if (dtRec.Rows[i]["SEX"].ToString().Equals("M"))
dDataMale[Convert.ToInt32(entry.Value.ToString())].Add(Convert.ToDouble(dtRec.Rows[i]["WEIGHT"].ToString()));
else
dDataFemale[Convert.ToInt32(entry.Value.ToString())].Add(Convert.ToDouble(dtRec.Rows[i]["WEIGHT"].ToString()));
break;
}
}
}
/*double[] test = new double[Diets.Count];
for (int j = 0; j < test.Length; j++)
{
test[j] = doMeans(dDataMale[j].ToArray());
}*/
List<string> testString = new List<string>();
List<double> testDouble = new List<double>();
for (int j = 0; j < dtRec.Rows.Count; j++)
{
if (dtRec.Rows[j]["SEX"].ToString().Equals("M"))
{
testString.Add(dtRec.Rows[j]["C"].ToString());
testDouble.Add(Convert.ToDouble(dtRec.Rows[j]["WEIGHT"].ToString()));
}
}
engine.SetSymbol("measure", engine.CreateNumericVector(testDouble.ToArray()));
engine.SetSymbol("diet", engine.CreateCharacterVector(testString.ToArray()));
/* var res = engine.Evaluate("anova(y ~ a, data = data.frame(y = measure, a = diet))").AsList()["Pr(>F)"].AsNumeric();
for (int loop = 0; loop < res.Length; loop++)
tbREngine.Text += res[loop] + "\n\n";*/
engine.Evaluate("bob <- aov(y~a, data.frame(y = measure, a = diet)");
var resName = engine.Evaluate("names(bob)").AsList().AsCharacter();
int loop = 0;
for (loop = 0; loop < resName.Length; loop++)
tbREngine.Text += resName[loop].ToString() + "\n";
var resSum = engine.Evaluate("summary(bob)").AsList().AsCharacter();
string newsummary = resSum[0].ToString();
newsummary = newsummary.Replace("list(", string.Empty);
newsummary = newsummary.Replace("'", string.Empty);
newsummary = newsummary.Replace("c", string.Empty);
string[] sumArray = newsummary.Split('=');
for (loop = 0; loop < sumArray.Length; loop++ )
tbREngine.Text += sumArray[loop].ToString() + "\n";
//.........这里部分代码省略.........
示例13: Test01
public void Test01()
{
ListDictionary ld;
// [] ListDictionary is constructed as expected
//-----------------------------------------------------------------
ld = new ListDictionary();
if (ld == null)
{
Assert.False(true, string.Format("Error, dictionary is null after default ctor"));
}
if (ld.Count != 0)
{
Assert.False(true, string.Format("Error, Count = {0} after default ctor", ld.Count));
}
if (ld["key"] != null)
{
Assert.False(true, string.Format("Error, Item(some_key) returned non-null after default ctor"));
}
System.Collections.ICollection keys = ld.Keys;
if (keys.Count != 0)
{
Assert.False(true, string.Format("Error, Keys contains {0} keys after default ctor", keys.Count));
}
System.Collections.ICollection values = ld.Values;
if (values.Count != 0)
{
Assert.False(true, string.Format("Error, Values contains {0} items after default ctor", values.Count));
}
//
// [] Add(string, string)
//
ld.Add("Name", "Value");
if (ld.Count != 1)
{
Assert.False(true, string.Format("Error, Count returned {0} instead of 1", ld.Count));
}
if (String.Compare(ld["Name"].ToString(), "Value") != 0)
{
Assert.False(true, string.Format("Error, Item() returned unexpected value"));
}
//
// [] Clear()
//
ld.Clear();
if (ld.Count != 0)
{
Assert.False(true, string.Format("Error, Count returned {0} instead of 0 after Clear()", ld.Count));
}
if (ld["Name"] != null)
{
Assert.False(true, string.Format("Error, Item() returned non-null value after Clear()"));
}
//
// [] elements not overriding Equals()
//
ld.Clear();
Hashtable lbl = new Hashtable();
Hashtable lbl1 = new Hashtable();
ArrayList b = new ArrayList();
ArrayList b1 = new ArrayList();
ld.Add(lbl, b);
ld.Add(lbl1, b1);
if (ld.Count != 2)
{
Assert.False(true, string.Format("Error, Count returned {0} instead of 2", ld.Count));
}
if (!ld.Contains(lbl))
{
Assert.False(true, string.Format("Error, doesn't contain 1st special item"));
}
if (!ld.Contains(lbl1))
{
Assert.False(true, string.Format("Error, doesn't contain 2nd special item"));
}
if (ld.Values.Count != 2)
{
Assert.False(true, string.Format("Error, Values.Count returned {0} instead of 2", ld.Values.Count));
}
ld.Remove(lbl1);
if (ld.Count != 1)
{
Assert.False(true, string.Format("Error, failed to remove item"));
}
if (ld.Contains(lbl1))
{
Assert.False(true, string.Format("Error, failed to remove special item"));
}
}
示例14: ParseNode
private void ParseNode( Object parent, Object context, XmlNode node, Hashtable config, String prefix )
{
foreach ( XmlNode item in node.ChildNodes ) {
if ( item.NodeType.Equals(XmlNodeType.Element) ) {
String sectionname = String.Concat(prefix, "/", item.Name);;
switch ( item.Name ) {
case "general":
case "login":
case "message":
case "inbox":
SingleTagSectionHandler singlesection = new SingleTagSectionHandler();
InitConfigSection(config, sectionname, singlesection.Create(parent, context, item) as System.Collections.Hashtable);
break;
case "read":
case "send":
if ( item.HasChildNodes )
ParseNode( parent, context, item, config, sectionname );
break;
case "servers":
if ( item.HasChildNodes )
config.Add(sectionname, ParseConfigServers(item.ChildNodes));
break;
case "addressbook":
if ( !config.Contains(sectionname) )
config.Add(sectionname, new SortedList());
SortedList addressbooks = (SortedList)config[sectionname];
Hashtable tmpaddressbook = (Hashtable)(new System.Configuration.SingleTagSectionHandler()).Create(parent, context, item);
ListDictionary addressbook = new ListDictionary(new System.Collections.CaseInsensitiveComparer());
foreach ( String configitem in tmpaddressbook.Keys) {
addressbook.Add(configitem, tmpaddressbook[configitem]);
}
tmpaddressbook = null;
if ( addressbook.Contains("type") && !addressbook["type"].Equals("none") && addressbook.Contains("name") && !addressbooks.Contains(addressbook["name"]) ) {
if ( addressbook.Contains("pagesize") )
addressbook["pagesize"] = ParseConfigElement(addressbook["pagesize"].ToString(), 10);
else
addressbook["pagesize"] = 10;
addressbooks.Add(addressbook["name"], addressbook);
if ( addressbook.Contains("allowupdate") )
addressbook["allowupdate"] = ParseConfigElement(addressbook["allowupdate"].ToString(), false);
else
addressbook["allowupdate"] = false;
}
break;
}
}
}
}
示例15: Test01
public void Test01()
{
IntlStrings intl;
ListDictionary ld;
// simple string values
string[] values =
{
"",
" ",
"a",
"aA",
"text",
" SPaces",
"1",
"$%^#",
"2222222222222222222222222",
System.DateTime.Today.ToString(),
Int32.MaxValue.ToString()
};
// keys for simple string values
string[] keys =
{
"zero",
"oNe",
" ",
"",
"aa",
"1",
System.DateTime.Today.ToString(),
"$%^#",
Int32.MaxValue.ToString(),
" spaces",
"2222222222222222222222222"
};
int cnt = 0; // Count
// initialize IntStrings
intl = new IntlStrings();
// [] ListDictionary is constructed as expected
//-----------------------------------------------------------------
ld = new ListDictionary();
// [] Contains() on empty dictionary
//
Assert.Throws<ArgumentNullException>(() => { ld.Contains(null); });
if (ld.Contains("some_string"))
{
Assert.False(true, string.Format("Error, empty dictionary contains some_object"));
}
if (ld.Contains(new Hashtable()))
{
Assert.False(true, string.Format("Error, empty dictionary contains some_object"));
}
// [] simple strings and Contains()
//
cnt = ld.Count;
int len = values.Length;
for (int i = 0; i < len; i++)
{
ld.Add(keys[i], values[i]);
}
if (ld.Count != len)
{
Assert.False(true, string.Format("Error, count is {0} instead of {1}", ld.Count, values.Length));
}
//
for (int i = 0; i < len; i++)
{
if (!ld.Contains(keys[i]))
{
Assert.False(true, string.Format("Error, doesn't contain \"{1}\"", i, keys[i]));
}
}
//
// Intl strings
// [] Intl strings and Contains()
//
string[] intlValues = new string[len * 2];
// fill array with unique strings
//
for (int i = 0; i < len * 2; i++)
{
string val = intl.GetRandomString(MAX_LEN);
while (Array.IndexOf(intlValues, val) != -1)
val = intl.GetRandomString(MAX_LEN);
intlValues[i] = val;
}
//.........这里部分代码省略.........