public OrmEntityMethod CreateMethod(OrmEntity entity)
{
if (MethodType == Sage.Platform.Orm.Entities.MethodType.Rule)
{
OrmEntityMethod method = new OrmEntityMethod
{
ActionType = ActionType.None,
ReturnType = ReturnType,
MethodName = Name,
MethodType = MethodType
};
if (ParameterTypes != null && ParameterTypes.Length > 0)
{
//MethodParameterCollection paramColl = new MethodParameterCollection(method);
foreach (ParamDescription p in ParameterTypes)
{
method.MethodParameters.Add(new OrmEntityMethodParam { ParamName = p.Name, ParamType = p.ParamType });
}
}
return method;
}
else if (MethodType == Sage.Platform.Orm.Entities.MethodType.CrudEvent)
{
switch (EventType)
{
case AutoWire.EventType.BeforeUpdate:
return entity.OnBeforeUpdateMethod;
case AutoWire.EventType.AfterUpdate:
return entity.OnAfterUpdateMethod;
case AutoWire.EventType.BeforeInsert:
return entity.OnBeforeInsertMethod;
case AutoWire.EventType.AfterInsert:
return entity.OnAfterInsertMethod;
case AutoWire.EventType.BeforeDelete:
return entity.OnBeforeDeleteMethod;
default:
throw new Exception("Invalid event type " + EventType + " for AutoWire method " + DeclaringType + "." + Name);
}
}
else
{
throw new Exception("Unsupported method type " + MethodType + " for AutoWire method " + DeclaringType + "." + Name);
}
}