1

Resolved

Add a new attribute [InitializerAttribute] for creating an instance of the type

description

for some season, we will not provide a public constructor with no parameters,so we can NOT create an instance for the type under some TrustLevel (e.g. Medium).

or we will get more better performance, so we want to create an instance via a function instead of reflection.

So we should define a new attribute [InitializerAttribute], it should have a property that is a function.

comments

cnlangzi wrote Dec 16, 2010 at 4:15 AM

Attribute can NOT contains a anonymous function or a lambda expression, so we can NOT skip reflection to execute the code.

Seem like this solution is not good.

We should add an api in ObjectContainer ,let developer can register the execute code (regular function, anonymous function or lambda expression) for creating an instance of the type.

e.g.

ObjectContainer.RegisterInitilizer<T>(Func<T> func)