public void VisualizerAudioEffect_CanSetAnalyzerType(AnalyzerType type) { IVisualizationSource source = (IVisualizationSource)sut; source.AnalyzerTypes = type; Assert.AreEqual(type, source.AnalyzerTypes); }
/// <summary> /// Returns an Analyzer for the given AnalyzerType /// </summary> /// <param name="oAnalyzerType">Enumeration value</param> /// <returns>Analyzer</returns> public static Analyzer GetAnalyzer(AnalyzerType oAnalyzerType) { Analyzer oAnalyzer = null; switch (oAnalyzerType) { case AnalyzerType.SimpleAnalyzer: oAnalyzer = new SimpleAnalyzer(); break; case AnalyzerType.StopAnalyzer: oAnalyzer = new StopAnalyzer(); break; case AnalyzerType.WhitespaceAnalyzer: oAnalyzer = new WhitespaceAnalyzer(); break; default: case AnalyzerType.StandardAnalyzer: oAnalyzer = new StandardAnalyzer(); break; } return(oAnalyzer); }
/// <summary> /// Gets a Lucene <c>Analyzer</c> from the API enumerator <see cref="IndexLibrary.AnalyzerType"/> /// </summary> /// <param name="type">The type of <c>Analyzer</c> to create</param> /// <returns>A real Lucene <c>Analyzer</c> that is equivalent to the specified <c>AnalyzerType</c></returns> public static Analyzer GetAnalyzer(AnalyzerType type) { switch (type) { case AnalyzerType.Standard: case AnalyzerType.Default: return(new Lucene29.Net.Analysis.Standard.StandardAnalyzer(StaticValues.LibraryVersion)); case AnalyzerType.Simple: return(new SimpleAnalyzer()); case AnalyzerType.Stop: return(new StopAnalyzer(StaticValues.LibraryVersion)); case AnalyzerType.Keyword: return(new KeywordAnalyzer()); case AnalyzerType.Whitespace: return(new WhitespaceAnalyzer()); case AnalyzerType.None: return(null); default: return(new Lucene29.Net.Analysis.Standard.StandardAnalyzer(StaticValues.LibraryVersion)); } }
public IndexWriter(IIndex index, AnalyzerType analyzer, bool create, bool allowUnlimitedFieldLength) { if (index == null) { throw new ArgumentNullException("index", "index cannot be null"); } if (index.IndexStructure == IndexType.None) { throw new ArgumentException("The specified index structure cannot be None", "index"); } if (analyzer == AnalyzerType.None || analyzer == AnalyzerType.Unknown) { throw new ArgumentException("The specified analyzer cannot be None or Unknown", "analyzer"); } this.analyzer = TypeConverter.GetAnalyzer(analyzer); this.index = index; DirectoryInfo writeDirectory = null; bool hasIndexfiles = GetIndexWriteDirectory(out writeDirectory); // you said append but there's no index files if (!create && !hasIndexfiles) { create = true; } this.openDirectory = Lucene29.Net.Store.FSDirectory.Open(writeDirectory); this.writer = new Lucene29.Net.Index.IndexWriter(this.openDirectory, this.analyzer, create, (allowUnlimitedFieldLength) ? Lucene29.Net.Index.IndexWriter.MaxFieldLength.UNLIMITED : Lucene29.Net.Index.IndexWriter.MaxFieldLength.LIMITED); }
/// <summary> /// Takes the manaually generated query and runs it through a Lucene analyzer /// </summary> /// <param name="analyzer">Analyzer to use when parsing this query</param> /// <param name="occurrence">Occurrence type of this query</param> internal void Analyze(Lucene29.Net.Analysis.Analyzer analyzer, ClauseOccurrence occurrence) { if (analyzer == null) { throw new ArgumentNullException("analyzer", "Analyzer cannot be null"); } try { AnalyzerType requestedType = TypeConverter.GetAnalyzerType(analyzer); if (cachedAnalyzer != requestedType) { lock (syncRoot) { if (cachedAnalyzer != requestedType) { cachedParser = new Lucene29.Net.QueryParsers.QueryParser(StaticValues.LibraryVersion, "Analyzer", analyzer); cachedAnalyzer = requestedType; cachedParser.SetAllowLeadingWildcard(this.allowLeadingWildcard); } } } Query query = cachedParser.Parse(this.luceneQuery.ToString()); this.luceneQuery = null; this.luceneQuery = new BooleanQuery(this.disableCoord); this.luceneQuery.Add(query, TypeConverter.ConvertToLuceneClauseOccurrence(occurrence)); } catch (Exception ex) { throw new FormatException("There was an unexpected exception thrown during the analyzing process of the instance.", ex); } }
public void AddMsgType(AnalyzerType analyzerType) { _writer.WriteLine("<tr style='background: lightcyan;'>"); _writer.WriteLine( "<td colspan='5' style='color: red; text-align: center; font-size: 1.2em;'>{0}</td>", Utils.GetDescription(analyzerType)); _writer.WriteLine("</tr>"); _withMsgType = true; }
/// <summary> /// Получает короткое имя для типа сообщений анализатора /// </summary> /// <param name="analyzerType">Тип сообщений анализатора</param> /// <returns>Короткое имя типа сообщений анализатора</returns> public static string GetShortName(AnalyzerType analyzerType) { return (analyzerType.GetType() .GetField(analyzerType.ToString()) .GetCustomAttributes(typeof(XmlEnumAttribute), false) .Cast <XmlEnumAttribute>() .First() .Name); }
/// <summary> /// Initializes a new instance of the <see cref="WriterEventArgs"/> class. /// </summary> /// <param name="document">The document to write.</param> /// <param name="analyzer">The analyzer being used to write.</param> /// <param name="indexName">Name of the index being written to.</param> public WriterEventArgs(IndexDocument document, AnalyzerType analyzer, string indexName) { if (document == null) throw new ArgumentNullException("document", "document cannot be null"); if (string.IsNullOrEmpty(indexName)) throw new ArgumentNullException("indexName", "indexName cannot be null or empty"); this.document = document; this.analyzer = analyzer; this.index = indexName; this.cancel = false; }
/// <summary> /// Takes the manaually generated query and runs it through a specified Lucene analyzer /// </summary> /// <param name="analyzerType">Lucene analyzer to run current query through</param> /// <param name="occurrence">Occurrence type of this query</param> public void Analyze(AnalyzerType analyzerType, ClauseOccurrence occurrence) { if (analyzerType == AnalyzerType.None) { throw new ArgumentException("analyzerType cannot be set to None", "analyzerType"); } if (analyzerType == AnalyzerType.Unknown) { throw new ArgumentException("analyzerType cannot be set to Unknown", "analyzerType"); } Analyze(TypeConverter.GetAnalyzer(analyzerType), occurrence); }
/// <summary> /// Initializes a new instance of the <see cref="WriterEventArgs"/> class. /// </summary> /// <param name="document">The document to write.</param> /// <param name="analyzer">The analyzer being used to write.</param> /// <param name="indexName">Name of the index being written to.</param> public WriterEventArgs(IndexDocument document, AnalyzerType analyzer, string indexName) { if (document == null) { throw new ArgumentNullException("document", "document cannot be null"); } if (string.IsNullOrEmpty(indexName)) { throw new ArgumentNullException("indexName", "indexName cannot be null or empty"); } this.document = document; this.analyzer = analyzer; this.index = indexName; this.cancel = false; }
/// <summary> /// 返回经过排序后的歌曲 /// </summary> /// <param name="Type"></param> /// <returns></returns> public List<Music> GetMusics(AnalyzerType Type) { List<Music> Musics = new List<Music>(); switch (Type) { case AnalyzerType.Like: LikeAnalyzer LikeAnalyzer = new LikeAnalyzer(this); Musics=LikeAnalyzer.SortByLike(); break; case AnalyzerType.Listen: ListenAnalyzer ListenAnalyzer = new ListenAnalyzer(this); Musics= ListenAnalyzer.SortByListen(); break; case AnalyzerType.Total: TotalAnalyzer TotalAnalyzer = new TotalAnalyzer(this); Musics= TotalAnalyzer.SortByTotal(); break; } return Musics; }
/// <summary> /// Writes the specified document. /// </summary> /// <param name="document">The document to out.</param> /// <param name="appliedAnalyzer">An analyzer to use against specifically this field.</param> /// <remarks> /// This is useful if you have a specific type of field or document that needs special analysis rules; /// not normally helpful if the analyzer is more complex, usually useful if the analyzer is less complex. /// </remarks> public void Write(IndexDocument document, AnalyzerType appliedAnalyzer) { if (this.isDisposed) { throw new ObjectDisposedException("IndexWriter", "You cannot access this method from a disposed IndexWriter"); } if (document == null) { throw new ArgumentNullException("document", "document cannot be null"); } OnWriting(new WriterEventArgs(document, (appliedAnalyzer == IndexLibrary.AnalyzerType.None || appliedAnalyzer == IndexLibrary.AnalyzerType.Unknown) ? this.AnalyzerType : appliedAnalyzer, this.index.IndexDirectory.Name)); if (appliedAnalyzer != IndexLibrary.AnalyzerType.None && appliedAnalyzer != IndexLibrary.AnalyzerType.Unknown) { this.writer.AddDocument(document.GetLuceneDocument, TypeConverter.GetAnalyzer(appliedAnalyzer)); } else { this.writer.AddDocument(document.GetLuceneDocument); } this.totalWrites++; }
/// <summary> /// 返回经过排序后的歌曲 /// </summary> /// <param name="Type"></param> /// <returns></returns> public List <Music> GetMusics(AnalyzerType Type) { List <Music> Musics = new List <Music>(); switch (Type) { case AnalyzerType.Like: LikeAnalyzer LikeAnalyzer = new LikeAnalyzer(this); Musics = LikeAnalyzer.SortByLike(); break; case AnalyzerType.Listen: ListenAnalyzer ListenAnalyzer = new ListenAnalyzer(this); Musics = ListenAnalyzer.SortByListen(); break; case AnalyzerType.Total: TotalAnalyzer TotalAnalyzer = new TotalAnalyzer(this); Musics = TotalAnalyzer.SortByTotal(); break; } return(Musics); }
/// <summary> /// 获取分词器 /// </summary> /// <param name="type"></param> /// <returns></returns> public static Analyzer GetAnalyzer(AnalyzerType type) { switch (type) { case AnalyzerType.StandardAnalyzer: return(new StandardAnalyzer(Version.LUCENE_30)); case AnalyzerType.SimpleAnalyzer: return(new SimpleAnalyzer()); case AnalyzerType.KeywordAnalyzer: return(new KeywordAnalyzer()); case AnalyzerType.WhitespaceAnalyzer: return(new WhitespaceAnalyzer()); case AnalyzerType.StopAnalyzer: return(new StopAnalyzer(Version.LUCENE_30)); default: return(new StandardAnalyzer(Version.LUCENE_30)); } }
public ChartLine Factory(AnalyzerType analyzerType, bool logarithmic) { var channel = analyzerType switch { AnalyzerType.PowerSpectralDensity => logarithmic ? Analyzer.LogarithmicPsd() : Analyzer.PowerSpectralDensity(), AnalyzerType.AmplitudeSpectralDensity => logarithmic ? Analyzer.LogarithmicAsd() : Analyzer.AmplitudeSpectralDensity(), _ => throw new NotSupportedException() }; var chartLine = new ChartLine(channel) { Scaling = ChartLine.ScalingMode.LocalZeroed, ContextMenu = new ContextMenu() }; FrequencyChartSetup(chartLine); return(chartLine); } }
/// <summary> /// Adds the string query. /// </summary> /// <param name="queryText">The query text.</param> /// <param name="occurrence">The occurrence.</param> /// <param name="analyzerType">Type of the analyzer.</param> /// <param name="merge">if set to <c>true</c> [merge].</param> /// <returns>True if query string is parsed and appended successfully</returns> public bool AddStringQuery(string queryText, ClauseOccurrence occurrence, AnalyzerType analyzerType, bool merge) { if (string.IsNullOrEmpty(queryText)) { throw new ArgumentNullException("queryText", "queryText cannot be null or empty"); } // this try catch is here to protect you from lucene specific exceptions bool success = true; IncrementTotalClauses(1); try { Lucene29.Net.QueryParsers.QueryParser parser = new Lucene29.Net.QueryParsers.QueryParser(StaticValues.LibraryVersion, "QueryParser", TypeConverter.GetAnalyzer(analyzerType)); Query query = parser.Parse(queryText); if (query == null) { success = false; } else { if (merge) { this.luceneQuery.Combine(new Query[] { query }); } else { this.luceneQuery.Add(query, TypeConverter.ConvertToLuceneClauseOccurrence(occurrence)); } } } catch (Exception) { //System.Diagnostics.Debug.WriteLine("Lucene exception -> " + ex.Message); success = false; this.totalClauses--; } return(success); }
private void OpenFile(string author, bool withHeader, bool withMsgType, AnalyzerType analyzerType = AnalyzerType.Unknown) { if (_writers.ContainsKey(author)) { return; } try { HtmlWriter htmlWriter = new HtmlWriter(RenderInfo, author); if (withHeader) { htmlWriter.AddHeader(); } if (withMsgType) { htmlWriter.AddMsgType(analyzerType); } _writers.Add(author, htmlWriter); } catch (Exception) { ; } }
public override IndexWriter GetWriter(AnalyzerType analyzerType, bool create) { return this.GetWriter(analyzerType, create, true); }
/// <summary> /// Gets a Lucene <c>Analyzer</c> from the API enumerator <see cref="IndexLibrary.AnalyzerType"/> /// </summary> /// <param name="type">The type of <c>Analyzer</c> to create</param> /// <returns>A real Lucene <c>Analyzer</c> that is equivalent to the specified <c>AnalyzerType</c></returns> public static Analyzer GetAnalyzer(AnalyzerType type) { switch (type) { case AnalyzerType.Standard: case AnalyzerType.Default: return new Lucene29.Net.Analysis.Standard.StandardAnalyzer(StaticValues.LibraryVersion); case AnalyzerType.Simple: return new SimpleAnalyzer(); case AnalyzerType.Stop: return new StopAnalyzer(StaticValues.LibraryVersion); case AnalyzerType.Keyword: return new KeywordAnalyzer(); case AnalyzerType.Whitespace: return new WhitespaceAnalyzer(); case AnalyzerType.None: return null; default: return new Lucene29.Net.Analysis.Standard.StandardAnalyzer(StaticValues.LibraryVersion); } }
/// <summary> /// Takes the manaually generated query and runs it through a specified Lucene analyzer /// </summary> /// <param name="analyzerType">Lucene analyzer to run current query through</param> /// <param name="occurrence">Occurrence type of this query</param> public void Analyze(AnalyzerType analyzerType, ClauseOccurrence occurrence) { if (analyzerType == AnalyzerType.None) throw new ArgumentException("analyzerType cannot be set to None", "analyzerType"); if (analyzerType == AnalyzerType.Unknown) throw new ArgumentException("analyzerType cannot be set to Unknown", "analyzerType"); Analyze(TypeConverter.GetAnalyzer(analyzerType), occurrence); }
/// <summary> /// Returns an Analyzer for the given AnalyzerType /// </summary> /// <param name="oAnalyzerType">Enumeration value</param> /// <returns>Analyzer</returns> public static Analyzer GetAnalyzer(AnalyzerType oAnalyzerType) { Analyzer oAnalyzer = null; switch (oAnalyzerType) { case AnalyzerType.SimpleAnalyzer: oAnalyzer = new SimpleAnalyzer(); break; case AnalyzerType.StopAnalyzer: oAnalyzer = new StopAnalyzer(); break; case AnalyzerType.WhitespaceAnalyzer: oAnalyzer = new WhitespaceAnalyzer(); break; default: case AnalyzerType.StandardAnalyzer: oAnalyzer = new StandardAnalyzer(); break; } return oAnalyzer; }
public virtual IndexWriter GetWriter(AnalyzerType analyzerType) { return(GetWriter(analyzerType, true)); }
public override IndexWriter GetWriter(AnalyzerType analyzerType, bool create) { return(this.GetWriter(analyzerType, create, true)); }
public virtual IndexWriter GetWriter(AnalyzerType analyzerType, bool create) { return GetWriter(analyzerType, create, false); }
/// <summary> /// Extends AnalyzerType with the method ToDiagnosticId. /// </summary> /// <param name="diagnosticId">The AnalyzerType to convert to the required string.</param> /// <returns>The diagnostic Id formatted as required.</returns> public static string ToDiagnosticId(this AnalyzerType diagnosticId) { return($"CAP{(int)diagnosticId:D4}"); }
/// <summary> /// Takes the manaually generated query and runs it through a specified Lucene analyzer /// </summary> /// <param name="analyzerType">Lucene analyzer to run current query through</param> public void Analyze(AnalyzerType analyzerType) { Analyze(analyzerType, ClauseOccurrence.Default); }
public override IndexWriter GetWriter(AnalyzerType analyzerType, bool create, bool unlimitedFieldLength) { // return IndexWriter.Open(analyzerType, this.mirrorDirectory, unlimitedFieldLength, create); return(new IndexWriter(this, analyzerType, create, unlimitedFieldLength)); }
/// <summary> /// Adds the string query. /// </summary> /// <param name="queryText">The query text.</param> /// <param name="occurrence">The occurrence.</param> /// <param name="analyzerType">Type of the analyzer.</param> /// <returns>True if query string is parsed and appended successfully</returns> public bool AddStringQuery(string queryText, ClauseOccurrence occurrence, AnalyzerType analyzerType) { return AddStringQuery(queryText, occurrence, analyzerType, this.totalClauses > 0); }
/// <summary> /// Adds the string query. /// </summary> /// <param name="queryText">The query text.</param> /// <param name="occurrence">The occurrence.</param> /// <param name="analyzerType">Type of the analyzer.</param> /// <param name="merge">if set to <c>true</c> [merge].</param> /// <returns>True if query string is parsed and appended successfully</returns> public bool AddStringQuery(string queryText, ClauseOccurrence occurrence, AnalyzerType analyzerType, bool merge) { if (string.IsNullOrEmpty(queryText)) throw new ArgumentNullException("queryText", "queryText cannot be null or empty"); // this try catch is here to protect you from lucene specific exceptions bool success = true; IncrementTotalClauses(1); try { Lucene29.Net.QueryParsers.QueryParser parser = new Lucene29.Net.QueryParsers.QueryParser(StaticValues.LibraryVersion, "QueryParser", TypeConverter.GetAnalyzer(analyzerType)); Query query = parser.Parse(queryText); if (query == null) { success = false; } else { if (merge) this.luceneQuery.Combine(new Query[] { query }); else this.luceneQuery.Add(query, TypeConverter.ConvertToLuceneClauseOccurrence(occurrence)); } } catch (Exception) { //System.Diagnostics.Debug.WriteLine("Lucene exception -> " + ex.Message); success = false; this.totalClauses--; } return success; }
public override IndexWriter GetWriter(AnalyzerType analyzerType, bool create, bool unlimitedFieldLength) { // return IndexWriter.Open(analyzerType, this.mirrorDirectory, unlimitedFieldLength, create); return new IndexWriter(this, analyzerType, create, unlimitedFieldLength); }
/// <summary> /// Takes the manaually generated query and runs it through a Lucene analyzer /// </summary> /// <param name="analyzer">Analyzer to use when parsing this query</param> /// <param name="occurrence">Occurrence type of this query</param> internal void Analyze(Lucene29.Net.Analysis.Analyzer analyzer, ClauseOccurrence occurrence) { if (analyzer == null) throw new ArgumentNullException("analyzer", "Analyzer cannot be null"); try { AnalyzerType requestedType = TypeConverter.GetAnalyzerType(analyzer); if (cachedAnalyzer != requestedType) { lock (syncRoot) { if (cachedAnalyzer != requestedType) { cachedParser = new Lucene29.Net.QueryParsers.QueryParser(StaticValues.LibraryVersion, "Analyzer", analyzer); cachedAnalyzer = requestedType; cachedParser.SetAllowLeadingWildcard(this.allowLeadingWildcard); } } } Query query = cachedParser.Parse(this.luceneQuery.ToString()); this.luceneQuery = null; this.luceneQuery = new BooleanQuery(this.disableCoord); this.luceneQuery.Add(query, TypeConverter.ConvertToLuceneClauseOccurrence(occurrence)); } catch (Exception ex) { throw new FormatException("There was an unexpected exception thrown during the analyzing process of the instance.", ex); } }
public override IndexWriter GetWriter(AnalyzerType analyzerType, bool create, bool unlimitedFieldLength) { return new IndexWriter(this, analyzerType, create, unlimitedFieldLength); }
public virtual IndexWriter GetWriter(AnalyzerType analyzerType) { return GetWriter(analyzerType, true); }
public virtual IndexWriter GetWriter(AnalyzerType analyzerType, bool create, bool unlimitedFieldLength) { //return IndexWriter.Open(analyzerType, this.directory, unlimitedFieldLength, create); return(new IndexWriter(this, analyzerType, create, unlimitedFieldLength)); }
public virtual IndexWriter GetWriter(AnalyzerType analyzerType, bool create, bool unlimitedFieldLength) { //return IndexWriter.Open(analyzerType, this.directory, unlimitedFieldLength, create); return new IndexWriter(this, analyzerType, create, unlimitedFieldLength); }
public void WriteDataSet(DataSet dataSet, IndexWriterRuleCollection ruleCollection, AnalyzerType analyzerType) { if (!this.IsOpen) { throw new ObjectDisposedException("IndexWriter", "You cannot access this method from a disposed IndexWriter"); } if (dataSet == null || dataSet.Tables.Count == 0) { return; } if (ruleCollection == null) { throw new ArgumentNullException("ruleCollection", "ruleCollection cannot be null"); } int totalTables = dataSet.Tables.Count; for (int i = 0; i < totalTables; i++) { WriteDataTable(dataSet.Tables[i], ruleCollection, analyzerType); } }
public override IndexWriter GetWriter(AnalyzerType analyzerType, bool create, bool unlimitedFieldLength) { return(new IndexWriter(this, analyzerType, create, unlimitedFieldLength)); }
public void WriteDataTable(DataTable dataTable, IndexWriterRuleCollection ruleCollection, AnalyzerType analyzerType) { if (!this.IsOpen) { throw new ObjectDisposedException("IndexWriter", "You cannot access this method from a disposed IndexWriter"); } if (dataTable == null) { throw new ArgumentNullException("dataTable", "dataTable cannot be null"); } if (ruleCollection == null) { throw new ArgumentNullException("ruleCollection", "ruleCollection cannot be null"); } int totalColumns = dataTable.Columns.Count; int totalRows = dataTable.Rows.Count; if (totalColumns == 0 || totalRows == 0) { return; } for (int i = 0; i < totalRows; i++) { DataRow row = dataTable.Rows[i]; IndexDocument document = new IndexDocument(); for (int j = 0; j < totalColumns; j++) { DataColumn column = dataTable.Columns[j]; if (string.IsNullOrEmpty(column.ColumnName)) { continue; } IndexWriterRule rule = ruleCollection.GetRuleFromType(column.DataType); if (rule.SkipField(column.DataType, column.ColumnName)) { continue; } FieldStorage storageRule = rule.GetStorageRule(column.ColumnName); // that's all the field data, now lets get the value data object rowValue = row[j]; bool isRowNull = rowValue == null || rowValue == DBNull.Value || string.IsNullOrEmpty(rowValue.ToString()); if (rule.SkipColumnIfNull && isRowNull) { continue; } else if (!rule.SkipColumnIfNull && string.IsNullOrEmpty(rule.DefaultValueIfNull) && isRowNull) { continue; } string fieldValue = (isRowNull) ? rule.DefaultValueIfNull : rowValue.ToString(); rowValue = null; document.Add(new FieldNormal(column.ColumnName, fieldValue, storageRule.Store, storageRule.SearchRule, storageRule.VectorRule)); } if (document.TotalFields > 0) { if (analyzerType == AnalyzerType.None || analyzerType == AnalyzerType.Unknown) { this.Write(document); } else { this.Write(document, analyzerType); } } } }
public void WriteDataView(DataView view, IndexWriterRuleCollection ruleCollection, AnalyzerType analyzerType) { DataTable table = null; if (view != null) { table = view.Table == null?view.ToTable() : view.Table; } WriteDataTable(table, ruleCollection, analyzerType); }
public virtual IndexWriter GetWriter(AnalyzerType analyzerType, bool create) { return(GetWriter(analyzerType, create, false)); }
/// <summary> /// Internal load method called from the constructor. Loads underlying values /// based on Xml configuration. /// </summary> /// <param name="node">XmlNode definition for a given IndexSet</param> internal void LoadValues(XmlNode node) { XmlAttributeCollection attributeCollection = node.Attributes; try { this._intId = Convert.ToInt32(attributeCollection["id"].Value); } catch (Exception) { throw new ConfigurationErrorsException("IndexSet id invalid: " + Environment.NewLine + node.OuterXml); } try { this._eIndexAction = (IndexAction)Enum.Parse(typeof(IndexAction), attributeCollection["action"].Value); } catch (Exception) { throw new ConfigurationErrorsException("IndexSet "+this._intId.ToString()+" IndexAction invalid: " + Environment.NewLine + node.OuterXml); } try { if (attributeCollection["analyzer"] != null) this._eAnalyzerType = (AnalyzerType)Enum.Parse(typeof(AnalyzerType), attributeCollection["analyzer"].Value); } catch (Exception) { throw new ConfigurationErrorsException("IndexSet " + this._intId.ToString() + " analyzer invalid: " + Environment.NewLine + node.OuterXml); } if (node.ChildNodes.Count==0) throw new ConfigurationErrorsException("IndexSet " + this._intId.ToString() + " configuration missing " + Environment.NewLine + node.OuterXml); foreach (XmlNode c in node.ChildNodes) { if (!c.HasChildNodes) { switch (c.Attributes["key"].Value.ToLower()) { case "localpath": this._strLocalPath = c.Attributes["value"].Value; break; case "idcolumn": this._strIdColumn = c.Attributes["value"].Value; break; case "bottomid": try { this._intBottomId = Convert.ToInt32(c.Attributes["value"].Value); } catch (Exception) { throw new ConfigurationErrorsException("IndexSet " + this._intId.ToString() + " bottomid invalid: " + Environment.NewLine + node.OuterXml); } break; case "topid": try { this._intTopId = Convert.ToInt32(c.Attributes["value"].Value); } catch (Exception) { throw new ConfigurationErrorsException("IndexSet " + this._intId.ToString() + " topid invalid: " + Environment.NewLine + node.OuterXml); } break; } } else { switch(c.Name.ToLower()) { case "copy": if (this._strLocalPath!=null) LoadCopy(c,this._strLocalPath); else LoadCopy(c,node); break; } } } this.CheckValidSet(node); }
public static string ToDiagnosticId(this AnalyzerType diagnosticId) => $"CAP{(int)diagnosticId:D4}";
public IndexWriter(IIndex index, AnalyzerType analyzer) : this(index, analyzer, true) { }
/// <summary> /// Internal load method called from the constructor. Loads underlying values /// based on Xml configuration. /// </summary> /// <param name="node">XmlNode definition for a given IndexSet</param> internal void LoadValues(XmlNode node) { XmlAttributeCollection attributeCollection = node.Attributes; try { this._intId = Convert.ToInt32(attributeCollection["id"].Value); } catch (Exception) { throw new ConfigurationErrorsException("IndexSet id invalid: " + Environment.NewLine + node.OuterXml); } try { this._eIndexAction = (IndexAction)Enum.Parse(typeof(IndexAction), attributeCollection["action"].Value); } catch (Exception) { throw new ConfigurationErrorsException("IndexSet " + this._intId.ToString() + " IndexAction invalid: " + Environment.NewLine + node.OuterXml); } try { if (attributeCollection["analyzer"] != null) { this._eAnalyzerType = (AnalyzerType)Enum.Parse(typeof(AnalyzerType), attributeCollection["analyzer"].Value); } } catch (Exception) { throw new ConfigurationErrorsException("IndexSet " + this._intId.ToString() + " analyzer invalid: " + Environment.NewLine + node.OuterXml); } if (node.ChildNodes.Count == 0) { throw new ConfigurationErrorsException("IndexSet " + this._intId.ToString() + " configuration missing " + Environment.NewLine + node.OuterXml); } foreach (XmlNode c in node.ChildNodes) { if (!c.HasChildNodes) { switch (c.Attributes["key"].Value.ToLower()) { case "localpath": this._strLocalPath = c.Attributes["value"].Value; break; case "idcolumn": this._strIdColumn = c.Attributes["value"].Value; break; case "bottomid": try { this._intBottomId = Convert.ToInt32(c.Attributes["value"].Value); } catch (Exception) { throw new ConfigurationErrorsException("IndexSet " + this._intId.ToString() + " bottomid invalid: " + Environment.NewLine + node.OuterXml); } break; case "topid": try { this._intTopId = Convert.ToInt32(c.Attributes["value"].Value); } catch (Exception) { throw new ConfigurationErrorsException("IndexSet " + this._intId.ToString() + " topid invalid: " + Environment.NewLine + node.OuterXml); } break; } } else { switch (c.Name.ToLower()) { case "copy": if (this._strLocalPath != null) { LoadCopy(c, this._strLocalPath); } else { LoadCopy(c, node); } break; } } } this.CheckValidSet(node); }
public IndexWriter(IIndex index, AnalyzerType analyzer, bool create) : this(index, analyzer, create, false) { }