Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a pattern to pass parameter to another assembly?

From a couple of my Assemblys like AssemblyA, AssemblyB, AssemblyC, AssemblyD I am calling a method in AssemblyE

for example:

DialogHelper.DisplayComments( param1,2,3,4) ;

now for some of those assemblies and not all of them I need to have an Overloaded version of DisplayComments() method that takes one more new parameter that I want to pass to:

DialogHelper.DisplayComments(param1,2,3,4,"5") ;

So one way is what I did: create an overload and pass the value.

But I was wondering if in .NET and Obeject-Oriented world is there any other elegant way of doing this so I can pass this value to that Assembly and that method?

like image 219
Bohn Avatar asked Dec 08 '25 21:12

Bohn


2 Answers

if you have the source code you better overload the DisplayComments method

otherwise (if they are not static methods) you can create an extension method that takes one more parameter

like image 100
Massimiliano Peluso Avatar answered Dec 10 '25 11:12

Massimiliano Peluso


In OOP world overloading is already very elegant.

If you want to try something else, can add Optional parameters, like for example

DialogHelper.DisplayComments(string param1, int prm2, int prm3, int prm4, string paramOtional="5") ;

Good luck

like image 29
Tigran Avatar answered Dec 10 '25 09:12

Tigran



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!