6 Important Delegates

  1. Predicate: essentially Func<T, bool>; asks the question “does the specified argument satisfy the condition represented by the delegate?” Used in things like List.FindAll.
  2. Action: Perform an action given the arguments. Very general purpose. Not used much in LINQ as it implies side-effects, basically.
  3. Func: Used extensively in LINQ, usually to transform the argument, e.g. by projecting a complex structure to one property.
  4. EventHandler/EventHandler<T>: Used all over WinForms
  5. Comparison<T>: Like IComparer<T> but in delegate form.
  6. Converter<TInput, TOutput>: It’s essentially Func<TInput, TOutput>, but with semantics. Used by List.ConvertAll and Array.ConvertAll, but personally haven’t seen it anywhere else.The Converter is a nice delegate when a lot of Converting of Model into Business classes is needed, i.e. http://www.stum.de/2009/12/23/using-a-converter-to-convert-from-a-model-to-a-business-class/

NVelocity in Medium Trust ASP.Net Enviroment

The NVelocity DLLs download from castleproject.org can not run in ASP.Net with medium trust level enviroment.You need to modify the NVelocity source code and rebuild it, here is how to :
1. Download the sources from http://github.com/castleproject/NVelocity.
2. Open NVelocity solution with Visual Studio 2008.
3. Add codes below in CommonAssemblyInfo.cs:

using System.Security;
[assembly: AllowPartiallyTrustedCallers()]

4. Rebuild the NVelocity-2008 project.
5. Referrence NVelocity.dll in your web project.
6. Add <trust level=”Medium”/> in web.config and test it .

5 Interesting Open Source Projects

1、NWebCrawler

This is a web crawler program written in C#.Features:

  • Configuable: thread count, waiting time, connection timeout, allow MIME types and priorities, download folders.
  • Statstics information: URL count, total downloaded files, total downloaded bytes, CPU utility and available memory.
  • Preferential crawler: user can set priority for MIME types (high, above, normal, below, low).
  • Robust: 10+ URL normalization rules, crawler trap avoiding rules.


2、NPatternRecognizer

NPatternRecognizer is a fast machine learning algorithm library written in C#. It contains support vector machine, neural networks, bayes, boost, k-nearest neighbor, decision tree, …, etc.

‘learn’ chess board pattern with support vector machine, chess board pattern is a 640 random points formed synthetic dataset.

legend: squares are support vectors.
3、NComputerVision
NComputerVision is a fast computer vision algorithm library written in C#.

upcoming NComputerVision sample provides data file for facial express recognition:

edge detection:

Circle detection:

sharpening:
moon (before sharpening):

moon (after sharpening):

contour extraction:

4、NPlanner
NPlanner is a fast intelligent planner based on graphplan algorithm written in C#.

5、NRuler
NRuler is a fast production system based on RETE algorithm written in C#.
The following diagram illustrates the basic Rete topography (three rules), and shows the associations between different node types and memories.

legends: