Quantcast
Channel: DevNet Questions
Viewing all articles
Browse latest Browse all 8901

Create custom macro method returning a custom class

$
0
0
HelloI've written a CustomMacroMethod, which is returning a class, looking like:public class ReturningObject { public string Name {get; set;} public int Id {get; set;} } In my CustomMacroMethod, I have the following code:[assembly: RegisterExtension(typeof(CustomContactMacroMethod), typeof(ReturningObject))] namespace CMSAppAppCode.Old_App_Code { public class CustomContactMacroMethod : MacroMethodContainer { /// @summary@ /// Function to get the object /// @/summary@ /// @param name=@context@@@/param@ /// @param name=@parameters@@@/param@ /// @returns@Returns the object@/returns@ [MacroMethod(typeof(ReturningObject), @Returns the current office@, 1)] [MacroMethodParam(0, @CurrentPage@, typeof(ReturningObject), @The current rendered page@)] public static ReturningObject GetObject(EvaluationContext context, params object[] parameters) { var object = new ReturningObject { Name = @test@, Id = 0 }; return object; } } } When I in Kentico asks for GetObjecc(currentDocument).Name, it returns an empty string.Is there something I do wrong?

Viewing all articles
Browse latest Browse all 8901

Trending Articles