Skip to content

Unknown identifier IDictionary #264

@rob53twenty

Description

@rob53twenty

I am trying to get dynamic expresso to interpret this line of code:

(((IDictionary<string, object>)o)["Diesel % in oil"].ToString().StartsWith("<") ? ((IDictionary<string, object>)o)["Diesel % in oil"].ToString().Replace("<", String.Empty) : ((IDictionary<string, object>)o)["Diesel % in oil"].ToString())

When it executes I get the following exception Unknown identifier 'IDictionary' (at index 3).

I am testing for a "<" at the start and then replacing all instances of the "<" (excuse the terrible key name - out of my control that one!).

I have tried adding typeof(System.Collections.Generic.IDictionary<string, object>) as a reference to the interpreter object, but no joy.

The full code:

    var interpreter = new Interpreter();
    interpreter.Reference(typeof(System.Collections.Generic.IDictionary<string, object>));
    interpreter.SetVariable("o", o);
    return (T)interpreter.Eval(code);

I'm sure I'm missing something simple.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions