|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.CodeDom;
namespace EntityMapper.CodeGen
{
public class MapCodeMemberMethod
{
public CodeMemberMethod Create(Type fromType, Type toType, string name = "Map", string fromParamName = "source", string toParamName = "target")
{
// Declaring a method void Map(fromType X, toType) ;
CodeMemberMethod method = new CodeMemberMethod();
method.Attributes = MemberAttributes.Public | MemberAttributes.Final;
method.Name = name;
// Declares parameters
CodeParameterDeclarationExpression paramFromType = new CodeParameterDeclarationExpression(new CodeTypeReference(fromType), fromParamName);
paramFromType.Direction = FieldDirection.In;
method.Parameters.Add(paramFromType);
CodeParameterDeclarationExpression paramToType = new CodeParameterDeclarationExpression(new CodeTypeReference(toType), toParamName);
paramToType.Direction = FieldDirection.In;
method.Parameters.Add(paramToType);
method.ReturnType = new CodeTypeReference("System.Void");
return method;
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I am always interested in finding innovative ways for building better applications and founded a technology company since 2003. Welcome to exchange any idea with you and if I am not too busy before deadline of projects, I will reply your emails. Also, if you willing to pay for consulting works and customized software development, you can leave me message.