Marc,
Perhaps consider making the namespace specific for each
script? So you have
Project1.Script.Class1 in Project1.dll
and
Project2.Script.Class1 in Project2.dll
Much simpler and more maintainable.
I'm planning to allow end users to override entity objects for custom
default values and validation using scripting.
Custom entity classes are created dynamically by entity factory. For
example, user can create the following script:
namespace MyApp.Script {
public class Invoice : MyApp.Business.Invoice {
public override void OnCreated(object sender, CreateEventArgs e) {
// set default customer for new invoice
this.CustomerId = "123";
}
}
}
Another, Query creation script which returns only some properties which we
discussed earlier refers to this object by using "MyApp.Script.Invoice".
User can also modify script at runtime, for example change CustomerId to
"456".
In this cases entity factory creates new type but it has same namespace and
name:
After that compiler error occurs in query creation script since script
engine adds references to all assemblies referenced by application to
compiler.
Possible solutions:
1. How I can use global aliases or different namespaces in this case ?
2. Create all other class creation scripts so that they take entity type as
generic type parameter.
In this case application can pass entity to type created by script using
MakeGenericType()
3. Should I create Linq expression insted of script ? I need to modify your
earlier selected property selection sample but
I do'nt know how to make such modification.
4. Should I use delegates and static methods insted of entity class dynamic
override ?
5. Modify script engine to add reference only to latest entity assembly to
compiler.
I don't know which is best solution. I will try solution 2 first since this
seems to be simplest to implement.
Andrus.