Απο τα λεγομενα σου καταλαβαινω οτι εχεις να κανεις με μια εφαρμογη η οποια πρεπει να "αλλαζει" το τροπο λειτουργιας ανα τακτο χρονικο διαστημα.
Για να μην κανεις rebuιld καθε μηνα για να βαλεις μια καινουρια συναρτηση, καλυτερα παιξεις με reflection. Τι θελω να πω, θα σου παραθεσω
ενα απλουστατο κομματι κωδικα στο οποιο γινετε επεξεργασια ενος αντικειμενου (το οποιο μπορει να ειναι αγνωστο) απο ενα αλλο αγνωστο αντικειμενο,
χωρις να επεμβουμε στο κωδικα της εφαρμογης (κατι σα addon για κωδικα)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization.Formatters.Binary;
using System.IO;
namespace ConsoleApplication2
{
class Program
{
class myObject { public int someValue { get; set; } public Iexp expre { get; set; } }
static void Main(string[] args)
{
//.... create a new expression
CreateExpre(new exp1());
//....
//some object type using a new expression
myObject myobj = new myObject { someValue = 123, expre = LoadExp1() };
//...
//work
myobj.expre.exp(myobj);
//.. :P
Console.WriteLine(myobj.someValue);
Console.Read();
}
static void CreateExpre(object expre)
{
BinaryFormatter forma = new BinaryFormatter();
using (var file = File.Create(@"c:\exp1.BLOCKED EXPRESSION)
{
forma.Serialize(file, expre);
}
}
static Iexp LoadExp1()
{
BinaryFormatter forma = new BinaryFormatter();
object obj = null;
using (var file = File.Open(@"c:\exp1.expression", FileMode.Open))
{
obj = forma.Deserialize(file);
}
return obj as Iexp;
}
}
interface Iexp
{
void exp(object obj);
}
[Serializable]
class exp1 : Iexp
{
#region Iexp Members
void Iexp.exp(object obj)
{
var unknow = obj.GetType();
var property = unknow.GetProperty("someValue");
int? someValue = (int?)property.GetValue(obj, null);
if (someValue == null)
throw new Exception("reflect error");
if (someValue.Value > 100)
{
property.SetValue(obj, someValue * 2, null);
}
}
#endregion
}
}
Αλλο που μου ερχετε ειναι να φτιαξεις μια μηχανη Script (power by regula expression :P )