Hi everyone I am not sure if what I want to do is even remotely possible but I am going to do my best to explain it and would really appreciate any suggestions / ideas,
Imagine I have :-
public class Attribute{
object Value;
**(X1)**IComparer<T> comparer
}
public class AttributeValues
{
List<Attribute> values;
SortedList<Attribute> Sort(){
this uses the comparer defined in **(X1)** to sort the values in the list
}
}
These classes allow the user to create user defined attributes and select a pre-defined sort algorithm to sort the values In the simplistic case, I can do AttributesValues.Sort() using one of the comparers that I have created and compiled in source code which has been chosen by the user. This is fine when the comparison is known in advance such as a simple ascending alphabetical sort for example.
However, there are some circumstances where more logic is needed and it is not known in advance. For example, the string "4DFG5ET" might codify a date that needs to be sorted and there may be some other attribute with similar logic and so on.
If possible I don't want to keep writing the IComparer implementations and would love for it to be possible that somehow I could define the IComparer implementation in a text box or file at runtime and it would be somehow compiled in the program or persisted then available in the selction of comparisons that could be used to sort an attribute.
Does anyone have any suggestions on how to approach this?
Please ask if you would like me to clarify something as I know it is a slightly obscure question.
Many thanks in advance
Alex