Geeks With Blogs
Greg Young Greg.ToString()

I have been searching for an answer to this one and I am perplexed.

http://msdn2.microsoft.com/en-us/library/system.type.getgenericarguments.aspx returns an array of the generic arguments .. what I can't figure out is if they will ever be out of order. The arguments themselves have a position on them, is it possible that I get them back out of order where I would need to re-order them ...

basically what I am doing is something similar to the following on a generic type definition

 

                string [] Params = new string[typeArguments.Length];
                for (int i=0;i                {
                    Params[i] = typeArguments[i].Name;            
                }
                GenericTypeParameterBuilder[] typeParams = outputType.DefineGenericParameters(Params);
                Debug.Assert(typeParams.Length == typeArguments.Length);
                for(int i=0;i                    GenericTypeParameterBuilder builder = typeParams[i];
                    Type OriginalType = typeArguments[i];
                    builder.SetGenericParameterAttributes(OriginalType.GenericParameterAttributes);
                    builder.SetInterfaceConstraints(OriginalType.GetGenericParameterConstraints());
                }

 

I have to say as well that I am rather unimpressed with the bridge I am forced to put up here .. it would be alot nicer to just pass through the generic arguments I already have as opposed to creating a string [] then iterating through .. maybe I am missing something with the API?

and for those who know me well .. you probably know what I am working on .. (hint, the topic this is posted in)\

Update: it seems the documentation has been updated to reflect the return being sorted http://msdn2.microsoft.com/en-us/library/system.type.getgenericarguments.aspx

Posted on Sunday, May 28, 2006 5:24 AM AOP | Back to top


Comments on this post: GetGenericArguments

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © Greg Young | Powered by: GeeksWithBlogs.net