I have an custom class DataLookupList, and it has the following private member
private Func<TValue, TKey> m_selector;
I want to be able to export its state to XML ( XML is a requirement, so I can't use binary or something else ), so I can import the object in another place. I can't seem to be able to export the Func<> to a String though. When exporting it to XML via
new XElement( "Selector", m_selector )
I get its string representation which is "System.Func`2[System.Int32,System.Int32]", but when I try to import it via
TypeDescriptor.GetConverter( typeof( Func<TValue, TKey> ) ).ConvertFromString( element.Value )
I get an error, because "System.Func`2[System.Int32,System.Int32]" cannot be parsed back.
Is it possible at all to store a Func to a String, and if not why ?