I am getting this exception. "Public member InjectFrom
on type ApplicationObj_B
not found."
I figured out the reason for this. This is because, I am checking if the source property type is value or array only. However, my source property type is an object which has properties inside it. How to write that thrid condition and inject values of those properties inside that object?
I am trying to inject one object and its child object to target object and child object. It has basically properties. Please help me
It throws exception in the final Create Activator instance line.
Protected Overrides Function SetValue(c As ConventionInfo) As Object
If c.SourceProp.Type.IsValueType OrElse c.SourceProp.Type = GetType(String) OrElse c.TargetProp.Type.IsValueType OrElse c.TargetProp.Type = GetType(String) Then
Return c.SourceProp.Value
End If
If c.SourceProp.Type.IsArray Then
Dim arr = TryCast(c.SourceProp.Value, Array)
If arr IsNot Nothing Then
Dim clone = TryCast(Activator.CreateInstance(c.TargetProp.Type, arr.Length), Array)
For index As Integer = 0 To arr.Length - 1
Dim a = arr.GetValue(index)
If a.[GetType]().IsValueType OrElse TypeOf a Is String Then
Continue For
End If
If clone IsNot Nothing Then
clone.SetValue(Activator.CreateInstance(c.TargetProp.Type.GetElementType()).InjectFrom(Of CloneInjection)(a), index)
End If
Next
Return clone
End If
End If
Return Activator.CreateInstance(c.TargetProp.Type).InjectFrom(Of CloneInjection)(c.SourceProp.Value)
End Function