本文整理汇总了C#中Dictionary.Clear方法的典型用法代码示例。如果您正苦于以下问题:C# Dictionary.Clear方法的具体用法?C# Dictionary.Clear怎么用?C# Dictionary.Clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dictionary
的用法示例。
在下文中一共展示了Dictionary.Clear方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: NotifyChangedText
public void NotifyChangedText()
{
var propDict = new Dictionary<string, string>();
JsonObject jso = new JsonObject();
jso.PropertyChanged += (obj, e) => { propDict.Add(e.PropertyName, ""); };
dynamic djso = jso;
Assert.IsFalse(propDict.ContainsKey("Name"));
djso.Name = "JP";
Assert.IsTrue(propDict.ContainsKey("Name"));
propDict.Clear();
Assert.IsFalse(propDict.ContainsKey("Name"));
djso["Name"] = "JP";
Assert.IsTrue(propDict.ContainsKey("Name"));
propDict.Clear();
djso.RemoveAll();
Assert.IsFalse(propDict.ContainsKey("Name"));
djso.Add("Name", "JP");
Assert.IsTrue(propDict.ContainsKey("Name"));
propDict.Clear();
}
示例2: CollectViews
void CollectViews()
{
var view = android_ass.GetType ("Android.Views.View");
var animation = android_ass.GetType ("Android.Views.Animations.Animation");
var layoutparams = android_ass.GetType ("Android.Views.ViewGroup+LayoutParams");
targets.Add (view);
var d = new Dictionary<Type,bool> ();
foreach (var ass in asses)
foreach (var t in ass.GetTypes ())
CheckIfTypeIsTarget (view, d, t);
views.AddRange (from e in d where e.Value select e.Key);
targets.AddRange (views);
d.Clear ();
targets.Add (animation);
foreach (var ass in asses)
foreach (var t in ass.GetTypes ())
CheckIfTypeIsTarget (animation, d, t);
anims.AddRange (from e in d where e.Value select e.Key);
targets.AddRange (anims);
d.Clear ();
layparams.Add (layoutparams);
foreach (var ass in asses)
foreach (var t in ass.GetTypes ())
CheckIfTypeIsTarget (layoutparams, d, t);
layparams.AddRange (from e in d where e.Value select e.Key);
targets.AddRange (layparams);
d.Clear ();
GenerateCode ();
}
示例3: Do
/// <summary>
/// Do the specified input and output.
/// </summary>
/// <param name="input">Input.</param>
/// <param name="output">Output.</param>
public void Do(BlockingCollection<ISkeleton> input, Action<IEnumerable<Result>> fireNewCommand)
{
var data = new Dictionary<JointType, InputVector>();
foreach (var skeleton in input.GetConsumingEnumerable())
{
foreach (var joint in skeleton.Joints)
{
if (!data.ContainsKey(joint.JointType))
{
data.Add(joint.JointType, new InputVector());
}
data[joint.JointType].Stream.Add(joint.Point);
}
if (data.First().Value.Stream.Count < 5)
{
continue;
}
var results = Recognizer.Recognize(data);
try
{
fireNewCommand(results);
}
catch (Exception)
{
if (data.First().Value.Stream.Count > 40)
{
data.Clear();
}
continue;
}
data.Clear();
}
}
示例4: deleteOrder
/// <summary>
/// Метод удаляет лист заказа вместе с горячей статистикой
/// </summary>
/// <param name="orderNum">Номер листа заказа</param>
public static void deleteOrder(string orderNum)
{
Dictionary<string, string> Dict = new Dictionary<string, string>();
Dict.Add("ORDER_NUM", orderNum);
SQLOracle.delete("delete from USP_HOT_STATS where ORDER_NUM = :ORDER_NUM", Dict);
Dict.Clear();
if (!AssemblyOrders.isProject(orderNum))
{
int id = _ASSEMBLIES.getId_OrderNum(orderNum);
Dict.Add("ID", id.ToString());
SQLOracle.delete("delete from USP_ASSEMBLIES where ID = :ID", Dict);
SQLOracle.delete("delete from USP_ASSEMBLY_ELEMENTS where ASSEMBLY_ID = :ID", Dict);
Dict.Clear();
}
if (isTZ(orderNum))
{
string idDoc = getTZId(orderNum);
Dict.Add("ID_DOC", idDoc);
string cmdUpdate = "update USP_TZ_DATA set UTV = 1, HP_KOL_EDEN = null where ID_DOC = :ID_DOC";
SQLOracle.update(cmdUpdate, Dict);
cmdUpdate = "update USP_TZ_DATA_TP set OBOZN_KOMP = NULL, NAIM_KOMP = NULL, KOL = null where ID_DOC = :ID_DOC";
SQLOracle.update(cmdUpdate, Dict);
}
Dict.Clear();
Dict.Add("ORDER_NUM", orderNum);
SQLOracle.delete("delete from USP_ASSEMBLY_ORDERS where NUM = :ORDER_NUM", Dict);
}
示例5: StringProperties
public void StringProperties()
{
IDictionary<string, object> dict = new Dictionary<string, object>();
dict["intprop"] = 1;
string json = JSON.ToJSON(dict);
Assert.AreEqual("{\"intprop\":1}",json);
dict.Clear();
dict["stringprop"] = "foo";
json = JSON.ToJSON(dict);
Assert.AreEqual("{\"stringprop\":\"foo\"}", json);
dict.Clear();
dict["arrayprop"] = new int[] { 1, 2, 3 };
json = JSON.ToJSON(dict);
Assert.AreEqual("{\"arrayprop\":[1,2,3]}", json);
dict.Clear();
dict["1"] = "bar";
json = JSON.ToJSON(dict);
Assert.AreEqual("{\"1\":\"bar\"}", json);
dict.Clear();
dict["false"] = "foobar";
json = JSON.ToJSON(dict);
Assert.AreEqual("{\"false\":\"foobar\"}", json);
}
示例6: Main
private static void Main(string[] args)
{
var connector = Credentials.MyConnector();
var paramlist = new Dictionary<string, string>
{
{"account", "test"},
{"tablename", "sdktest1"},
{"fileurl", "http://maplarge-data.s3.amazonaws.com/TwitterS3.zip"}
};
//CREATE TABLE SYNCHRONOUS (NO WEB CALL)
//MapLargeConnector.NO_WEB_CALLS = true;
var response = connector.InvokeAPIRequest("CreateTableSynchronous", paramlist);
Console.WriteLine(response);
MapLargeConnector.NO_WEB_CALLS = false;
//RETRIEVE REMOTE USER AUTH TOKEN
response = connector.GetRemoteAuthToken(Credentials.UserName, Credentials.Password, "255.255.255.255");
Console.WriteLine(response);
//LIST GROUPS
paramlist.Clear();
paramlist.Add("account", "test");
response = connector.InvokeAPIRequestPost("ListGroups", paramlist);
Console.WriteLine(response);
//CREATE TABLE WITH FILES SYNCHRONOUS
paramlist.Clear();
paramlist.Add("account", "test");
paramlist.Add("tablename", "sdktest2");
response = connector.InvokeAPIRequestPost("CreateTableWithFilesSynchronous",
paramlist,
new[] {@"C:\MapLarge\Small.csv"});
Console.WriteLine(response);
}
示例7: IsValidSudoku
public bool IsValidSudoku(char[,] board)
{
IDictionary<char, bool> dic = new Dictionary<char, bool> ();
for (int i = 0; i < board.GetLength (0); ++i) {
// row
dic.Clear();
for (int j = 0; j < board.GetLength (1); ++j) {
if (board [i, j] == '.') {
continue;
}
if (dic.ContainsKey (board [i, j])) {
return false;
} else {
dic[board[i, j]] = true;
}
}
// col
dic.Clear();
for (int j = 0; j < board.GetLength (1); ++j) {
if (board [j, i] == '.') {
continue;
}
if (dic.ContainsKey (board [j, i])) {
return false;
} else {
dic[board[j, i]] = true;
}
}
}
// part
for (int i = 0; i < board.GetLength (0); i += 3) {
for (int j = 0; j < board.GetLength (1); j += 3) {
dic.Clear ();
for (int ii = 0; ii < 3; ++ii) {
for (int jj = 0; jj < 3; ++jj) {
char c = board [i + ii, j + jj];
if (c == '.') {
continue;
}
if (dic.ContainsKey (c)) {
return false;
} else {
dic[c] = true;
}
}
}
}
}
return true;
}
示例8: Run
public static void Run()
{
Console.WriteLine("Running test configured with App.config.");
using (WorkflowRuntimeManager manager = new WorkflowRuntimeManager(new WorkflowRuntime("WorkflowRuntime")))
{
manager.MessageEvent += delegate(object sender, WorkflowLogEventArgs e)
{
Console.WriteLine(e.Message);
};
manager.WorkflowRuntime.StartRuntime();
Dictionary<string, object> wfArguments = new Dictionary<string, object>();
//wfArguments.Add("InputString", "1");
ManagedWorkflowInstance instance1 = manager.StartWorkflow(@"C:\Documents and Settings\Administrator\Desktop\Pro WF\chapter 17\WorkflowDesignerApp\bin\Debug\Test.xoml", @"C:\Documents and Settings\Administrator\Desktop\Pro WF\chapter 17\WorkflowDesignerApp\bin\Debug\Test.rules", wfArguments);
//ManagedWorkflowInstance instance1 = manager.StartWorkflow(typeof(Workflow1), wfArguments);
//instance1.WorkflowInstance.Terminate("Manual Termination");
wfArguments.Clear();
wfArguments.Add("InputString", "2");
ManagedWorkflowInstance instance2 = manager.StartWorkflow(typeof(Workflow1), wfArguments);
instance2.WorkflowInstance.Suspend("Manual Suspension");
instance2.WorkflowInstance.Resume();
wfArguments.Clear();
wfArguments.Add("InputString", "3");
manager.StartWorkflow(typeof(Workflow1), wfArguments);
manager.WaitAll(15000);
foreach (ManagedWorkflowInstance managedInstance in manager.Workflows.Values)
{
if (managedInstance.Outputs.ContainsKey("Result"))
{
Console.WriteLine(managedInstance.Outputs["Result"]);
}
if (managedInstance.Exception != null)
{
Console.WriteLine("{0} - Exception: {1}", managedInstance.Id, managedInstance.Exception.Message);
}
if (managedInstance.ReasonSuspended.Length > 0)
{
Console.WriteLine("{0} - Suspended: {1}", managedInstance.Id, managedInstance.ReasonSuspended);
}
}
manager.ClearAllWorkflows();
}
}
示例9: ProcessDom
/// <summary>
/// replace every <include/> node in the document with the nodes that it references
/// </summary>
/// <param name="dom"></param>=
public void ProcessDom(string parentPath, XmlDocument dom)
{
Dictionary<string, XmlDocument> cachedDoms = new Dictionary<string, XmlDocument>();
cachedDoms.Add(parentPath, dom);
ProcessDom(cachedDoms, null, dom);
cachedDoms.Clear();
}
示例10: GetTests
private void GetTests()
{
methods = methods ?? new LinkedList<MethodInfo>();
methods.Clear();
status = status ?? new Dictionary<MethodInfo, Status>();
status.Clear();
toggleGroup = toggleGroup ?? new Dictionary<string, bool>();
var bindingFlags = BindingFlags.Public;
bindingFlags |= BindingFlags.Static;
bindingFlags |= BindingFlags.DeclaredOnly;
Type[] typelist = GetTypesInNamespace("Exodrifter.ExpressionParser.Test");
for (int i = 0; i < typelist.Length; i++) {
foreach (var method in typelist[i].GetMethods(bindingFlags)) {
if (0 == method.GetParameters().Length) {
methods.AddLast(method);
status.Add(method, Status.UNKNOWN);
if (!toggleGroup.ContainsKey(method.DeclaringType.Name)) {
toggleGroup[method.DeclaringType.Name] = false;
}
}
}
}
}
示例11: Bind
public void Bind(MapperGenerator.Library.Model.TemplateSource.FileModel model, Dictionary<TreeNode, object> templateFileModelMap, TreeView treeFileTemplateModel)
{
treeFileTemplateModel.Nodes.Clear();
templateFileModelMap.Clear();
var fileNode = new TreeNode("File");
templateFileModelMap.Add(fileNode, model);
foreach (var ns in model.Namespaces)
{
var nsNode = new TreeNode(ns.Name.PascalCase);
templateFileModelMap.Add(nsNode, ns);
foreach (var cs in ns.Entities)
{
var csNode = new TreeNode(cs.Name.PascalCase);
templateFileModelMap.Add(csNode, cs);
foreach (var ps in cs.Properties)
{
var psNode = new TreeNode(ps.Name.PascalCase);
templateFileModelMap.Add(psNode, ps);
csNode.Nodes.Add(psNode);
}
nsNode.Nodes.Add(csNode);
}
fileNode.Nodes.Add(nsNode);
}
treeFileTemplateModel.Nodes.Add(fileNode);
treeFileTemplateModel.SelectedNode = fileNode;
treeFileTemplateModel.ExpandAll();
}
示例12: WritePdb
public void WritePdb(SymbolData symData)
{
m_docWriters = new Dictionary<int, ISymbolDocumentWriter>();
ImageDebugDirectory debugDirectory;
byte[] debugInfo = null;
// Rather than use the emitter here, we are just careful enough to emit pdb metadata that
// matches what is already in the assembly image.
object emitter = null;
// We must be careful to close the writer before updating the debug headers. The writer has an
// open file handle on the assembly we want to update.
m_writer = SymbolAccess.GetWriterForFile(m_symFormat, m_outputAssembly, ref emitter);
// We don't actually need the emitter in managed code at all, so release the CLR reference on it
Marshal.FinalReleaseComObject(emitter);
try
{
WriteEntryPoint(symData.entryPointToken);
WriteFiles(symData.sourceFiles);
WriteMethods(symData.methods);
debugInfo = m_writer.GetDebugInfo(out debugDirectory);
}
finally
{
m_writer.Close();
((IDisposable)m_writer).Dispose();
m_writer = null;
m_docWriters.Clear();
}
UpdatePEDebugHeaders(debugInfo);
}
示例13: GetQuaries
static void GetQuaries(string consoleInput)
{
Dictionary<string, List<string>> result = new Dictionary<string,List<string>>();
string pattern = @"(?:\w+)(?:[\%\d\+])*=(?:[\%20|\+])*(([\w\d]*)(?:\%20|\+)*)*(?=[\n\b\&]|$)";
Regex regex = new Regex(pattern);
MatchCollection matches = regex.Matches(consoleInput);
foreach(Match match in matches)
{
string filteredQuery = FilterQuery(match.Value);
string key = GetKey(filteredQuery).Trim();
string values = GetValues(filteredQuery).Trim();
if (!result.ContainsKey(key))
result.Add(key, new List<string>());
result[key].Add(values);
}
PrintQueries(result);
Console.WriteLine();
result.Clear();
}
示例14: setupDeck
private void setupDeck(List<CardDB.cardIDEnum> cardsPlayed, List<CardDB.Card> deckGuessed, Dictionary<CardDB.cardIDEnum, int> knownCards)
{
deckGuessed.Clear();
knownCards.Clear();
foreach (CardDB.cardIDEnum crdidnm in cardsPlayed)
{
if (crdidnm == CardDB.cardIDEnum.GAME_005) continue; //(im sure, he has no coins in his deck :D)
if (knownCards.ContainsKey(crdidnm))
{
knownCards[crdidnm]++;
}
else
{
if (CardDB.Instance.getCardDataFromID(crdidnm).rarity == 5)
{
//you cant own rare ones more than once!
knownCards.Add(crdidnm, 2);
continue;
}
knownCards.Add(crdidnm, 1);
}
}
foreach (KeyValuePair<CardDB.cardIDEnum, int> kvp in knownCards)
{
if (kvp.Value == 1) deckGuessed.Add(CardDB.Instance.getCardDataFromID(kvp.Key));
}
}
示例15: MaxSubString
//Given s string, Find max size of a sub-string, in which no duplicate chars present.
public int MaxSubString(string str)
{
int max = 0;
int count = 0;
int current = 0;
Dictionary<char, int> result = new Dictionary<char, int>();
while (current!=str.Length)
{
if (result.ContainsKey(str[current]))
{
if (count > max)
{
max = count;
}
count = 0;
result.Clear();
str = str.Substring(current+1);
current = 0;
}
else
{
result.Add(str[current], 1);
count++;
current++;
}
}
if (count > max) max = count;
return max;
}