Tags: C#

How to search a Lucene.Net index in C#

Benjamin Perkins Lucene.NET

I used this code to perform a search of a Lucene.Net index. Lucene.Net.Store..Directory directory =      Lucene.Net.Store.FSDirectory                .Open(new DirectoryInfo(textBoxSearchIndex.Text)); Lucene.Net.Analysis.Analyzer analyzer =      new Lucene.Net.Analysis.Standard                    .StandardAnalyzer(LuceneUtil.Version.LUCENE_29); Lucene.Net.Search.Searcher searcher =      new Lucene.Net.Search                .IndexSearcher(LuceneIndex.IndexReader                                          .Open(directory, true)); Lucene.Net.Search.Query query =      new Lucene.Net.QueryParsers                .QueryParser(LuceneUtil.Version.LUCENE_29,                             “contents”, analyzer)                             .Parse(textBoxSearch.Text); Lucene.Net.Search.Hits hits = […]

Read More →

Treeview with checkbox in WPF

Benjamin Perkins C#

On one of my projects I had to provide treeview selection functionality. I searched the internet and pulled everything I could into a this single resource. I wasn’t able to find 1 post that provided all the details and source code to do what I needed. Now there is one and if you find it, […]

Read More →

Strings in C#

The String class in .Net has many capabilities. Below is a list of some string methods I use frequently in my development projects. Even when I have completed this list, I am sure it will over cover 5% of the capabilities within the String class. After reading this, I suggest you look over the MSDN […]

Read More →

Constants and Enums in C#

Benjamin Perkins C#

Constants come in handy when you need to store values that will be used frequently within the system and at the same time will not change often, if ever. You want to avoid hard coding values in you code. It makes maintenance and debugging very difficult. You can create a constants class and then access […]

Read More →

How to use Data Parallelism from the Task Parallel Library in C#

Benjamin Perkins C#

I wrote a program a few months back that populated a dropdown list with contents from a class using reflection. I used a normal for each statement. [sourcecode language=”csharp” padlinenumbers=”true” autolinks=”false” gutter=”false” toolbar=”false”] foreach (Type type in assembly.GetTypes() .OrderBy(f => f.MetadataToken)) { if (type.Namespace != null) { if (!type.Namespace.ToLower().StartsWith(“namespace”)) combobox1.Add(new ComboBoxClass(type.Name, type.FullName)); } } [/sourcecode] […]

Read More →