My favorites | Sign in
Logo
                
Search
for
Updated May 20, 2009 by fedorchenko
NReco  
Describes NReco Core Services.

Core

NReco core (NReco assembly) defines minimal infrastructure required for all components:

  • common interfaces
  • run-time type conversion module
  • vendor-independent logging module

Type Conversion

This subsystem provides flexible and extensible mechanism for run-time types conversion (just as System.Convert for simple types). It simplifies components interaction (especially when their configuration was automatically generated from models) by encapsulating all work related to types casting and conversion. ConvertManager class provides simple access to this mechanism:

var h = new Hashtable { {"a", "b"} };
var dict = ConvertManager.ChangeType<IDictionary<string,string>>( h );

Standard converters are:

Additionally it's possible to add custom converters using application config:

<configSections>
	<section name="nreco.converting" type="NReco.Converting.ConvertManagerCfgHandler,NReco"/>
</configSections>
<nreco.converting>
	<converter>NReco.Winter.Converting.NiOperationConverter,NReco.Winter</converter>
</nreco.converting>

Don't forget to initialize you configuration: ConvertManager.Configure();

Logging

Because of a lot of abstraction layers models debugging may become an nontrivial task. .NET platform has at least 2 approaches to do that:

That's why all NReco classes uses internal extra-lightweight logging mechanism. By internal organization it is similar to log4net; interfaces are extremely lightweight. In any case it didn't reinvent a wheel and redirects all log event to either log4net or internal .NET logging. But right now you have a choice. Here is typical usage scenario:

class MyClass {
	static ILog log = LogManager.GetLogger(typeof(MyClass));
	protected void MyMethod() {
		int myVar = 0;
		log.Write(
			LogEvent.Error,
			new{Action="some event description",myVar=myVar} );
	}
}

Component Composition

NReco.Composition introduces POCO-components composition model. Central interfaces are IProvider<,> and IOperation<>. They represents 2 main concepts from NReco upper-level ontology:

  • provider is an object that performs transportation/convertation/transformation function over some object. By its semantics it is similar to math function in some sense.
  • operation is an object that represents some action in the system.

Providers

Standard providers are:

Additional providers are:

Operations

Standard operations are:

  • Chain used for organizing sequential calls to another providers and operations
  • InvokeMethod / DynamicInvokeMethod used for invoking another object's method as operation
  • EvalCsCode used for C#-code based operations that compiled on-fly (note: ensure that your application security policy allows that)
  • Transaction used for wrapping another operation with transactional logic


Sign in to add a comment
Hosted by Google Code