开发者

C# CodeModel Find out if CodeParameter is out or ref

开发者 https://www.devze.com 2023-01-20 01:56 出处:网络
I am using CodeModel inside of a T4 template to generate some code based from an interface. I am able to get the interface methods, parameter names, and parameter types but I can\'t seem to be able to

I am using CodeModel inside of a T4 template to generate some code based from an interface. I am able to get the interface methods, parameter names, and parameter types but I can't seem to be able to find out wither the parameter is an out or ref parameter.

http://msdn.microsoft.com/en-us/library/envdte.codeparameter.aspx

foreach ( CodeElement child in func.Children )
        {
            CodeParameter param = child as CodeParameter;
            if ( param != null ) 
            {
           开发者_运维知识库     Write("{0}{1} {2}", nextString, param.Type.AsString, param.Name);
                nextString = ", ";
            }
        }

Any ideas on how to get this information?


http://www.visualstudiodev.com/visual-studio-extensibility/codemodel-alternatives-11973.shtml
According to that link you can cast it to CodeParameter2 and which has a property ParameterKind which differenciates ref and out.

0

精彩评论

暂无评论...
验证码 换一张
取 消