Hello Sippyuconn,
Apart from Marc's suggestions, you may also try this:
1. Create a list of TemplateInfo with .NET Reflection
string typeName =
"System.Collections.Generic.List`1[[TestNamespace.TemplateInfo,
TestAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]";
Type type = Type.GetType(typeName);
object o = Activator.CreateInstance(type);
,where typeName is the full type name of List<TemplateInfo>.
"TestNamespace" is the namespace of the class and TestAssembly is the
target assembly with strong name info.
You may get the type name in an easier way by not using Reflection first:
List<TemplateInfo> list = new List<TemplateInfo>();
Console.Write(list.GetType().FullName);
2. Iterate the list object with Reflection.
One solution is Marc's suggestion of converting the object to IList.
Another way is to invoke the "get_Item" method with Reflection:
a. Get the count of elements in the collection
type.InvokeMember("Count", System.Reflection.BindingFlags.GetProperty,
null, o, null);
b. Get each object in a for statement:
object element = type.InvokeMember("get_Item",
System.Reflection.BindingFlags.InvokeMethod, null, l, new object[] { index
});
There might be other better ways to iterate the collection with .NET
Reflection. I appreciate other community members' inputs.
Regards,
Jialiang Ge (
[email protected], remove 'online.')
Microsoft Online Community Support
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://support.microsoft.com/select/default.aspx?target=assistance&ln=en-us.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.