private void cbxLayers2Symbolize_SelectedIndexChanged(object sender, EventArgs e) { if (cbxLayers2Symbolize.SelectedItem != null) { string strLayer2Symbolize = cbxLayers2Symbolize.SelectedItem.ToString(); layer2Symbolize = GetFeatureLayer(strLayer2Symbolize); lstSourceFieldsAdditems(layer2Symbolize); lvRendererFields.Items.Clear(); fieldSymbolHashTable.Clear(); if (layer2Symbolize.FeatureClass.ShapeType == esriGeometryType.esriGeometryPolyline) { gBaseSymbol = new SimpleLineSymbolClass(); (gBaseSymbol as ISimpleLineSymbol).Color = getRGB(128, 128, 255); } if (layer2Symbolize.FeatureClass.ShapeType == esriGeometryType.esriGeometryPolygon) { gBaseSymbol = new SimpleFillSymbolClass(); (gBaseSymbol as ISimpleFillSymbol).Color = getRGB(128, 128, 255); } if (layer2Symbolize.FeatureClass.ShapeType == esriGeometryType.esriGeometryPoint || layer2Symbolize.FeatureClass.ShapeType == esriGeometryType.esriGeometryMultipoint) { gBaseSymbol = new SimpleMarkerSymbolClass(); (gBaseSymbol as ISimpleMarkerSymbol).Color = getRGB(128, 128, 255); //btnSelectBackGroud.Enabled = false; } else { btnSelectBackGroud.Enabled = true; } } }
public void ClearCache() { lock (CachedElements) { CachedElements.Clear(); } }
/// <summary> Stop the rentransmition and clear all pending msgs. /// <p> /// If this retransmitter has been provided an externally managed /// scheduler, then just clear all msgs and the associated tasks, else /// stop the scheduler. In this case the method blocks until the /// scheduler's thread is dead. Only the owner of the scheduler should /// stop it. /// </summary> public void stop() { Entry entry; // i. If retransmitter is owned, stop it else cancel all tasks // ii. Clear all pending msgs and notify anyone waiting lock (msgs.SyncRoot) { if (retransmitter_owned) { try { retransmitter.Dispose(); } catch (System.Threading.ThreadInterruptedException ex) { NCacheLog.Error("AckMcastSenderWindow.stop()", ex.ToString()); } } else { for (System.Collections.IEnumerator e = msgs.Values.GetEnumerator(); e.MoveNext();) { entry = (Entry)e.Current; entry.cancel(); } } msgs.Clear(); // wake up waitUntilAllAcksReceived() method System.Threading.Monitor.Pulse(msgs.SyncRoot); } }
/// <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)); } }
private void cbxLayers2Symbolize_SelectedIndexChanged(object sender, EventArgs e) { if (cbxLayers2Symbolize.SelectedItem != null) { string strLayer2Symbolize = cbxLayers2Symbolize.SelectedItem.ToString(); layer2Symbolize = GetFeatureLayer(strLayer2Symbolize); lstSourceFieldsAdditems(layer2Symbolize); lvRendererFields.Items.Clear(); fieldSymbolHashTable.Clear(); } }
// いくつかはrefでなくても大丈夫かも private void createDlgTree(ref uint[] start, ref ConversationNode[] nodes, ref TreeNode dlg) { // 親が別枝で出た場合に親だけ重複してしかも1個だけの親が出来るのでとりあえず枝毎にやる方向で // さらにstartindexも調べることでに到達したかどうかが分かるので枝を中断できるのだが重そうだ // ここで真っ先にstartをrepeat_tableに登録すると重複しないんじゃね? // と思ったら自分も登録できない罠 // repeat_tableをローカルにしてスレッドのこと考えた方がいいのかなあ dlg.Nodes.Clear(); repeat_table.Clear(); // 念のため // 毎回startか調べるのは重いのでこれは親かどうかのフラグ付けを事前にやっとくのかなあ for (int i = 0; i < start.Length; ++i) { ConversationNode root = nodes[start[i]]; root.start = true; } for (int i = 0; i < start.Length; ++i) { // startは優先しない、とにかく先に出た方を優先する // startも重複しないように切り捨てる bool has = repeat_table.ContainsKey(start[i]); if (has) { continue; } ConversationNode root = nodes[start[i]]; createConversationTree(root, nodes); dlg.Nodes.Add(root); //repeat_table.Clear(); // ここでクリアすると重複は親ごとか if (i % 2 == 1) { //root.BackColor = Color.FromArgb( 255, 240, 230 ); } } //これはstartでstartrootを優先するとつかえんなあ repeat_table.Clear(); // dlg全体で1回です // startを優先するか、他の枝を優先するかで変わってきそうだ // 個人的にはstart至上にしたいが、startだけでは意味の通らない展開がなければいいのだが // start至上だとstart別になるのでその分重複ノード数増えるし // とりあえずstartを切り捨ててみるか、最初のknight1ってのはstart優先させると分かりにくいし }
void Compiler_OnChangeCompilerState(PascalABCCompiler.ICompiler sender, PascalABCCompiler.CompilerState State, string FileName) { if (!Visible) { return; } switch (State) { case PascalABCCompiler.CompilerState.CompilationStarting: BuildButtonsEnabled = syntaxTreeSelectComboBox.Enabled = false; this.Refresh(); break; case PascalABCCompiler.CompilerState.CompilationFinished: Errors.Clear(); if (VisualEnvironmentCompiler.Compiler.ErrorsList.Count > 0) { SyntaxError er; for (int i = 0; i < VisualEnvironmentCompiler.Compiler.ErrorsList.Count; i++) { er = VisualEnvironmentCompiler.Compiler.ErrorsList[i] as SyntaxError; if (er != null && er.bad_node != null) { Errors[er.bad_node] = i; } } } UpdateSelectList(); ShowTree(); BuildButtonsEnabled = true; break; } }
void ThreadLoop() { while (!this.m_disposed) { System.Collections.Hashtable hash = null; lock (lockobject) hash = (System.Collections.Hashtable)dataPoints.Clone(); if (hash.Count > 0) { DateTime last = new DateTime(); foreach (var value in hash.Values) { last = (DateTime)value; } if (DateTime.Now.Subtract(last).Seconds > 0) { lock (lockobject) dataPoints.Clear(); } } hash.Clear(); hash = null; Thread.Sleep(250); } }
private void Init() { Table.Clear(); Table.Add('0', "101010011"); Table.Add('1', "101011001"); Table.Add('2', "101001011"); Table.Add('3', "110010101"); Table.Add('4', "101101001"); Table.Add('5', "110101001"); Table.Add('6', "100101011"); Table.Add('7', "100101101"); Table.Add('8', "100110101"); Table.Add('9', "110100101"); Table.Add('-', "101001101"); Table.Add('$', "101100101"); Table.Add(':', "1101011011"); Table.Add('/', "1101101011"); Table.Add('.', "1101101101"); Table.Add('+', "101100110011"); Table.Add('A', "1011001001"); Table.Add('B', "1010010011"); Table.Add('C', "1001001011"); Table.Add('D', "1010011001"); Table.Add('a', "1011001001"); Table.Add('b', "1010010011"); Table.Add('c', "1001001011"); Table.Add('d', "1010011001"); }
/// <summary> Removes the VMs and the namespace from the manager. /// Used when a template is reloaded to avoid /// accumulating drek /// * /// </summary> /// <param name="namespace">namespace to dump /// </param> /// <returns>boolean representing success /// /// </returns> public virtual bool dumpNamespace(System.String namespace_Renamed) { lock (this) { if (usingNamespaces(namespace_Renamed)) { System.Object temp_key; System.Collections.Hashtable temp_hashtable; temp_key = namespace_Renamed; temp_hashtable = namespaceHash; System.Collections.Hashtable h = (System.Collections.Hashtable)temp_hashtable[temp_key]; temp_hashtable.Remove(temp_key); if (h == null) { return(false); } h.Clear(); return(true); } return(false); } }
/// <summary> /// 清除缓存中所有对象 /// </summary> public virtual void Clear() { lock (_Cache.SyncRoot) { _Cache.Clear(); } }
private void OnDispose() { TcpServer.DisposeSocket(mSocket); try { if (Package != null) { Package.Channel = null; } mSocket = null; mSendSAEA.SetBuffer(null, 0, 0); mReceiveSAEA.SetBuffer(null, 0, 0); mSendSAEA.Completed -= OnSend; mReceiveSAEA.Completed -= OnReceive; while (mDatas.Count > 0) { SendData(GetSendData()); } if (ChannelDisposed != null) { ChannelDisposed(Server, new ChannelEventArgs { Channel = this }); } } finally { mProperties.Clear(); mServer = null; } }
/// <summary> /// Function to create subscription list and subscribe to pagedata /// </summary> /// <param name="session"></param> private void subscribe(Session session) { System.Collections.Generic.List <Subscription> subscriptions = new System.Collections.Generic.List <Subscription>(); d_topicTable.Clear(); List <string> fields = new List <string>(); fields.Add("6-23"); // Following commented code shows some of the sample values // that can be used for field other than above // e.g. fields.Add("1"); // fields.Add("1,2,3"); // fields.Add("1,6-10,15,16"); foreach (string topic in d_topics) { subscriptions.Add(new Subscription(PAGEDATA_SVC + "/" + topic, fields, null, new CorrelationID(topic))); d_topicTable.Add(topic, new ArrayList()); } if (d_authOption == "NONE") { session.Subscribe(subscriptions); } else { session.Subscribe(subscriptions, d_identity); } }
public void RefreshTreeView() { Nodes.Clear(); _nodelist.Clear(); //this.PopulateTreeView(-1); PopulateTreeViewThreaded(); }
/// <summary> /// 清除缓存中所有对象 /// </summary> public virtual void Clear() { lock (hashTableCache.SyncRoot) { hashTableCache.Clear(); } }
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); }
}//Encode_Codabar private void InitCodabar() { _codabarCode.Clear(); _codabarCode.Add('0', "101010011"); _codabarCode.Add('1', "101011001"); _codabarCode.Add('2', "101001011"); _codabarCode.Add('3', "110010101"); _codabarCode.Add('4', "101101001"); _codabarCode.Add('5', "110101001"); _codabarCode.Add('6', "100101011"); _codabarCode.Add('7', "100101101"); _codabarCode.Add('8', "100110101"); _codabarCode.Add('9', "110100101"); _codabarCode.Add('-', "101001101"); _codabarCode.Add('$', "101100101"); _codabarCode.Add(':', "1101011011"); _codabarCode.Add('/', "1101101011"); _codabarCode.Add('.', "1101101101"); _codabarCode.Add('+', "101100110011"); _codabarCode.Add('A', "1011001001"); _codabarCode.Add('B', "1001001011"); _codabarCode.Add('C', "1010010011"); _codabarCode.Add('D', "1010011001"); _codabarCode.Add('a', "1011001001"); _codabarCode.Add('b', "1001001011"); _codabarCode.Add('c', "1010010011"); _codabarCode.Add('d', "1010011001"); } //init_Codeabar
private void LoadAssocs() { string path = System.IO.Path.GetDirectoryName( System.Reflection.Assembly.GetExecutingAssembly().Location); if (hash_leaders != null && hash_leaders.Count > 0) { hash_leaders.Clear(); } if (hash_assoc != null && hash_assoc.Count > 0) { hash_assoc.Clear(); } //System.Windows.Forms.MessageBox.Show(path); if (path.EndsWith(System.IO.Path.DirectorySeparatorChar.ToString()) == false) { path += System.IO.Path.DirectorySeparatorChar.ToString(); } path += "ris_templates" + System.IO.Path.DirectorySeparatorChar.ToString(); System.IO.StreamReader reader = new System.IO.StreamReader(path + "assoc.txt"); string tmp = ""; while (reader.Peek() > -1) { tmp = reader.ReadLine(); if (tmp.Trim().Length > 0) { string[] tarr = tmp.Split("=".ToCharArray()); hash_assoc.Add(tarr[0], tarr[1]); } } reader.Close(); string[] sfiles = new string[8]; sfiles[0] = "books.txt"; sfiles[1] = "serials.txt"; sfiles[2] = "visual_mat.txt"; sfiles[3] = "maps.txt"; sfiles[4] = "sound_rec.txt"; sfiles[5] = "scores.txt"; sfiles[6] = "electronic_resources.txt"; sfiles[7] = "mixed_mat.txt"; string tmp_line = ""; foreach (string ts in sfiles) { reader = new System.IO.StreamReader(path + ts); tmp_line = reader.ReadToEnd(); hash_leaders.Add(ts.Replace(".txt", ""), tmp_line); reader.Close(); } }
internal virtual void Clear() { terms.Clear(); queries.Clear(); docIDs.Clear(); numTerms = 0; bytesUsed = 0; }
/// <summary> /// Gets row as Hashtable /// </summary> /// <param name="row">int - row index</param> /// <param name="data">Hashtable reference</param> public void RowAsHashtable(int row, ref System.Collections.Hashtable data) { data.Clear(); for (int i = 0; i < this.Cols; i++) { data[i] = this.Data[row][i]; } }
public void Clear() { foreach (object ps in _List.Values) { ((PacketSocket)ps).currentSocket.Close(); } _List.Clear(); }
public void Visit(object t, object parent, int childIndex, IDictionary unusedlabels) { // the unusedlabels arg is null as visit on token type doesn't set. labels.Clear(); if (owner._Parse(t, pattern, labels)) { visitor.Visit(t, parent, childIndex, labels); } }
//Added by Lailin Chen to clear the SnapData list. 12/12/2005 public void ClearSnapData() { foreach (System.Collections.DictionaryEntry a in m_lists) { ((System.Collections.SortedList)a.Value).Clear(); } m_lists.Clear(); //System.GC.Collect(); don't do this, let the VM determine when to collect!!! }
// Overriding Dispose is a must to free our window handle we created at the constructor. protected override void Dispose(bool disposing) { if (disposing) { tooltexts.Clear(); tooltexts = null; } DestroyWindow(toolwindow); // Free the window handle obtained by CreateWindowEx. base.Dispose(disposing); }
/// <summary> /// Encode the raw data using the Code 39 algorithm. /// </summary> private string Encode_Code39() { init_Code39(); init_ExtendedCode39(); var strNoAstr = Raw_Data.Replace("*", ""); var strFormattedData = "*" + strNoAstr + (_enableChecksum ? GetChecksumChar(strNoAstr).ToString() : String.Empty) + "*"; if (_allowExtended) { InsertExtendedCharsIfNeeded(ref strFormattedData); } var result = ""; //foreach (char c in this.FormattedData) foreach (var c in strFormattedData) { try { result += C39_Code[c].ToString(); result += "0";//whitespace }//try catch { if (_allowExtended) { Error("EC39-1: Invalid data."); } else { Error("EC39-1: Invalid data. (Try using Extended Code39)"); } } //catch } //foreach result = result.Substring(0, result.Length - 1); //clear the hashtable so it no longer takes up memory C39_Code.Clear(); return(result); }//Encode_Code39
//Clear all the collections public void Clear() { strMachineName = ""; if (lstPcsRun != null) { lstPcsRun.Items.Clear(); lstPcsRun.SelectedIndexChanged -= new System.EventHandler(this.SelectedProcess); lstPcsRun.MouseDown -= new System.Windows.Forms.MouseEventHandler(this.ListOptions); } if (lstPcs != null) { lstPcs.Items.Clear(); lstPcs.SelectedIndexChanged -= new System.EventHandler(this.SelectedProcess); lstPcs.MouseDown -= new System.Windows.Forms.MouseEventHandler(this.ListOptions); } colProcesses.Clear(); }
/// <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(); } } }
public void Clear() { foreach (object key in _hash.Keys) { if (key is Altaxo.Main.IEventIndicatedDisposable) { (key as Altaxo.Main.IEventIndicatedDisposable).Disposed -= EhKeyDisposed; } } _hash.Clear(); }
public static void LoadHashTables(string xmlPath) { VBTypes.Clear(); CSharpTypes.Clear(); JavaTypes.Clear(); DotNetTypes.Clear(); libraryTypes.Clear(); langSpecificTypes.Clear(); calculateLengths.Clear(); if (System.IO.File.Exists(xmlPath)) { System.Xml.XmlDocument document = new System.Xml.XmlDocument(); document.Load(xmlPath); System.Xml.XmlNodeList nodeList = document.GetElementsByTagName("*"); foreach (System.Xml.XmlNode node in nodeList) { if (node.Attributes["VBType"] != null && node.Attributes["name"] != null) { VBTypes.Add(node.Attributes["name"].Value, node.Attributes["VBType"].Value); } if (node.Attributes["CSharpType"] != null && node.Attributes["name"] != null) { CSharpTypes.Add(node.Attributes["name"].Value, node.Attributes["CSharpType"].Value); } if (node.Attributes["JavaType"] != null && node.Attributes["name"] != null) { JavaTypes.Add(node.Attributes["name"].Value, node.Attributes["JavaType"].Value); } if (node.Attributes["DotNetType"] != null && node.Attributes["name"] != null) { DotNetTypes.Add(node.Attributes["name"].Value, node.Attributes["DotNetType"].Value); } if (node.Attributes["LibraryType"] != null && node.Attributes["name"] != null) { libraryTypes.Add(node.Attributes["name"].Value, node.Attributes["LibraryType"].Value); } if (node.Attributes["LanguageSpecificType"] != null && node.Attributes["name"] != null) { langSpecificTypes.Add(node.Attributes["name"].Value, node.Attributes["LanguageSpecificType"].Value); } if (node.Attributes["CalculateLength"] != null && node.Attributes["name"] != null) { calculateLengths.Add(node.Attributes["name"].Value, node.Attributes["CalculateLength"].Value); } } } }
public void DefaultHashtable_Clear(int[] items, int capacity) { var hashtable = new System.Collections.Hashtable(capacity); for (int i = 0; i < items.Length; i++) { hashtable.Add($"item {items[i]}", items[i]); } hashtable.Clear(); }
/// <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(); } }
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; } }
/// <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)); } }
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; }
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"); }