本文整理汇总了C#中System.Collections.Hashtable.Clear方法的典型用法代码示例。如果您正苦于以下问题:C# System.Collections.Hashtable.Clear方法的具体用法?C# System.Collections.Hashtable.Clear怎么用?C# System.Collections.Hashtable.Clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.Hashtable
的用法示例。
在下文中一共展示了System.Collections.Hashtable.Clear方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Parse
/// <summary>
/// Parse the data from specified Uri into a document.
/// </summary>
/// <param name="document">The document instance to store the gained data in.</param>
/// <param name="xmlTextReader">XmlTextReader instance</param>
protected virtual void Parse(OpmlDocument document, System.Xml.XmlReader xmlTextReader)
{
try
{
System.Diagnostics.Debug.Assert(xmlTextReader != null);
//
xmlTextReader.MoveToContent();
if (xmlTextReader.Name != "opml") throw new FormatException(xmlTextReader.BaseURI + " is no valid Opml File");
// read the stream forward while not end of file
int currentDepth = -1;
System.Collections.Hashtable nodeLevels = new System.Collections.Hashtable();
//
while (!xmlTextReader.EOF)
{
// process head
if (xmlTextReader.Name == "head" && xmlTextReader.NodeType == XmlNodeType.Element)
{
document.Head = new OpmlHead(xmlTextReader);
}
// process outline and child outlines
else if (xmlTextReader.Name == "outline" && xmlTextReader.NodeType == XmlNodeType.Element)
{
currentDepth = xmlTextReader.Depth;
//
OpmlOutline o = OnCreateOutline(xmlTextReader);
if (currentDepth == 2)
{
document.Body.Items.Add(o);
// new node
nodeLevels.Clear();
}
else
{
((OpmlOutline)nodeLevels[xmlTextReader.Depth - 1]).Items.Add(o);
}
nodeLevels[xmlTextReader.Depth] = o;
}
else
{
xmlTextReader.Read();
xmlTextReader.MoveToContent();
}
}
}
finally
{
if (xmlTextReader != null) xmlTextReader.Close();
}
}
示例2: TestFieldSelector
public virtual void TestFieldSelector()
{
RAMDirectory ramDirectory1, ramDirectory2;
IndexSearcher indexSearcher1, indexSearcher2;
ramDirectory1 = new RAMDirectory();
ramDirectory2 = new RAMDirectory();
Query query = new TermQuery(new Term("contents", "doc0"));
// Now put the documents in a different index
InitIndex(ramDirectory1, 10, true, null); // documents with a single token "doc0", "doc1", etc...
InitIndex(ramDirectory2, 10, true, "x"); // documents with two tokens "doc0" and "x", "doc1" and x, etc...
indexSearcher1 = new IndexSearcher(ramDirectory1);
indexSearcher2 = new IndexSearcher(ramDirectory2);
MultiSearcher searcher = GetMultiSearcherInstance(new Searcher[]{indexSearcher1, indexSearcher2});
Assert.IsTrue(searcher != null, "searcher is null and it shouldn't be");
ScoreDoc[] hits = searcher.Search(query, null, 1000).scoreDocs;
Assert.IsTrue(hits != null, "hits is null and it shouldn't be");
Assert.IsTrue(hits.Length == 2, hits.Length + " does not equal: " + 2);
Document document = searcher.Doc(hits[0].doc);
Assert.IsTrue(document != null, "document is null and it shouldn't be");
Assert.IsTrue(document.GetFields().Count == 2, "document.getFields() Size: " + document.GetFields().Count + " is not: " + 2);
//Should be one document from each directory
//they both have two fields, contents and other
System.Collections.Hashtable ftl = new System.Collections.Hashtable();
SupportClass.CollectionsHelper.AddIfNotContains(ftl, "other");
SetBasedFieldSelector fs = new SetBasedFieldSelector(ftl, (System.Collections.Hashtable) new System.Collections.Hashtable());
document = searcher.Doc(hits[0].doc, fs);
Assert.IsTrue(document != null, "document is null and it shouldn't be");
Assert.IsTrue(document.GetFields().Count == 1, "document.getFields() Size: " + document.GetFields().Count + " is not: " + 1);
System.String value_Renamed = document.Get("contents");
Assert.IsTrue(value_Renamed == null, "value is not null and it should be");
value_Renamed = document.Get("other");
Assert.IsTrue(value_Renamed != null, "value is null and it shouldn't be");
ftl.Clear();
SupportClass.CollectionsHelper.AddIfNotContains(ftl, "contents");
fs = new SetBasedFieldSelector(ftl, (System.Collections.Hashtable) new System.Collections.Hashtable());
document = searcher.Doc(hits[1].doc, fs);
value_Renamed = document.Get("contents");
Assert.IsTrue(value_Renamed != null, "value is null and it shouldn't be");
value_Renamed = document.Get("other");
Assert.IsTrue(value_Renamed == null, "value is not null and it should be");
}
示例3: CheckHitCollector
/// <summary> Tests that a query matches the an expected set of documents using a
/// HitCollector.
///
/// <p/>
/// Note that when using the HitCollector API, documents will be collected
/// if they "match" regardless of what their score is.
/// <p/>
/// </summary>
/// <param name="query">the query to test
/// </param>
/// <param name="searcher">the searcher to test the query against
/// </param>
/// <param name="defaultFieldName">used for displaying the query in assertion messages
/// </param>
/// <param name="results">a list of documentIds that must match the query
/// </param>
/// <seealso cref="Searcher.Search(Query,HitCollector)">
/// </seealso>
/// <seealso cref="checkHits">
/// </seealso>
public static void CheckHitCollector(Query query, System.String defaultFieldName, Searcher searcher, int[] results)
{
QueryUtils.Check(query, searcher);
System.Collections.Hashtable correct = new System.Collections.Hashtable();
for (int i = 0; i < results.Length; i++)
{
SupportClass.CollectionsHelper.AddIfNotContains(correct, (System.Int32) results[i]);
}
System.Collections.Hashtable actual = new System.Collections.Hashtable();
Collector c = new SetCollector(actual);
searcher.Search(query, c);
Assert.AreEqual(correct, actual, "Simple: " + query.ToString(defaultFieldName));
for (int i = - 1; i < 2; i++)
{
actual.Clear();
QueryUtils.WrapSearcher(searcher, i).Search(query, c);
Assert.AreEqual(correct, actual, "Wrap Searcher " + i + ": " + query.ToString(defaultFieldName));
}
if (!(searcher is IndexSearcher))
return ;
for (int i = - 1; i < 2; i++)
{
actual.Clear();
QueryUtils.WrapUnderlyingReader((IndexSearcher) searcher, i).Search(query, c);
Assert.AreEqual(correct, actual, "Wrap Reader " + i + ": " + query.ToString(defaultFieldName));
}
}
示例4: GetAllFields
public IOdbList<FieldInfo> GetAllFields(string fullClassName)
{
IOdbList<FieldInfo> result = null;
fields.TryGetValue(fullClassName, out result);
if (result != null)
{
return result;
}
System.Collections.IDictionary attributesNames = new System.Collections.Hashtable();
result = new OdbArrayList<FieldInfo>(50);
System.Reflection.FieldInfo[] superClassfields = null;
System.Collections.IList classes = GetSuperClasses(fullClassName, true);
for (int i = 0; i < classes.Count; i++)
{
System.Type clazz1 = (System.Type)classes[i];
superClassfields = clazz1.GetFields(System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.DeclaredOnly | System.Reflection.BindingFlags.Static);
for (int j = 0; j < superClassfields.Length; j++)
{
// Only adds the attribute if it does not exist one with same name
if (attributesNames[superClassfields[j].Name] == null)
{
result.Add(superClassfields[j]);
attributesNames[superClassfields[j].Name] = superClassfields[j].Name;
}
}
}
result = RemoveUnnecessaryFields(result);
fields[fullClassName] = result;
attributesNames.Clear();
attributesNames = null;
return result;
}
示例5: GetAllByAzienda
public UnitaImmobiliareListaDTO[] GetAllByAzienda(int idAzienda)
{
try
{
var daoFactory = _windsorRepository.GetDaoFactory(_info.Azienda);
var db = new UnitaImmobiliareDataContext(daoFactory.GetUnitaImmobiliareDao().GetConnection().ConnectionString);
var unitaImmobiliari = (from unita in db.GetAll_UnitaImmobiliari(idAzienda)
select unita).ToArray<UnitaImmobiliareListaDTO>();
var impostazioniAzienda = daoFactory.GetImpostazioniAziendaDao().GetByAzienda(_info.Azienda);
var memoryEngine = NVelocityEngineFactory.CreateNVelocityMemoryEngine(true);
System.Collections.IDictionary context = new System.Collections.Hashtable();
foreach (var t in unitaImmobiliari)
{
try
{
// ==========================================================
// Applico il formato definito a livello di azienda
// ==========================================================
if (impostazioniAzienda != null)
{
if (impostazioniAzienda.FormatoNomeProprietario != FormatoTesto.NonDefinito)
t.Proprietario = Conversione.ToStringFormat(t.Proprietario, impostazioniAzienda.FormatoNomeProprietario);
if (impostazioniAzienda.FormatoNomeConduttore != FormatoTesto.NonDefinito)
t.Conduttore = Conversione.ToStringFormat(t.Conduttore, impostazioniAzienda.FormatoNomeConduttore);
}
var conduttore = t.Conduttore;
if (string.IsNullOrEmpty(conduttore))
conduttore = " ";
// ==========================================================
// Applico il template
// ==========================================================
if (!string.IsNullOrEmpty(t.Descrizione) && t.Descrizione.Contains("$"))
{
// ----------------------------------------------------------------------------
// Se presente più di un proprietario modifico la descrizione del proprietario
// ----------------------------------------------------------------------------
var proprietario1 = t.Proprietario;
var proprietario2 = string.Empty;
if (t.Descrizione.Contains("$proprietario2"))
{
var unita = daoFactory.GetUnitaImmobiliareDao().GetById(t.Id, false);
var proprietarioSecondario = unita.Proprietari.FirstOrDefault(item => !item.Principale.GetValueOrDefault());
if (proprietarioSecondario != null)
{
proprietario2 = proprietarioSecondario.DisplayName;
t.Proprietario += " / " + proprietario2;
}
}
// ----------------------------------------------------------------------------
// Applico il template alla descrizione e alla descrizione completa (DisplayName)
// ----------------------------------------------------------------------------
context.Clear();
context.Add("interno", t.Interno);
context.Add("progressivo", t.Ordine);
context.Add("piano", t.Piano);
context.Add("proprietario1", proprietario1);
context.Add("proprietario2", proprietario2);
context.Add("conduttore1", conduttore);
var descrizione = memoryEngine.Process(context, t.Descrizione);
var descrizioneCompleta = memoryEngine.Process(context, t.DisplayName);
try
{
if (descrizione.Trim().EndsWith("-"))
descrizione = descrizione.Trim().Substring(0, descrizione.Trim().Length - 1).Trim();
if (descrizioneCompleta.Trim().EndsWith("-"))
descrizioneCompleta = descrizioneCompleta.Trim().Substring(0, descrizioneCompleta.Trim().Length - 1).Trim();
}
catch (Exception ex)
{
_log.ErrorFormat("Errore nella formattazione della descrizione della unità immobiliare - {0} - unità:{1} - descrizione:{2} - descrizioneCompleta:{3}", ex, Utility.GetMethodDescription(), t.Id, descrizione, descrizioneCompleta);
}
t.Descrizione = descrizione;
t.DisplayName = descrizioneCompleta;
}
}
catch (Exception ex)
{
_log.ErrorFormat("Errore nel caricamento delle unita immobiliari - (SINGOLA UNITA' IMMOBILIARE) - {0} - unità:{1} - idAzienda:{2}", ex, Utility.GetMethodDescription(), t.Id, idAzienda);
throw;
}
}
return unitaImmobiliari;
}
catch (Exception ex)
{
_log.ErrorFormat("Errore nel caricamento delle unità immobiliari - {0} - idAzienda:{1}", ex, Utility.GetMethodDescription(), idAzienda);
throw;
}
//.........这里部分代码省略.........