1

Here is my problem :

I have a dll containing some mathematical functions, the code looks that way:

internal sealed class TemplateSourceCodeClass
{
    public const string MathExpressionEvaluationCode =
    @"using System;
        class MathExpressionEvaluation
        {
            public object Eval(double value)
            {}
            public double abs(double dValue)
            {}

the probleme is that it manipulate only double variables and I need to be able to manipulate all kind of number (UInt32, UInt64, Byte ...)

Should I write an other class ? and make it a generic class ?

The class is called by some methods inside the dll (another class)

public class MathExpressionEvaluator : BaseEvaluator
{
    static private CSharpCodeProvider _csharpCodeProvider;
    static private Dictionary<string,object>  equations;
    public MathExpressionEvaluator()
    {}
   public void Compile(string formulaString)
    {}
  • I don t have access to the code of the dll

I m sorry if the question is not clear enough but If you need further expplications, just ask

Any help could be useful

I searched on the forum and I didn t find something that helped me but If you think that the question was already answered just give me the link

Thank you verry much

user2492258
  • 11
  • 1
  • 3
  • 1
    If its not your DLL you can't modify its behaviour, you could try casting your inputs/outputs but you won't have the precision – Sayse Jun 17 '13 at 06:40
  • Do you need to add into this .dll? Will be used by someone else? If you need only for yourself, you can make an extension for your class. Its not possible to add something into .dll without rebuilding it - so you have to have a source code of whole dll. – Martin Ch Jun 17 '13 at 06:43

1 Answers1

3

you can create an extentsion method

If you wan to add a Method to the MathExpressionEvaluation class, you have to do create a public static class like this :

public static class Extentions
{
    public static object Eval(this MathExpressionEvaluation mathExpress, double value)
    {
        double x = value;
        object o = null;
        o= value;
        return o;
    }
}

After you can you your method like this :

MathExpressionEvaluation mathExpression = new MathExpressionEvaluation();
object o = mathExpression.Eval(1);

Hope it's help !

Joffrey Kern
  • 6,449
  • 3
  • 25
  • 25