本文整理汇总了C#中Dict.Add方法的典型用法代码示例。如果您正苦于以下问题:C# Dict.Add方法的具体用法?C# Dict.Add怎么用?C# Dict.Add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dict
的用法示例。
在下文中一共展示了Dict.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ItShouldAdd
public void ItShouldAdd()
{
Dict<int, string> test = new Dict<int, string>();
test.Add(1, "One");
test.Add(2, "Two");
test.Add(3, "Three");
test.Add(4, "Four");
test.Add(5, "Five");
bool actual = test.ContainsKey(1);
bool expected = true;
Assert.AreEqual(expected, actual);
}
示例2: Initilize
/// <summary>
/// (Re)initialize the debugger. This method must
/// be called whenever a program is compiled.
/// </summary>
/// <param name="scene"></param>
public static void Initilize(Dict scene)
{
// allocate GPU resources
buf = new GLBuffer(DbgBufKey, "dbg", BufferUsageHint.DynamicRead, stage_size * 6 * 16);
tex = new GLTexture(DbgTexKey, "dbg", GpuFormat.Rgba32f, buf, null);
#if DEBUG // add to scene for debug inspection
scene.Add(DbgBufKey, buf);
scene.Add(DbgTexKey, tex);
#endif
passes.Clear();
// reset watch count for indexing in debug mode
dbgVarCount = 0;
}
示例3: GeneratorAssetbundleEntry
static List<AssetBundleBuild> GeneratorAssetbundleEntry()
{
string path = Application.dataPath + "/" + PackagePlatform.packageConfigPath;
if (string.IsNullOrEmpty(path)) return null;
string str = File.ReadAllText(path);
Dict<string, ABEntry> abEntries = new Dict<string, ABEntry>();
PackageConfig apc = JsonUtility.FromJson<PackageConfig>(str);
AssetBundlePackageInfo[] bundlesInfo = apc.bundles;
for (int i = 0; i < bundlesInfo.Length; i++)
{
ABEntry entry = new ABEntry();
entry.bundleInfo = bundlesInfo[i];
if (!abEntries.ContainsKey(entry.bundleInfo.name))
{
abEntries.Add(entry.bundleInfo.name, entry);
}
}
List<AssetBundleBuild> abbList = new List<AssetBundleBuild>();
foreach (var rEntryItem in abEntries)
{
abbList.AddRange(rEntryItem.Value.ToABBuild());
}
return abbList;
}
示例4: ItShouldGetValueForSpecificKey
public void ItShouldGetValueForSpecificKey()
{
Dict<int, string> test = new Dict<int, string>();
test.Add(1, "One");
test.Add(2, "Two");
test.Add(3, "Three");
test.Add(4, "Four");
test.Add(5, "Five");
test.Add(18, "Eightteen");
string actual = test[18];
string expected = "Eightteen";
Assert.AreEqual(expected, actual);
}
示例5: ItShouldClear
public void ItShouldClear()
{
Dict<int, string> test = new Dict<int, string>();
test.Add(1, "One");
test.Add(2, "Two");
test.Add(3, "Three");
test.Add(4, "Four");
test.Add(5, "Five");
test.Add(18, "Eightteen");
test.Clear();
int expected = 0;
int actual = test.Count;
Assert.AreEqual(expected, actual);
}
示例6: ItShouldRemove
public void ItShouldRemove()
{
Dict<int, string> test = new Dict<int, string>();
test.Add(1, "One");
test.Add(2, "Two");
test.Add(3, "Three");
test.Add(4, "Four");
test.Add(5, "Five");
test.Add(18, "Eightteen");
test.Remove(3);
bool actual=test.ContainsKey(3);
bool expected=false;
Assert.AreEqual(expected, actual);
}
示例7: ParserCSV
public void ParserCSV(string content)
{
string[] row = content.Split(new char[]{'\n'});
string[] columnHeads = row[0].Split(new char[]{','});
for(int i = 1; i < row.Length; i++)
{
Dict<string, string> rowDict = new Dict<string, string>();
string[] column =row[i].Split(new char[]{','});
for(int j = 0; j < columnHeads.Length; j++)
{
if(!String.IsNullOrEmpty(column[j]))
{
rowDict.Add(columnHeads[j], column[j]);
}
else
{
Debug.Log("file error");
}
}
this.table.AddRow(column[0], rowDict);
}
}
示例8: ItShouldTryGetValueAndReturnFalse
public void ItShouldTryGetValueAndReturnFalse()
{
Dict<int, string> test = new Dict<int, string>();
test.Add(1, "One");
test.Add(2, "Two");
test.Add(3, "Three");
test.Add(4, "Four");
test.Add(5, "Five");
test.Add(18, "Eightteen");
string value;
bool actual = test.TryGetValue(6, out value);
bool expected = false;
Assert.AreEqual(expected, actual);
}
示例9: ItShouldTryGetValue
public void ItShouldTryGetValue()
{
Dict<int, string> test = new Dict<int, string>();
test.Add(1, "One");
test.Add(2, "Two");
test.Add(3, "Three");
test.Add(4, "Four");
test.Add(5, "Five");
test.Add(18, "Eightteen");
string actual;
test.TryGetValue(3,out actual);
string expected = "Three";
Assert.AreEqual(expected, actual);
}
示例10: GetAnchorsList
/// <summary>
/// Extracts the link tag info from the page using RegEx
/// </summary>
/// <param name="p_strPageHtmlContent"></param>
/// <returns>Deprecated</returns>
private static Dict<string, Anchor> GetAnchorsList(string p_strPageHtmlContent)
{
Dict<string, Anchor> dictReturnSet = new Dict<string, Anchor>();
Anchor ancrLink = new Anchor();
// Try grabbing the meta info of the page into a dictionary
string pattern = "<a.+?(?:href=(?:\"|')(.*?)(?:\"|').*?)?(?:title=(?:\"|')(.*?)(?:\"|').*?)?(?:href=(?:\"|')(.*?)(?:\"|'))?/?>.*?</head>";
RegexOptions rxoOptions = RegexOptions.IgnoreCase | RegexOptions.Singleline;
foreach (Match match in Regex.Matches(p_strPageHtmlContent, pattern, rxoOptions))
{
ancrLink = new Anchor();
ancrLink.Rel = match.Groups[1].Value;
ancrLink.Type = match.Groups[2].Value;
ancrLink.Href = match.Groups[3].Value;
dictReturnSet.Add(match.Groups[1].Value, ancrLink);
}
return dictReturnSet;
}
示例11: GetAttrDictWithCustomDict
internal IDictionary<object, object> GetAttrDictWithCustomDict(ICallerContext context, ICustomAttributes self, IAttributesDictionary selfDict)
{
Debug.Assert(IsInstanceOfType(self));
// Get the attributes from the instance
Dict res = new Dict(selfDict);
// Add the attributes from the type
Dict typeDict = base.GetAttrDict(context, self);
foreach (KeyValuePair<object, object> pair in (IDictionary<object, object>)typeDict) {
res.Add(pair);
}
return res;
}
示例12: GetAttrDict
public virtual Dict GetAttrDict(ICallerContext context, object self)
{
// Get the entries from the type
Dict res = new Dict(GetAttrDict(context));
// Add the entries from the instance
ISuperDynamicObject sdo = self as ISuperDynamicObject;
if (sdo != null) {
IAttributesDictionary dict = sdo.GetDict();
if (dict != null) {
foreach (KeyValuePair<object, object> val in dict) {
object fieldName = val.Key;
if (!res.ContainsKey(fieldName)) {
res.Add(new KeyValuePair<object, object>(fieldName, val.Value));
}
}
}
}
return res;
}
示例13: GetPageMetaLinkInfo
/// <summary>
/// Extracts the link tag info from the page using RegEx
/// </summary>
/// <param name="p_strPageHtmlContent"></param>
/// <returns>Deprecated</returns>
private static Dict<string, PageMetaLink> GetPageMetaLinkInfo(string p_strPageHtmlContent)
{
Dict<string, PageMetaLink> dictReturnSet = new Dict<string, PageMetaLink>();
PageMetaLink pmlLinkTag = new PageMetaLink();
// Try grabbing the meta info of the page into a dictionary
string pattern = "<link.+?(?:rel=(?:\"|')(.*?)(?:\"|').*?)?(?:type=(?:\"|')(.*?)(?:\"|').*?)?(?:href=(?:\"|')(.*?)(?:\"|'))?/?>.*?</head>";
RegexOptions rxoOptions = RegexOptions.IgnoreCase | RegexOptions.Singleline;
foreach (Match match in Regex.Matches(p_strPageHtmlContent, pattern, rxoOptions))
{
pmlLinkTag = new PageMetaLink();
pmlLinkTag.Rel = match.Groups[1].Value;
pmlLinkTag.Type = match.Groups[2].Value;
pmlLinkTag.Href = match.Groups[3].Value;
dictReturnSet.Add(match.Groups[1].Value, pmlLinkTag);
}
return dictReturnSet;
}
示例14: GetPageMetaInfo
/// <summary>
/// Extracts the meta tag info from the page using RegEx
/// </summary>
/// <param name="p_strPageHtmlContent"></param>
/// <returns>Deprecated</returns>
private static Dict<string, PageMeta> GetPageMetaInfo(string p_strPageHtmlContent)
{
Dict<string, PageMeta> dictReturnSet = new Dict<string, PageMeta>();
PageMeta pmMetaTag = new PageMeta();
// Try grabbing the meta info of the page into a dictionary
string pattern = "<meta.+?(?:name=(?:\"|')(.*?)(?:\"|').*?)?(?:property=(?:\"|')(.*?)(?:\"|').*?)?(?:content=(?:\"|')(.*?)(?:\"|'))?/?>.*?</head>";
RegexOptions rxoOptions = RegexOptions.IgnoreCase | RegexOptions.Singleline;
foreach (Match match in Regex.Matches(p_strPageHtmlContent, pattern, rxoOptions))
{
pmMetaTag = new PageMeta();
pmMetaTag.Name = match.Groups[1].Value;
pmMetaTag.Property = match.Groups[2].Value;
pmMetaTag.Content = match.Groups[3].Value;
if (!dictReturnSet.ContainsKey(match.Groups[1].Value))
{
dictReturnSet.Add(match.Groups[1].Value, pmMetaTag);
}
}
return dictReturnSet;
}
示例15: GetGenericTag
/// <summary>
/// Grabs and returns generic tags as (safe) dictionaries from an HTML document - for futureproving
/// </summary>
/// <param name="htmlDocDocument"></param>
/// <returns></returns>
private static Dict<string, string> GetGenericTag(HtmlDocument p_htmlDocDocument, string p_strTagName)
{
Dict<string, string> dictTag = new Dict<string, string>();
foreach (HtmlNode hnItem in p_htmlDocDocument.DocumentNode.SelectNodes("//" + p_strTagName))
{
foreach (HtmlAttribute haItem in hnItem.Attributes)
{
// Generate name-value pair of the tag's attribute
dictTag.Add(haItem.Name, GetHtmlAttributeValue(hnItem.Attributes, haItem.Name));
}
}
return dictTag;
}