I think your looking for CodeAttachEventStatement, I believe there is an
example in the documentation for this class.
Close, but CodeAttachEventStatement made me reconsider using
CodeDelegateCreateExpression which I didn't think I needed but in fact
does the trick. FWIW, I wanted to create something like the following
in c#:
System.Array.ConvertAll<ProprietaryDateTime,
System.DateTime>(dtrange_pr.ToArray(), new
System.Converter<ProprietaryDateTime,
System.DateTime>(ProprietaryDateTime.ConvertProprietaryDateTimeToDateTime));
So to get there I ended up using something like the following in
codedom:
CodeMethodReferenceExpression arrayConvertAllGeneric = new
CodeMethodReferenceExpression(
new CodeTypeReferenceExpression(typeof(Array)),
"ConvertAll",
new
CodeTypeReference(typeof(ProprietaryDateTime)),
new CodeTypeReference(typeof(DateTime))
);
CodeMethodInvokeExpression dtrangeToArray = new
CodeMethodInvokeExpression(
new CodeVariableReferenceExpression("dtrange_pr"),
"ToArray"
);
CodeDelegateCreateExpression createDelegate = new
CodeDelegateCreateExpression(
new CodeTypeReference("System.Converter", new
CodeTypeReference(typeof(ProprietaryDateTime)), new
CodeTypeReference(typeof(DateTime))),
new
CodeTypeReferenceExpression(typeof(ProprietaryDateTime)),
"ConvertProprietaryDateTimeToDateTime"
);
CodeMethodInvokeExpression arrayConvert = new
CodeMethodInvokeExpression(
arrayConvertAllGeneric,
dtrangeToArray,
createDelegate
);
This produces the desired result in c# and vb. Thanks for the help!