How to pass a C# list variable to another C# method?

When one calls a method, generally the AML is passed. Is there a way to pass a C# variable so I won't have to regex a string that it casts into when I pass it as I do currently in an AML tag attribute.

Such like access it some other way than AML for a C# to C# calling.

Best Regards,

Frank

Parents
  • Could you elaborate on your exact use case? There might be a better/alternative way of achieving the same end result.

    For example, you might be able to take advantage of setting a "fake property" as demonstrated in this blog post

  • My exact use case is a JS method that promises a C#'s method completion. The JS needs to pass it window.selectedIds. Also a C# onAfterAdd method calls the same C# method as the JS mentioned. It seems like the middleware AML turns all passed arguments into a string. Is there a way to do a more traditional object orientated caller, where I can preserve the data type?

    I understand that the AML layer and non-compatible data type of a JS list and C# list would require window.selectedIds to be passed as a string, except I would like know of a way to expect an argument as a list.

    When it comes to C# to C#, as mentioned in the paragraph before last, is there a way to have no AML in between the calls, so I can preserve a C# list to allow me to use myList.Add() right away?

    Best Regards,

    Frank

    PS Thank you for the blog post, I'll be bookmarking that

  • Ah, I see. Unfortunately, no, there's no way to preserve that kind of data-typing.

    However, there are plenty of utility functions to easily convert lists to and from strings nowadays. It is extra code to handle the AML layer, but one line of

    List<string> idList = this.getProperty("selected_ids", "").Split(",").ToList();

    should be enough to handle what you're looking for. And you can use the methodology from the blog post I linked to set this "fake" selected_ids property when you call this C# method. 

Reply
  • Ah, I see. Unfortunately, no, there's no way to preserve that kind of data-typing.

    However, there are plenty of utility functions to easily convert lists to and from strings nowadays. It is extra code to handle the AML layer, but one line of

    List<string> idList = this.getProperty("selected_ids", "").Split(",").ToList();

    should be enough to handle what you're looking for. And you can use the methodology from the blog post I linked to set this "fake" selected_ids property when you call this C# method. 

Children
No Data