Closed dan-robinson closed 5 years ago
Nevermind, my above solution just ends up changing all types to "object". I found that I wasn't specifying the type when calling the "By" method on the filter. However, to do this correctly I had to invoke using reflection so that I could correctly set the type based on the value type.
Unfortunately I am using VB and working with a WinForms control (ucFilter) similar to the sample in this project.
Dim filterType = ucFilter.Value.GetType() Dim method As MethodInfo = GetType(Filter(Of clsGLPayRecord)).GetMethods().Where(Function(m As MethodInfo) m.Name = "By" AndAlso m.IsGenericMethod).First() Dim generic As MethodInfo = method.MakeGenericMethod(filterType) generic.Invoke(glRuleFilter, New Object() {ucFilter.PropertyId, ucFilter.Operation, ucFilter.Value, ucFilter.Value2, ucFilter.Connector})
The FilterStatment class does not serialize properly to XML, specifically the type is always going to be "FilterStatmentOfObject" due to setting the type equal to the type of "Value" which is always going to be "Object". It should be changed to the generic type "TPropertyType".