Codesmith Method Picker Property

Rating:        Based on 1 rating
Reviewed:  0 reviews
Downloads: 235
Released: Oct 29, 2008
Updated: Oct 29, 2008 by martinolivares
Dev status: Beta Help Icon

Recommended Download

Source Code MethodPicker.rar
source code, 72K, uploaded Oct 29, 2008 - 130 downloads

Other Available Downloads

Application MethodPicker.dll
application, 18K, uploaded Oct 29, 2008 - 54 downloads
Application MethodsToWebService.cst
application, 3K, uploaded Oct 29, 2008 - 51 downloads

Release Notes

Installation
Copy MethodPicker.dll to the Codesmith "bin" folder

Usage
1) Register the assembly in the template adding the following code

<%@ Assembly Name="MethodPicker" %>
<%@ Import NameSpace="MethodPicker" %>

2) Add a property with the MethodPicker editor
<%@ Property Category="Assembly Methods" Name="Methods" Type="System.String" Optional="True"
Description="Select assembly and methods"
Editor="MethodPicker" %>

3) Use the selected methods in template code. The edited property returns a string array that contains the assembly path and the MethodHandle of each method. You must load the assembly and iterate the methodhandle array.

<script runat="template">
public Type[] assemblyTypes;
private MethodInfo GetMethodInfoByTypeMethod(string typeMethod)
{
string[] classAndMethodNames = methodSignature.Split(new char[] {'@'});
if (classAndMethodNames.Length == 2)
{
foreach(Type type in assemblyTypes)
{
if (type.FullName == classAndMethodNames[[0]])
{
foreach(MethodInfo methodInfo in type.GetMethods())
{
if(methodInfo.ToString() == classAndMethodNames[[1]])
return methodInfo;
}
}
}
}
return null;
}
</script>

<%
string[] arrValues = Methods.Split(new char[] { '#' });
if (arrValues.Length > 0)
{
Assembly asm = Assembly.LoadFrom(arrValues[[0]]);
assemblyTypes = asm.GetTypes();
for (int i = 1; i < arrValues.Length - 1; i++)
{
MethodInfo mi = GetMethodInfoByTypeMethod(arrValues[[i]]);
if (mi != null)
RenderMethodBody(mi);
}
}
%>

Reviews for this release